@parcha/agentrun-computer 0.1.0-beta.42 → 0.1.0-beta.44

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
@@ -1546,13 +1546,13 @@ the TTL.
1546
1546
  | `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 |
1547
1547
  | `isolation` | `container`, or `vm` with `sandboxClass: "linux-vm"` | the class comes from the snapshot |
1548
1548
  | `os` | `linux` | Linux classes only; Windows and macOS are not offered here |
1549
- | `daemon` | `child` | Daytona's toolbox daemon is the sandbox's first process, and init is started detached through a session command of it (above) |
1549
+ | `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)) |
1550
1550
  | `networkReadBack` | `false` | the network is probed from inside, the same for every hosted vendor |
1551
1551
  | `groups` | `exec`, `files`, `processes` | the daemon's own, checked against its hello's `groups`, as is its `kind` |
1552
1552
  | `maxLifetimeMs` | 30 days | the cap `check` gives, through the shared `checkLifetime`; Daytona's TTL is whole minutes and documents no cap of its own |
1553
1553
  | `user` | none | the daemon runs as the provider's `daemonUser`; a spec cannot name a user |
1554
1554
  | `release` | `delete` | `DELETE /sandbox/{id}`; a stop is refused as `unsupported` |
1555
- | `gpu` | `H100`; at most 1 | daytona-gpu's own GPU (`DAYTONA_GPU_SNAPSHOT_GPU`, from GET /snapshots/daytona-gpu). A GPU computer is made from Daytona's GPU snapshot `daytona-gpu` (`DAYTONA_GPU_SNAPSHOT`: its default sandbox image, user `daytona` with passwordless sudo, plus the CUDA toolkit), sent as `snapshot`: its spec's image is `"daytona-gpu"` or `"default"`, and `check` refuses any other (a snapshot of box/Dockerfile among them) in words. A Daytona snapshot carries its own resources, so the create sends none (no `cpu`, `gpu`, `gpuType`, `memory` or `disk`: Daytona refuses them beside a snapshot, 400 "Cannot specify Sandbox resources when using a snapshot"). Another type or count needs a snapshot of its own, so `check` refuses it. A GPU computer's limits, declared on `capabilities().gpu`: `preemptible: true` (daytona.io/pricing lists its GPUs as "Preemptible GPU prices": a run on one can be cut short); `stopDeletes: true` (it is made with `autoDeleteInterval: 0`, whatever `autoDeleteMinutes` says. That is Daytona's ephemeral: its SDK's `ephemeral` sets it, and `CreateSandbox` has no `ephemeral` field, so none is sent. A GPU sandbox has no pause and no snapshot, so stopping it deletes it and nothing on it persists); `region: "earth"` (Daytona's one GPU region, sent as `target` in place of the provider's); `perGpu` 16 vCPU, 100 GiB memory and 400 GiB disk, the snapshot's; `mounts: []`, so a GPU computer with any mount is refused in words: Daytona's GPU host gives no `/dev/fuse`, even to root (live 11-11), and the archil client mounts through FUSE. In serve's Mode 2 the run's folder is an Archil mount, so a Daytona GPU sandbox is refused there, and Settings' `gpu.why` says so. The org needs GPU credits, or the create is refused in Daytona's words. Create notes who installed the daemon: daytona-gpu's `daytona` user through passwordless sudo, or root on a snapshot of box/Dockerfile. The `gpuSnapshot` option names our own GPU snapshot instead: box/Dockerfile as it is, built with one GPU by `box/build-daytona.py --gpu H100` (resources gpu 1 and gpuType H100, named `agentrun-archil-gpu-h100-<recipe hash>`, in region earth). Its user is root, its GPU is the one its name says, and its GPU computers take no mount either. It carries no CUDA toolkit: pip install torch brings its own CUDA runtime; the host gives the driver. A GPU spec's image is then `"default"` or that name. An Archil computer's preflight reads `/dev/fuse`, and one without it is refused in those words ("this computer has no /dev/fuse, so the Archil folder can't be mounted") before anything else |
1555
+ | `gpu` | `H100`; at most 1; none on dial | daytona-gpu's own GPU (`DAYTONA_GPU_SNAPSHOT_GPU`, from GET /snapshots/daytona-gpu). A GPU computer is made from Daytona's GPU snapshot `daytona-gpu` (`DAYTONA_GPU_SNAPSHOT`: its default sandbox image, user `daytona` with passwordless sudo, plus the CUDA toolkit), sent as `snapshot`: its spec's image is `"daytona-gpu"` or `"default"`, and `check` refuses any other (a snapshot of box/Dockerfile among them) in words. A Daytona snapshot carries its own resources, so the create sends none (no `cpu`, `gpu`, `gpuType`, `memory` or `disk`: Daytona refuses them beside a snapshot, 400 "Cannot specify Sandbox resources when using a snapshot"). Another type or count needs a snapshot of its own, so `check` refuses it. A GPU computer's limits, declared on `capabilities().gpu`: `preemptible: true` (daytona.io/pricing lists its GPUs as "Preemptible GPU prices": a run on one can be cut short); `stopDeletes: true` (it is made with `autoDeleteInterval: 0`, whatever `autoDeleteMinutes` says. That is Daytona's ephemeral: its SDK's `ephemeral` sets it, and `CreateSandbox` has no `ephemeral` field, so none is sent. A GPU sandbox has no pause and no snapshot, so stopping it deletes it and nothing on it persists); `region: "earth"` (Daytona's one GPU region, sent as `target` in place of the provider's); `perGpu` 16 vCPU, 100 GiB memory and 400 GiB disk, the snapshot's; `mounts: []`, so a GPU computer with any mount is refused in words: Daytona's GPU host gives no `/dev/fuse`, even to root (live 11-11), and the archil client mounts through FUSE. In serve's Mode 2 the run's folder is an Archil mount, so a Daytona GPU sandbox is refused there, and Settings' `gpu.why` says so. The org needs GPU credits, or the create is refused in Daytona's words. Create notes who installed the daemon: daytona-gpu's `daytona` user through passwordless sudo, or root on a snapshot of box/Dockerfile. The `gpuSnapshot` option names our own GPU snapshot instead: box/Dockerfile as it is, built with one GPU by `box/build-daytona.py --gpu H100` (resources gpu 1 and gpuType H100, named `agentrun-archil-gpu-h100-<recipe hash>`, in region earth). Its user is root, its GPU is the one its name says, and its GPU computers take no mount either. It carries no CUDA toolkit: pip install torch brings its own CUDA runtime; the host gives the driver. A GPU spec's image is then `"default"` or that name. An Archil computer's preflight reads `/dev/fuse`, and one without it is refused in those words ("this computer has no /dev/fuse, so the Archil folder can't be mounted") before anything else |
1556
1556
 
1557
1557
  ### What the provider does
1558
1558
 
@@ -1622,9 +1622,10 @@ The conformance module, `dist/conformance/daytona.js` (`--provider daytona`), re
1622
1622
  when it runs (`settingsFromEnv`) and passes each to `create()` as the option in brackets: `COMPUTER_DAYTONA_API_KEY`
1623
1623
  (`apiKey`, required), `COMPUTER_DAYTONA_API_URL` (`apiUrl`), `COMPUTER_DAYTONA_DAEMON` (`daemonPath`),
1624
1624
  `COMPUTER_DAYTONA_ARCH` (`arch`), `COMPUTER_DAYTONA_TARGET` (`target`), `COMPUTER_DAYTONA_CLASS` (`sandboxClass`),
1625
- `COMPUTER_DAYTONA_USER` (`daemonUser`) and `COMPUTER_DAYTONA_GPU_SNAPSHOT` (`gpuSnapshot`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
1625
+ `COMPUTER_DAYTONA_USER` (`daemonUser`), `COMPUTER_DAYTONA_GPU_SNAPSHOT` (`gpuSnapshot`) and `COMPUTER_DAYTONA_CONNECT`
1626
+ (`connect`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
1626
1627
  daemon of another version with Go), and reads `COMPUTER_DAYTONA_SNAPSHOT` (the run's image; unset, `"default"`,
1627
- Daytona's default snapshot). It never reads `DAYTONA_API_KEY`, `DAYTONA_API_URL` or `DAYTONA_TARGET`, not even as a
1628
+ 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
1628
1629
  fallback: on a host that runs other Daytona work they may hold another organization's key. Those are serve's names,
1629
1630
  which serve passes in itself.
1630
1631
 
@@ -1652,6 +1653,61 @@ node packages/computer/dist/conformance/sweep.js --provider daytona --after /tmp
1652
1653
  It prints `{"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}` (`gone` was `notFound`). A conformance run of
1653
1654
  Daytona also sweeps its own label through the host at its end (the report's `cleanup.sweep`).
1654
1655
 
1656
+ ### Daytona on dial
1657
+
1658
+ With `connect: "dial"` (a server's `daytonaConnect` setting, `COMPUTER_DAYTONA_CONNECT` for conformance; `exec` by
1659
+ default) a Daytona sandbox dials the server instead ([PROVIDERS.md](PROVIDERS.md#machines-that-dial-in)). The host has
1660
+ no exec and no upload, and nothing goes through the toolbox: create sends the boot env as `CreateSandbox.env` and
1661
+ `networkBlockAll: false` (the machine's root reaches the server; network none is init's, inside), and the snapshot's
1662
+ entrypoint runs `agentrun-dial`. No Archil mount, no GPU, and not `image: "default"` (Daytona's default snapshot holds
1663
+ no `agentrun-dial`): `check()` refuses each in words. Labels as on exec. What each part rests on:
1664
+
1665
+ - **A snapshot, never an image.** A create names a snapshot; a snapshot is made from "any publicly accessible image"
1666
+ whose tag is not `latest`, `lts` or `stable` ([docs: create snapshots](https://www.daytona.io/docs/en/snapshots.md#create-snapshots)).
1667
+ The one that holds `agentrun-dial` is the box image's, `agentrun-box-<recipe hash>`: `box/build-daytona.py`
1668
+ builds it from `box/Dockerfile`, or `POST /snapshots` makes it from the published
1669
+ `ghcr.io/parcha-ai/agentrun-box:<recipe hash>` with the same `entrypoint`. The conformance module's run image on
1670
+ dial is that name. A snapshot carries its own resources: a create that names one sends none (400 "Cannot specify
1671
+ Sandbox resources when using a snapshot", live 11-11).
1672
+ - **The boot env reaches `agentrun-dial`.** The runner puts `env` in the container's env
1673
+ ([runner container_configs.go:87](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/runner/pkg/docker/container_configs.go#L87)),
1674
+ and the toolbox's session shell takes the toolbox's env (`cmd.Env = os.Environ()`,
1675
+ [daemon session/create.go:23-24](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/daemon/pkg/session/create.go#L23-L24)).
1676
+ - **The image's CMD never runs; the snapshot's entrypoint does.** The container's entrypoint is the toolbox daemon, and
1677
+ its arguments are the snapshot's entrypoint, else the image's ENTRYPOINT, never its CMD
1678
+ ([runner container_configs.go:143-173](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/runner/pkg/docker/container_configs.go#L143-L173));
1679
+ the daemon runs them as a command of its entrypoint session, and the sandbox stays up when it exits
1680
+ ([daemon main.go:129-164](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/daemon/cmd/daemon/main.go#L129-L164)).
1681
+ A snapshot built from a Dockerfile with no ENTRYPOINT gets `sleep infinity`
1682
+ ([api snapshot.service.ts:883-901](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/api/src/sandbox/services/snapshot.service.ts#L883-L901)),
1683
+ so `box/build-daytona.py` names the Dockerfile's CMD as the snapshot's `entrypoint`. The box snapshots it built
1684
+ before, `agentrun-archil-<recipe hash>`, have none and never dial, so the snapshot it builds now has a name of its
1685
+ own, `agentrun-box-<recipe hash>`, which no snapshot without the entrypoint holds. (The Dockerfile's comment that Daytona runs its
1686
+ CMD is wrong; it stays until the recipe next changes, since editing it changes the hash.)
1687
+ - **Outbound https, by tier.** Tier 1 and 2 organizations reach "essential services" alone, and those leave out shared
1688
+ hosting domains; Tier 3 and 4 have full access
1689
+ ([docs: tier-based network restrictions](https://www.daytona.io/docs/en/network-limits.md#tier-based-network-restrictions)).
1690
+ A server on such a domain (`*.onrender.com`) is out of a Tier 1 or 2 sandbox's reach unless Daytona adds that exact
1691
+ host to the list ([docs: essential services](https://www.daytona.io/docs/en/network-limits.md#essential-services)).
1692
+ **Unverified**: our organization's tier, and a dial from it.
1693
+ - **No GPU on dial**, refused in words: `daytona-gpu` holds no `agentrun-dial`, and Daytona runs a GPU sandbox
1694
+ unprivileged (`Privileged: gpuIndex == nil`,
1695
+ [runner container_configs.go:205](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/runner/pkg/docker/container_configs.go#L205)),
1696
+ where no dial has run. A server whose Daytona connect is exec makes GPU computers. A GPU host still gives no
1697
+ `/dev/fuse` (live 11-11), and the REST API has no `ephemeral` field: a GPU sandbox is made with
1698
+ `autoDeleteInterval: 0` ([Capabilities](#capabilities)).
1699
+ - **The idle timer.** Processes inside a sandbox never reset it, toolbox calls do
1700
+ ([docs: auto-stop interval](https://www.daytona.io/docs/en/sandboxes.md#auto-stop-interval)). On dial no connection is
1701
+ a toolbox call, so with `autoStopMinutes` set a sandbox stops that long after it starts, whatever runs on it; unset
1702
+ (0) it never stops on its own. The conformance module sets 30, so a dial run's computers each live under 30 minutes.
1703
+ - **The token is readable from the API.** `GET /sandbox/{id}` returns `env`
1704
+ ([api sandbox.dto.ts:84](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/api/src/sandbox/dto/sandbox.dto.ts#L84)),
1705
+ so whoever holds the API key reads the machine's token; that key already runs root in the sandbox through the
1706
+ toolbox. The token is the machine's alone, and revoked at its delete.
1707
+ - **Unverified**: whether a box-image sandbox has a D-Bus session bus in `/tmp` (on exec, create closes `/tmp/dbus-*`
1708
+ to the computer's user through the toolbox; on dial there is no exec, so nothing does), and the `linux-vm` class on
1709
+ dial.
1710
+
1655
1711
  ### Not yet known
1656
1712
 
1657
1713
  Four live runs reached the default snapshot. The first failed at the start, in the privilege tool init's own drop now
@@ -4,15 +4,23 @@
4
4
  # starts from it (on Daytona's hosted cloud Archil's client hangs, so no computer there takes the mount). The name is
5
5
  # the recipe's hash (the Dockerfile and the files it copies, install.sh among them), so a changed recipe is
6
6
  # a new snapshot, and the same recipe is the one built before: Daytona then refuses the name, and the printed name is
7
- # the one to use. Its size is 2 CPUs, 4 GB of memory and a 10 GB disk.
7
+ # the one to use. Its name is agentrun-box-<the recipe's hash>, and its size is 2 CPUs, 4 GB of memory and a 10 GB disk.
8
8
  #
9
9
  # With --gpu H100, the same image as a GPU snapshot: a snapshot carries its own resources, the GPU among them, so its
10
10
  # sandboxes have one H100 (and daytona-gpu's 16 CPUs, 100 GB of memory and a 400 GB disk), in region earth, Daytona's
11
11
  # GPU region. Its name is agentrun-archil-gpu-h100-<the recipe's hash>: the provider's gpuSnapshot option takes it, and
12
12
  # reads the GPU from it. Another type is another snapshot.
13
13
  #
14
+ # The snapshot's entrypoint is the Dockerfile's CMD, named: Daytona's toolbox runs a snapshot's entrypoint as its first
15
+ # command, and a snapshot built from a Dockerfile with no ENTRYPOINT gets `sleep infinity` instead, never the CMD
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.
20
+ #
14
21
  # python3 packages/computer/box/build-daytona.py [--gpu H100]
15
22
  import hashlib
23
+ import json
16
24
  import os
17
25
  import sys
18
26
 
@@ -30,12 +38,14 @@ if args:
30
38
  here = os.path.dirname(os.path.abspath(__file__))
31
39
  recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "install.sh", "agentrun-archil"))
32
40
  digest = hashlib.sha256(recipe).hexdigest()[:12]
33
- name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-archil-{digest}"
41
+ name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-box-{digest}"
42
+ cmd = [json.loads(line[4:]) for line in open(os.path.join(here, "Dockerfile")).read().splitlines() if line.startswith("CMD ")][-1]
34
43
  print(f"build-daytona: snapshot {name}", file=sys.stderr)
35
44
  Daytona().snapshot.create(
36
45
  CreateSnapshotParams(
37
46
  name=name,
38
47
  image=Image.from_dockerfile(os.path.join(here, "Dockerfile")),
48
+ entrypoint=cmd,
39
49
  resources=Resources(cpu=16, memory=100, disk=400, gpu=1, gpu_type=GPUS[gpu]) if gpu else Resources(cpu=2, memory=4, disk=10),
40
50
  **({"region_id": "earth"} if gpu else {}),
41
51
  ),
package/box/recipe.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // The box image's recipe: the files it is made of (this folder's Dockerfile and what it copies: install.sh, the build,
2
2
  // and the helper) and their hash, the first 12 hex of their sha256. Every build names what it makes by that hash, so a
3
3
  // changed recipe is a new image and the same recipe is the one built before: the E2B template agentrun-archil-<hash>
4
- // (build-e2b.mjs), the Daytona snapshot of the same name (build-daytona.py hashes the same files), the published image
4
+ // (build-e2b.mjs), the Daytona snapshot agentrun-box-<hash> (build-daytona.py hashes the same files), the published image
5
5
  // ghcr.io/parcha-ai/agentrun-box:<hash> (release.yml's box job reads recipeHash()), and what a provider's prepareImage
6
6
  // builds or registers in a vendor's account.
7
7
  //
@@ -119,8 +119,10 @@ class CloudflareHost {
119
119
  // check() refused a size past the largest, so one instance holds it.
120
120
  const instance = instanceOf(req.cpus, req.memoryMb) ?? LARGEST;
121
121
  const body = { name: nameOf(req.name), image: req.image, env: req.boot.env, labels: req.labels, instance: instance.name, backstopAt: req.backstopAt };
122
- // Only a 429, a refusal that made nothing, is sent again: a create that got no answer may have made a container.
123
- const made = (await this.#call("POST", "/v1/computers", { json: body, named: true, retry: (status) => status === 429 }, ctx));
122
+ // A 429 made nothing. A 500, 502 or 503 may have made the container, and sending it again is still safe: the relay's
123
+ // Computer object of this name answers a second create with the first's row and starts nothing twice. A create that
124
+ // got no answer is not sent again: the adapter deletes the name it asked for.
125
+ const made = (await this.#call("POST", "/v1/computers", { json: body, named: true, retry: (status) => [429, 500, 502, 503].includes(status) }, ctx));
124
126
  if (made?.name !== req.name)
125
127
  throw new HostError("vendor", `POST /v1/computers answered another computer: ${show(made?.name)}`);
126
128
  return { id: made.name };
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.0-beta.42",
3
- "source": "sha256:8969b1d46b7c70a2e5010f2913157491a58ee403cccc3d31cd70f73bf3524a6c"
2
+ "version": "0.1.0-beta.44",
3
+ "source": "sha256:8f902d5ec002eb42b17e1af0bac3976c24b218f12e0fab54a49315bbabca81a9"
4
4
  }
@@ -65,6 +65,10 @@ export async function assertIsolated(t, client) {
65
65
  }
66
66
  const found = search.sockets.map((one) => ({ path: String(one.path), type: String(one.type) }));
67
67
  t.observe(`unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
68
+ // Folders of a filesystem no socket can be a file of (proc, sysfs a runtime mounted inside a searched root) are not
69
+ // gone into; they take nothing from the proof, and are said so a run shows them.
70
+ if (Array.isArray(search.skipped) && search.skipped.length > 0)
71
+ t.observe(`not searched, no socket can be a file there: ${search.skipped.map(String).join(", ")}`);
68
72
  const incomplete = search.incomplete.map(String);
69
73
  t.assert(incomplete.length === 0, `the probe could not search every place a socket may be, so the socket fence is unproven: ${incomplete.join("; ")}`);
70
74
  // A desktop's tools draw on its display: the X server of the display its hello names, on its path and on the same
@@ -30,6 +30,8 @@ export declare const DAYTONA_ENV: {
30
30
  * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
31
31
  */
32
32
  readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
33
+ /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
34
+ readonly connect: "COMPUTER_DAYTONA_CONNECT";
33
35
  };
34
36
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
35
37
  export declare const ENV: {
@@ -56,6 +58,8 @@ export declare const ENV: {
56
58
  * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
57
59
  */
58
60
  readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
61
+ /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
62
+ readonly connect: "COMPUTER_DAYTONA_CONNECT";
59
63
  };
60
64
  /**
61
65
  * The provider's options this module reads from env, each only when its name is set; throws in words without the key,
@@ -77,9 +81,19 @@ export interface DaytonaModuleOptions {
77
81
  timeouts?: DaytonaProviderOptions["timeouts"];
78
82
  /** What the provider says that is no failure: the CLI gives it and puts it in the report. */
79
83
  onNote?: DaytonaProviderOptions["onNote"];
84
+ /** The public server a dial machine dials (COMPUTER_DAYTONA_CONNECT=dial): its process alone gives it (dialKit). */
85
+ dial?: DaytonaProviderOptions["dial"];
86
+ /** The daemon binary, over COMPUTER_DAYTONA_DAEMON: dial-conformance.mjs gives drift.version's daemon here. */
87
+ daemonPath?: DaytonaProviderOptions["daemonPath"];
80
88
  }
81
- /** The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT, or Daytona's default snapshot. */
89
+ /**
90
+ * The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT; else on dial the box image's snapshot,
91
+ * agentrun-box-<recipe hash> (box/build-daytona.py), since only it holds agentrun-dial and runs it; else Daytona's default
92
+ * snapshot.
93
+ */
82
94
  export declare function conformanceImage({ env }?: Pick<DaytonaModuleOptions, "env">): string;
95
+ /** A dial machine (COMPUTER_DAYTONA_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
96
+ export declare const dialKit: () => import("./types.js").DialKit;
83
97
  /**
84
98
  * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
85
99
  * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
@@ -6,9 +6,11 @@
6
6
  // (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing. The mount cases run on a
7
7
  // self-hosted Daytona target alone: COMPUTER_DAYTONA_ARCHIL_EGRESS names its Archil egress relay, and the
8
8
  // COMPUTER_ARCHIL_* settings the disk (mountFor).
9
+ import { boxRecipeHash } from "../box-image.js";
9
10
  import { create } from "../daytona.js";
10
11
  import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
11
12
  import { archilRunFolder, archilSettings } from "./archil.js";
13
+ import { dialOnlyFromServer } from "./dial-only.js";
12
14
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
13
15
  /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
14
16
  export { ARCHIL_ENV } from "./archil.js";
@@ -37,6 +39,8 @@ export const DAYTONA_ENV = {
37
39
  * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
38
40
  */
39
41
  archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS",
42
+ /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
43
+ connect: "COMPUTER_DAYTONA_CONNECT",
40
44
  };
41
45
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
42
46
  export const ENV = DAYTONA_ENV;
@@ -57,6 +61,7 @@ export function settingsFromEnv(env = process.env) {
57
61
  const user = named(DAYTONA_ENV.user);
58
62
  const gpuSnapshot = named(DAYTONA_ENV.gpuSnapshot);
59
63
  const archilEgress = named(DAYTONA_ENV.archilEgress);
64
+ const connect = named(DAYTONA_ENV.connect);
60
65
  return {
61
66
  apiKey,
62
67
  ...(url ? { apiUrl: url.value } : {}),
@@ -71,6 +76,8 @@ export function settingsFromEnv(env = process.env) {
71
76
  ...(gpuSnapshot ? { gpuSnapshot: gpuSnapshot.value } : {}),
72
77
  // create() refuses one of another shape in words.
73
78
  ...(archilEgress ? { archilEgress: archilEgress.value } : {}),
79
+ // create() refuses any other value in words.
80
+ ...(connect ? { connect: connect.value } : {}),
74
81
  };
75
82
  }
76
83
  /** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
@@ -79,24 +86,32 @@ export const CONFORMANCE_AUTO_STOP_MINUTES = 30;
79
86
  export const CONFORMANCE_AUTO_DELETE_MINUTES = 0;
80
87
  /** For the run's report: what this configuration means for the suite, in words. */
81
88
  export const conformanceNotes = [
82
- `daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer. A computer here is deleted, never stopped: release stop is refused. Full provider.janitor, which needs a stopped computer kept, is skipped (the lifetime being vendor).`,
89
+ `daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer. A computer here is deleted, never stopped: release stop is refused. Full provider.janitor, which needs a stopped computer kept, is skipped (the lifetime being vendor). On dial (${DAYTONA_ENV.connect}=dial) no connection is a toolbox call, so nothing resets Daytona's idle timer: a computer stops, and is deleted, ${CONFORMANCE_AUTO_STOP_MINUTES} minutes after it starts, whatever runs on it.`,
83
90
  ];
84
91
  /** The provider's options: what this module reads from the environment (settingsFromEnv), with the run's bounds. */
85
- function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote }) {
92
+ function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote, dial, daemonPath }) {
86
93
  return {
87
94
  ...settingsFromEnv(env),
95
+ ...(daemonPath === undefined ? {} : { daemonPath }),
88
96
  autoStopMinutes: CONFORMANCE_AUTO_STOP_MINUTES,
89
97
  autoDeleteMinutes: CONFORMANCE_AUTO_DELETE_MINUTES,
90
98
  ...(fetch ? { fetch } : {}),
91
99
  ...(webSocket ? { webSocket } : {}),
92
100
  ...(timeouts ? { timeouts } : {}),
93
101
  ...(onNote ? { onNote } : {}),
102
+ ...(dial ? { dial } : {}),
94
103
  };
95
104
  }
96
- /** The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT, or Daytona's default snapshot. */
105
+ /**
106
+ * The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT; else on dial the box image's snapshot,
107
+ * agentrun-box-<recipe hash> (box/build-daytona.py), since only it holds agentrun-dial and runs it; else Daytona's default
108
+ * snapshot.
109
+ */
97
110
  export function conformanceImage({ env = process.env } = {}) {
98
- return env[DAYTONA_ENV.snapshot] || DAYTONA_DEFAULT_SNAPSHOT;
111
+ return env[DAYTONA_ENV.snapshot] || (env[DAYTONA_ENV.connect] === "dial" ? `agentrun-box-${boxRecipeHash()}` : DAYTONA_DEFAULT_SNAPSHOT);
99
112
  }
113
+ /** A dial machine (COMPUTER_DAYTONA_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
114
+ export const dialKit = dialOnlyFromServer("daytona", "Daytona", `${DAYTONA_ENV.connect}=dial`);
100
115
  /**
101
116
  * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
102
117
  * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
package/dist/daytona.d.ts CHANGED
@@ -53,6 +53,12 @@ export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "de
53
53
  * (-1 is sent) and the TTL ends it.
54
54
  */
55
55
  autoDeleteMinutes?: number;
56
+ /**
57
+ * exec (default): the daemon goes in through the toolbox's file API and each connection is a session command. dial:
58
+ * the sandbox gets the boot env as its env, and its snapshot's entrypoint, the box image's CMD, runs agentrun-dial; the
59
+ * machine dials the server (options.dial), which every connection goes over. No Archil mount and no GPU on dial.
60
+ */
61
+ connect?: "exec" | "dial";
56
62
  /** For tests: every request goes through it. Default the global fetch. */
57
63
  fetch?: typeof fetch;
58
64
  /** For tests: every log stream opens through it. Default Node's global WebSocket. */
package/dist/daytona.js CHANGED
@@ -1,11 +1,14 @@
1
1
  // The Daytona host: Daytona sandboxes over Daytona's v0 REST API with fetch (no SDK). Daytona's toolbox daemon is the
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
- // the command's log stream and its stdin sent as the command's input. The rest of the computer is the shared
5
- // machine-host adapter's (./hosted/provider.ts). Every Daytona fact used here is cited in the README's Daytona section.
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.
6
9
  import { randomBytes } from "node:crypto";
7
10
  import { mountsOf } from "./descriptor.js";
8
- import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, daytonaGpuSnapshot } from "./descriptors/daytona.js";
11
+ import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
9
12
  import { COMPUTER_LABEL } from "./drift.js";
10
13
  import { HostError } from "./host.js";
11
14
  import { framedExec } from "./hosted/framed-exec.js";
@@ -13,7 +16,7 @@ import { HostedProvider, timeoutsOf } from "./hosted/provider.js";
13
16
  import { boundOf, orThrow, pause as sleep } from "./hosted/process.js";
14
17
  import { allPages, jsonOf, rest } from "./hosted/rest.js";
15
18
  import { shellLine } from "./hosted/scripts.js";
16
- import { dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
19
+ import { connectOf, dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
17
20
  import { MAX_LINE_BYTES } from "./protocol.js";
18
21
  import { checkGpu } from "./provider.js";
19
22
  import { ok, vendorFail } from "./result.js";
@@ -48,6 +51,14 @@ const ERR = Buffer.from([2, 2, 2]);
48
51
  /** A line the client wrote, echoed back: a request or a notification is never a daemon's reply. */
49
52
  const ECHO = /^\{"jsonrpc":"2\.0",("id":\d+,)?"method":/;
50
53
  const decoder = new TextDecoder();
54
+ /**
55
+ * Why a dial computer takes no GPU: check() refuses one in these words, and capabilities() declares none on dial.
56
+ * daytona-gpu is Daytona's own image, with no agentrun-dial; our GPU snapshot holds it, but Daytona runs a GPU sandbox
57
+ * unprivileged (apps/runner/pkg/docker/container_configs.go:205), and no dial has run there.
58
+ */
59
+ const DIAL_NO_GPU = `a Daytona computer that dials this server takes no GPU: ${DAYTONA_GPU_SNAPSHOT} holds no agentrun-dial, and a box/Dockerfile GPU snapshot's dial on Daytona's GPU host, which runs it unprivileged, is not proven; a server whose Daytona connect is exec makes GPU computers`;
60
+ /** Why a dial computer is never made from Daytona's default snapshot: it holds no agentrun-dial, so it would never dial. */
61
+ const DIAL_NO_DEFAULT = `a Daytona computer that dials this server starts from a snapshot of box/Dockerfile, which holds agentrun-dial (box/build-daytona.py prints its name, agentrun-box-<recipe hash>); Daytona's default snapshot has none, so it would never dial`;
51
62
  /**
52
63
  * A sandbox's state as the adapter reads a machine's: failed, destroying and asked to destroy are gone (none of them
53
64
  * starts again); stopping and pausing are stopped. A destroyed one get and list leave out, and the wait after a delete
@@ -93,6 +104,9 @@ class DaytonaHost {
93
104
  */
94
105
  descriptor = DAYTONA;
95
106
  facts;
107
+ /** connect exec alone: a dial host has neither (HostFacts.connect). */
108
+ exec;
109
+ upload;
96
110
  /** Daytona's REST API: the control plane, and the toolbox of each sandbox. */
97
111
  #rest;
98
112
  #headers;
@@ -119,7 +133,8 @@ class DaytonaHost {
119
133
  // maxLifetimeMs is the 30 days check() has always given; Daytona's TTL is in whole minutes and documents no cap of
120
134
  // its own. The toolbox listens on 2280 on every interface and runs commands for whoever reaches it, so init starts
121
135
  // with --own-network, and network none is all a computer takes. Its D-Bus session bus in /tmp (/tmp/dbus-*), which
122
- // no network namespace cuts, is closed to the tool user before init starts, as on every child host.
136
+ // no network namespace cuts, is closed to the tool user before init starts, as on every child host. On dial init is
137
+ // agentrun-dial's child, and agentrun-dial the entrypoint the toolbox runs in a session of its own: still a child.
123
138
  this.facts = {
124
139
  daemon: "child",
125
140
  isolation: options.sandboxClass === "linux-vm" ? "vm" : "container",
@@ -127,7 +142,12 @@ class DaytonaHost {
127
142
  maxLifetimeMs: MAX_LIFETIME_MS,
128
143
  arch: options.arch,
129
144
  vendorAgentPorts: [TOOLBOX_PORT],
145
+ ...(options.connect === "dial" ? { connect: options.connect } : {}),
130
146
  };
147
+ if (options.connect === "exec") {
148
+ this.exec = (id, argv, ctx) => this.#exec(id, argv, ctx);
149
+ this.upload = (id, path, bytes, ctx) => this.#upload(id, path, bytes, ctx);
150
+ }
131
151
  }
132
152
  /**
133
153
  * A snapshot name has no control characters, and its size is the snapshot's; a GPU computer is made from the
@@ -140,6 +160,10 @@ class DaytonaHost {
140
160
  refusals.push({ field: "image", message: `an image is the id or name of a Daytona snapshot, or "${DAYTONA_DEFAULT_SNAPSHOT}" for Daytona's default snapshot` });
141
161
  else if (typeof image === "string" && /[\x01-\x1f]/.test(image))
142
162
  refusals.push({ field: "image", message: "a snapshot name has no control characters" });
163
+ if (given.gpu !== undefined && this.facts.connect === "dial")
164
+ return [...refusals, { field: "gpu", message: DIAL_NO_GPU }];
165
+ if (image === DAYTONA_DEFAULT_SNAPSHOT && this.facts.connect === "dial")
166
+ refusals.push({ field: "image", message: DIAL_NO_DEFAULT });
143
167
  const gpuSnapshot = this.#gpu.snapshot;
144
168
  const offered = { gpu: { ...DAYTONA_GPU, types: [this.#gpu.type], max: this.#gpu.count } };
145
169
  if (given.gpu !== undefined && checkGpu(given.gpu, offered, given.mount).length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== gpuSnapshot) {
@@ -170,7 +194,8 @@ class DaytonaHost {
170
194
  * computer's root, which reaches Archil through the operator's relay). A GPU computer is made from the GPU snapshot in region earth, ephemeral (its stop deletes it). Never cancelled: the adapter
171
195
  * races it, and deletes by name one whose answer never comes. A name Daytona already holds (409) made nothing: exists,
172
196
  * and the adapter adopts the sandbox the name lists, as a retry does. req.backstopAt is left: the TTL is Daytona's own
173
- * timer at the deadline (lifetime "vendor"), and autoDeleteInterval counts from a stop, not from create.
197
+ * timer at the deadline (lifetime "vendor"), and autoDeleteInterval counts from a stop, not from create. A dial
198
+ * machine's boot env is the sandbox's env, which the toolbox's entrypoint session inherits (README, Daytona on dial).
174
199
  */
175
200
  async create(req, ctx) {
176
201
  const gpu = req.gpu !== undefined;
@@ -179,7 +204,7 @@ class DaytonaHost {
179
204
  // "default" sends no snapshot, and Daytona makes the sandbox from its default snapshot.
180
205
  ...(gpu ? { snapshot: this.#gpu.snapshot } : req.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: req.image }),
181
206
  labels: { ...req.labels },
182
- env: {},
207
+ env: { ...req.boot?.env },
183
208
  public: false,
184
209
  // A GPU sandbox runs in region earth alone, whatever the provider's target.
185
210
  ...(gpu ? { target: DAYTONA_GPU_REGION } : this.#target === undefined ? {} : { target: this.#target }),
@@ -284,9 +309,9 @@ class DaytonaHost {
284
309
  * A file's bytes to `path` in the sandbox: files/upload-v2, else files/upload. An older toolbox, as a self-hosted
285
310
  * Daytona's runners may run (the open daemon's routes, daytonaio/daytona@b5a5d9e7 apps/daemon/pkg/toolbox/server.go),
286
311
  * has no files/upload-v2 and answers it 404; its files/upload takes the same form (a path query, the bytes as
287
- * "file"). A 404 alone moves to the older route, so a refusal of any other kind is never sent twice.
312
+ * "file"). A 404 alone moves to the older route, so a refusal of any other kind is never sent twice. Connect exec alone.
288
313
  */
289
- async upload(id, path, bytes, ctx) {
314
+ async #upload(id, path, bytes, ctx) {
290
315
  const toolbox = await this.#toolbox(id, ctx.signal);
291
316
  const query = new URLSearchParams({ path });
292
317
  const send = (route, answerStatus) => {
@@ -304,9 +329,9 @@ class DaytonaHost {
304
329
  }
305
330
  /**
306
331
  * A session command of its own (#commands), on framedExec: argv as one shell line, run async with no input echo, as
307
- * the toolbox's user (root, or one with passwordless sudo, which the adapter's scripts use).
332
+ * the toolbox's user (root, or one with passwordless sudo, which the adapter's scripts use). Connect exec alone.
308
333
  */
309
- async exec(id, argv, ctx) {
334
+ async #exec(id, argv, ctx) {
310
335
  return framedExec(this.#commands(await this.#toolbox(id, ctx.signal)), argv, ctx);
311
336
  }
312
337
  /**
@@ -486,7 +511,8 @@ class DaytonaHost {
486
511
  */
487
512
  export class DaytonaProvider extends HostedProvider {
488
513
  constructor(options) {
489
- const { apiKey, apiUrl = DEFAULT_API_URL, arch = "amd64", sandboxClass = "container", target, gpuSnapshot, autoStopMinutes = 0, autoDeleteMinutes, fetch: fetcher, webSocket, pause, timeouts = {}, ...hosted } = options ?? {};
514
+ const { apiKey, apiUrl = DEFAULT_API_URL, arch = "amd64", sandboxClass = "container", target, gpuSnapshot, autoStopMinutes = 0, autoDeleteMinutes, connect, fetch: fetcher, webSocket, pause, timeouts = {}, ...hosted } = options ?? {};
515
+ const via = connectOf(connect, "Daytona");
490
516
  if (typeof apiKey !== "string" || apiKey === "")
491
517
  throw new Error("options.apiKey, the Daytona API key, is required: the provider reads no environment, so the caller passes it");
492
518
  const base = new URL(apiUrl);
@@ -515,7 +541,8 @@ export class DaytonaProvider extends HostedProvider {
515
541
  return typeof value === "string" && value !== "";
516
542
  };
517
543
  const host = new DaytonaHost({
518
- descriptor: { ...DAYTONA, ...mountsOf(DAYTONA, set) },
544
+ // On dial its capabilities declare no GPU (DIAL_NO_GPU).
545
+ descriptor: { ...DAYTONA, ...mountsOf(DAYTONA, set), ...(via === "dial" ? { capabilities: DAYTONA.capabilities.map(({ gpu: _gpu, ...rest }) => rest) } : {}) },
519
546
  rest: rest({ base: apiUrl, headers: () => headers, vendor: "daytona", fetch: fetcher ?? fetch, timeoutMs: requestMs, retry: { attempts: RETRY_ATTEMPTS, baseMs: retryMs, ...(pause ? { pause } : {}) }, explain }),
520
547
  headers,
521
548
  webSocket: webSocket ?? ((url, init) => new WebSocket(url, init)),
@@ -526,6 +553,7 @@ export class DaytonaProvider extends HostedProvider {
526
553
  autoStop: autoStopMinutes,
527
554
  autoDelete: autoDeleteMinutes ?? NO_AUTO_DELETE,
528
555
  pollMs,
556
+ connect: via,
529
557
  });
530
558
  super(host, { ...hosted, kind: "linux", timeouts: hostedTimeouts });
531
559
  }
@@ -65,6 +65,10 @@ export declare const DAYTONA: {
65
65
  readonly option: "archilEgress";
66
66
  readonly required: false;
67
67
  }];
68
+ readonly settings: readonly [{
69
+ readonly name: "daytonaConnect";
70
+ readonly option: "connect";
71
+ }];
68
72
  readonly metered: true;
69
73
  readonly mounts: readonly [];
70
74
  readonly unmounted: {
@@ -72,6 +72,9 @@ export const DAYTONA = defineProvider({
72
72
  { name: "DAYTONA_TARGET", option: "target", required: false },
73
73
  { name: DAYTONA_ARCHIL_EGRESS, option: "archilEgress", required: false },
74
74
  ],
75
+ // How the server reaches its machines: exec (the provider's default, when the server's settings name none), a session
76
+ // command through the toolbox per connection, or dial, the machine dials the server (a snapshot of box/Dockerfile).
77
+ settings: [{ name: "daytonaConnect", option: "connect" }],
75
78
  metered: true,
76
79
  // No mount by default: on Daytona's hosted cloud, Archil's client (0.10.1) mounts on its container sandboxes, but
77
80
  // nothing reads its /dev/fuse after, so the first statx of the folder hangs, on every kernel and mount shape tried
@@ -55,6 +55,10 @@ export declare const DESCRIPTORS: readonly [{
55
55
  readonly option: "archilEgress";
56
56
  readonly required: false;
57
57
  }];
58
+ readonly settings: readonly [{
59
+ readonly name: "daytonaConnect";
60
+ readonly option: "connect";
61
+ }];
58
62
  readonly metered: true;
59
63
  readonly mounts: readonly [];
60
64
  readonly unmounted: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-computer",
3
- "version": "0.1.0-beta.42",
3
+ "version": "0.1.0-beta.44",
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",