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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +39 -9
  2. package/box/Dockerfile +2 -1
  3. package/box/install.sh +19 -5
  4. package/dist/attach.d.ts +13 -3
  5. package/dist/attach.js +182 -15
  6. package/dist/cloudflare.d.ts +4 -2
  7. package/dist/cloudflare.js +7 -3
  8. package/dist/computerd-linux-amd64 +0 -0
  9. package/dist/computerd-linux-arm64 +0 -0
  10. package/dist/computerd.json +2 -2
  11. package/dist/conformance/cases/files.js +7 -1
  12. package/dist/conformance/cases/mount.js +155 -2
  13. package/dist/conformance/cases/provider.js +3 -1
  14. package/dist/conformance/types.d.ts +1 -1
  15. package/dist/daytona.d.ts +5 -2
  16. package/dist/daytona.js +8 -4
  17. package/dist/descriptor.d.ts +34 -4
  18. package/dist/descriptor.js +40 -6
  19. package/dist/descriptors/cloudflare.d.ts +14 -1
  20. package/dist/descriptors/cloudflare.js +7 -3
  21. package/dist/descriptors/daytona.d.ts +17 -3
  22. package/dist/descriptors/daytona.js +12 -8
  23. package/dist/descriptors/e2b.d.ts +1 -0
  24. package/dist/descriptors/e2b.js +2 -1
  25. package/dist/descriptors/fly.d.ts +14 -1
  26. package/dist/descriptors/fly.js +6 -3
  27. package/dist/descriptors/index.d.ts +60 -2
  28. package/dist/descriptors/modal.d.ts +16 -2
  29. package/dist/descriptors/modal.js +10 -6
  30. package/dist/descriptors/orgo.d.ts +3 -0
  31. package/dist/descriptors/orgo.js +3 -1
  32. package/dist/e2b.d.ts +9 -4
  33. package/dist/e2b.js +8 -8
  34. package/dist/env-proxy.d.ts +26 -0
  35. package/dist/env-proxy.js +97 -0
  36. package/dist/fly.d.ts +4 -3
  37. package/dist/fly.js +7 -4
  38. package/dist/hosted/provider.d.ts +2 -1
  39. package/dist/hosted/provider.js +133 -54
  40. package/dist/hosted/scripts.d.ts +3 -2
  41. package/dist/hosted/scripts.js +12 -7
  42. package/dist/hosted/values.d.ts +2 -5
  43. package/dist/hosted/values.js +2 -9
  44. package/dist/index.d.ts +4 -2
  45. package/dist/index.js +4 -2
  46. package/dist/kinds.d.ts +4 -2
  47. package/dist/kinds.js +10 -1
  48. package/dist/modal.d.ts +5 -2
  49. package/dist/modal.js +8 -2
  50. package/dist/morph.js +15 -7
  51. package/dist/mount-archil.d.ts +33 -17
  52. package/dist/mount-archil.js +83 -36
  53. package/dist/mount.d.ts +16 -7
  54. package/dist/mount.js +13 -8
  55. package/dist/orgo.js +1 -1
  56. package/dist/provider.d.ts +1 -1
  57. package/dist/sync-folder.d.ts +82 -0
  58. package/dist/sync-folder.js +494 -0
  59. package/dist/tar.d.ts +34 -0
  60. package/dist/tar.js +203 -0
  61. package/package.json +1 -1
  62. package/dist/conformance/tar.d.ts +0 -13
  63. package/dist/conformance/tar.js +0 -105
@@ -10,10 +10,21 @@
10
10
  // disk once the computer lets the folder go; a new claim takes the folder from a lower epoch, whose computer is gone;
11
11
  // the token is nowhere a tool can read it; and, on one computer, a tool reaches no network while its writes reach the
12
12
  // disk as each call returns.
13
+ //
14
+ // A synced folder has no disk of the provider's: the runner holds the copy (a SyncSink), pushes it in at the claim and
15
+ // lands each call's delta on it before the call answers (FolderSync under syncingClient). Its cases hold that copy in
16
+ // memory, as a runner would hold it, and check what the provider's computer gives the runner: a push restores modes and
17
+ // links, a change is on the copy before the call that made it answers, a delete reaches it, and a folder past a cap
18
+ // fails the call in words.
13
19
  import { randomBytes } from "node:crypto";
20
+ import { pushTar } from "../../files.js";
14
21
  import { EPOCH_LABEL, RUN_LABEL, runLabels as claimLabels } from "../../labels.js";
15
22
  import { MOUNT_KINDS, readBackOf, WORKSPACE } from "../../mount.js";
16
- import { MAX_OUTPUT_BYTES } from "../../protocol.js";
23
+ import { syncingClient } from "../../mount-archil.js";
24
+ import { MAX_LIST_DEPTH, MAX_OUTPUT_BYTES } from "../../protocol.js";
25
+ import { ok } from "../../result.js";
26
+ import { FolderSync, SYNC_MAX_ENTRIES } from "../../sync-folder.js";
27
+ import { tarStream } from "../../tar.js";
17
28
  import { assertIsolated, assertRootRunsClosed } from "./isolation.js";
18
29
  import { b64, CASE_LABEL, decode } from "./util.js";
19
30
  /** The claim epoch the run-folder cases make their computers under. */
@@ -64,7 +75,8 @@ export async function mounted(t, folder, epoch, name, extra = {}) {
64
75
  return { ref, labels };
65
76
  }
66
77
  const text = (bytes) => (bytes === undefined ? undefined : Buffer.from(bytes).toString("utf8"));
67
- /** "mounts the run's folder" for one kind: on a computer of its own, made with a fresh run folder from the run. */
78
+ /** "mounts the run's folder" for one kind: on a computer of its own, made with a fresh run folder from the run. A synced
79
+ * folder's cases are the sync-* ones, below. */
68
80
  const runFolder = (kind) => mount(`run-folder-${kind}`, async (t) => {
69
81
  const folder = await t.runFolder(kind);
70
82
  const asked = folder.mount;
@@ -219,8 +231,145 @@ const archilLoopToolEdit = mount("archil-loop-tool-edit", async (t) => {
219
231
  t.ok(await t.provider.release(ref, "delete"), `release of ${ref.name}`);
220
232
  t.equal(text(await folder.read(name)), want, `${name}: the loop's text with the tool's line, read through the file API once the computer is released`);
221
233
  }, { needs: ["mount:archil", "exec", "files"], timeoutMs: 600_000 });
234
+ /** The runner's copy of a synced folder, in memory: its files, its empty directories, its modes and links, and each
235
+ * write in order ("put a", "remove a", ...). */
236
+ class CopySink {
237
+ files = new Map();
238
+ dirs = new Set();
239
+ kept = { modes: {}, links: {} };
240
+ writes = [];
241
+ async put(path, body) {
242
+ this.writes.push(`put ${path}`);
243
+ this.files.set(path, body);
244
+ return ok(undefined);
245
+ }
246
+ async mkdir(path) {
247
+ this.writes.push(`mkdir ${path}`);
248
+ this.dirs.add(path);
249
+ return ok(undefined);
250
+ }
251
+ async remove(path, type) {
252
+ this.writes.push(`remove ${path}`);
253
+ if (type === "file")
254
+ this.files.delete(path);
255
+ else
256
+ this.dirs.delete(path);
257
+ return ok(undefined);
258
+ }
259
+ async meta(meta) {
260
+ this.writes.push("meta");
261
+ this.kept = meta;
262
+ return ok(undefined);
263
+ }
264
+ }
265
+ /**
266
+ * A computer made with a synced folder, its copy `entries` held by the runner and pushed into /workspace as one tar
267
+ * (none: an empty folder), the computer's listing read as the manifest, and its client under syncingClient, as a runner
268
+ * hands it to the tools: each call that may change the folder answers once its delta is on the copy.
269
+ */
270
+ async function synced(t, name, entries = []) {
271
+ const copy = new CopySink();
272
+ for (const entry of entries) {
273
+ if (entry.type === "file")
274
+ copy.files.set(entry.name, entry.body ?? new Uint8Array());
275
+ else if (entry.type === "dir" && !entries.some((other) => other.name.startsWith(`${entry.name}/`)))
276
+ copy.dirs.add(entry.name);
277
+ }
278
+ const kept = {
279
+ mount: { kind: "sync" },
280
+ read: async (path) => copy.files.get(path),
281
+ write: async (path, data) => void copy.files.set(path, data),
282
+ close: async () => { },
283
+ };
284
+ const { ref } = await mounted(t, kept, EPOCH, name);
285
+ const connected = await t.connect(ref);
286
+ if (entries.length > 0)
287
+ t.ok(await pushTar(connected.client, WORKSPACE, tarStream(entries)), `tar.push of the run's folder into ${WORKSPACE}`);
288
+ const folder = new FolderSync(connected.client, copy);
289
+ t.ok(await folder.baseline(), `files.list of ${WORKSPACE} pushed in, as the manifest`);
290
+ const client = syncingClient(connected.client, async () => {
291
+ const done = await folder.sync();
292
+ return done.ok ? ok(undefined) : done;
293
+ });
294
+ return { copy, client, own: connected.client, folder };
295
+ }
296
+ /** /workspace as files.list gives it, by path relative to it. */
297
+ async function listed(t, client) {
298
+ const page = await t.call("files.list", { path: WORKSPACE, depth: MAX_LIST_DEPTH }, client);
299
+ return new Map(page.entries.map((entry) => [entry.path.slice(WORKSPACE.length + 1), entry]));
300
+ }
301
+ const SYNC_NEEDS = ["mount:sync", "exec", "files"];
302
+ /** "on the copy before the answer": a program's write, a files.write and a new tree land before their call answers. */
303
+ const syncDurable = mount("sync-durable", async (t) => {
304
+ const { copy, client } = await synced(t, "mount-sync-durable");
305
+ const nonce = randomBytes(6).toString("hex");
306
+ const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, client);
307
+ t.equal(ran.exitCode, 0, `a program's write at ${WORKSPACE}: its exit code (${ran.err.trim()})`);
308
+ t.equal(text(copy.files.get(`exec-${nonce}.txt`)), `${nonce}\n`, `exec-${nonce}.txt, written by a program, on the runner's copy when exec.run answered`);
309
+ const body = `written by files.write ${nonce}\n`;
310
+ await t.call("files.write", { path: `${WORKSPACE}/write-${nonce}.txt`, data: b64(body) }, client);
311
+ t.equal(text(copy.files.get(`write-${nonce}.txt`)), body, `write-${nonce}.txt, written by files.write, on the runner's copy when it answered`);
312
+ // A new tree (npm install's node_modules), pulled as one tar, and an empty directory, with no bytes.
313
+ const tree = await t.exec(["sh", "-c", `mkdir -p tree/a/b tree/empty && printf ${nonce} > tree/a/b/leaf`], { cwd: WORKSPACE }, client);
314
+ t.equal(tree.exitCode, 0, `a program's new tree at ${WORKSPACE}: its exit code (${tree.err.trim()})`);
315
+ t.equal(text(copy.files.get("tree/a/b/leaf")), nonce, "tree/a/b/leaf, in a tree a program made, on the runner's copy when exec.run answered");
316
+ t.assert(copy.dirs.has("tree/empty"), `tree/empty, an empty directory a program made, is not on the runner's copy: ${copy.writes.join(", ")}`);
317
+ }, { needs: SYNC_NEEDS });
318
+ /** "a push restores modes and links": the runner's copy pushed in reads back with its modes and its link, a program runs
319
+ * from it, and a sync after it writes nothing, since the copy holds it all. */
320
+ const syncPush = mount("sync-push", async (t) => {
321
+ const nonce = randomBytes(6).toString("hex");
322
+ const entries = [
323
+ { name: "run.sh", type: "file", mode: 0o755, body: Buffer.from(`#!/bin/sh\necho ran ${nonce}\n`) },
324
+ { name: "empty", type: "dir", mode: 0o755 },
325
+ { name: "private", type: "dir", mode: 0o700 },
326
+ { name: "private/key.txt", type: "file", mode: 0o600, body: Buffer.from(nonce) },
327
+ { name: "link", type: "symlink", mode: 0o777, link: "run.sh" },
328
+ ];
329
+ const { copy, client, own } = await synced(t, "mount-sync-push", entries);
330
+ const seen = await listed(t, own);
331
+ for (const { name, type, mode, link } of entries) {
332
+ const entry = t.present(seen.get(name), `${name}, pushed in, listed at ${WORKSPACE}`);
333
+ t.equal(entry.type, type, `${name}: its type`);
334
+ if (link !== undefined)
335
+ t.equal(entry.target, link, `${name}: the link's target, as pushed`);
336
+ else
337
+ t.equal((entry.mode & 0o7777).toString(8), mode.toString(8), `${name}: its mode, as pushed`);
338
+ }
339
+ const ran = await t.exec(["./run.sh"], { cwd: WORKSPACE }, client);
340
+ t.equal(ran.out, `ran ${nonce}\n`, `./run.sh, pushed in with mode 755, run at ${WORKSPACE} (${ran.err.trim()})`);
341
+ t.deepEqual(copy.writes, [], "what the sync after the push wrote to the runner's copy, which already holds the folder");
342
+ }, { needs: SYNC_NEEDS });
343
+ /** "a delete reaches the copy": a file removed, a tree removed and a file moved, on the copy when the call answers; the
344
+ * moved file's new path put before its old one is removed. */
345
+ const syncDelete = mount("sync-delete", async (t) => {
346
+ const nonce = randomBytes(6).toString("hex");
347
+ const file = (name) => ({ name, type: "file", mode: 0o644, body: Buffer.from(`${name} ${nonce}`) });
348
+ const { copy, client } = await synced(t, "mount-sync-delete", [file("gone.txt"), file("keep.txt"), file("move-me.txt"), { name: "dir", type: "dir", mode: 0o755 }, file("dir/a.txt"), { name: "dir/sub", type: "dir", mode: 0o755 }, file("dir/sub/b.txt")]);
349
+ const ran = await t.exec(["sh", "-c", "rm gone.txt && rm -rf dir && mv move-me.txt moved.txt"], { cwd: WORKSPACE }, client);
350
+ t.equal(ran.exitCode, 0, `rm, rm -rf and mv at ${WORKSPACE}: the exit code (${ran.err.trim()})`);
351
+ t.deepEqual([...copy.files.keys()].sort(), ["keep.txt", "moved.txt"], "the files on the runner's copy when exec.run answered");
352
+ t.equal(text(copy.files.get("moved.txt")), `move-me.txt ${nonce}`, "moved.txt: the moved file's bytes");
353
+ t.deepEqual([...copy.dirs], [], "the empty directories on the runner's copy");
354
+ t.assert(copy.writes.indexOf("put moved.txt") < copy.writes.indexOf("remove move-me.txt"), `the moved file is put at its new path before its old one is removed: ${copy.writes.join(", ")}`);
355
+ t.assert(copy.writes.indexOf("remove dir/sub/b.txt") < copy.writes.indexOf("remove dir/sub") && copy.writes.indexOf("remove dir/sub") < copy.writes.indexOf("remove dir"), `a tree is removed deepest first: ${copy.writes.join(", ")}`);
356
+ }, { needs: SYNC_NEEDS });
357
+ /** "a cap refuses": a folder grown past SYNC_MAX_ENTRIES fails the call that grew it, kind limit, in words naming the cap,
358
+ * and nothing past the cap reaches the copy. */
359
+ const syncCap = mount("sync-cap", async (t) => {
360
+ const { copy, client } = await synced(t, "mount-sync-cap");
361
+ const grown = await client.call("exec.run", { argv: ["sh", "-c", `mkdir many && cd many && seq 1 ${SYNC_MAX_ENTRIES} | xargs touch`], cwd: WORKSPACE, timeoutMs: 120_000 });
362
+ t.assert(!grown.ok, `exec.run that made ${SYNC_MAX_ENTRIES + 1} entries answered as if the folder were synced`);
363
+ if (grown.ok)
364
+ return;
365
+ t.equal(grown.error.code, "limit", `the failure's code (${grown.error.message})`);
366
+ t.equal(grown.error.message, `exec.run ran, but the run's folder could not be made durable: the run's folder holds more than ${SYNC_MAX_ENTRIES} entries, the most a synced folder holds`, "the failure's words");
367
+ t.deepEqual(copy.writes, [], "what reached the runner's copy");
368
+ }, { needs: SYNC_NEEDS, timeoutMs: 600_000 });
222
369
  /** A mount of each kind the provider does not declare, with a token this case alone knows. */
223
370
  function undeclaredMount(kind, token) {
371
+ if (kind === "sync")
372
+ return { kind };
224
373
  return kind === "bind" ? { kind, path: "/" } : { kind, disk: "conformance-disk", region: "conformance-region", folder: "agents/conformance/runs/r/work", token };
225
374
  }
226
375
  export const mountCases = [
@@ -231,6 +380,10 @@ export const mountCases = [
231
380
  archilToken,
232
381
  archilIsolatedDurable,
233
382
  archilLoopToolEdit,
383
+ syncDurable,
384
+ syncPush,
385
+ syncDelete,
386
+ syncCap,
234
387
  mount("undeclared-kind", async (t) => {
235
388
  const declared = t.provider.capabilities().mount ?? [];
236
389
  const undeclared = MOUNT_KINDS.filter((kind) => !declared.includes(kind));
@@ -393,7 +393,9 @@ export const providerCases = [
393
393
  // Past the machine's backstop: create's time, the most it may live and the margin, and a minute.
394
394
  const past = new Date(Date.now() + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS + 60_000);
395
395
  t.equal(await kit.check(token, past), undefined, "the machine's token past its backstop");
396
- const others = [{ kind: hello.kind === "linux" ? "desktop" : "linux" }, { os: hello.os === "linux" ? "windows" : "linux" }, { arch: hello.arch === "amd64" ? "arm64" : "amd64" }];
396
+ // A desktop's token takes a linux hello, its own before its display answers (attach.ts helloMismatch): it is held to
397
+ // another kind instead.
398
+ const others = [{ kind: hello.kind === "linux" ? "desktop" : hello.kind === "desktop" ? "android" : "linux" }, { os: hello.os === "linux" ? "windows" : "linux" }, { arch: hello.arch === "amd64" ? "arm64" : "amd64" }];
397
399
  for (const other of others) {
398
400
  t.equal(await kit.dialAs(token, { ...hello, ...other }), ATTACH_CLOSE.mismatch, `the machine's token with a hello of ${JSON.stringify(other)}: the close code`);
399
401
  }
@@ -19,7 +19,7 @@ export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "
19
19
  * included), a secret the provider takes (secrets: declared by the run's planted provider, which its conformance
20
20
  * module's ENV makes possible), or GPUs (gpu: declared by capabilities().gpu).
21
21
  */
22
- export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "persistence" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent" | "secrets" | "gpu";
22
+ export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "persistence" | "mount:bind" | "mount:archil" | "mount:sync" | "extend" | "stream" | "vendor-agent" | "secrets" | "gpu";
23
23
  /**
24
24
  * A fresh run's folder for one mount kind, made by the provider's conformance module: the mount that reaches it, and its
25
25
  * outside, where a computer does not run (the folder on the host for a bind, the disk's file API for Archil).
package/dist/daytona.d.ts CHANGED
@@ -17,8 +17,11 @@ export type WebSocketFactory = (url: string, init: {
17
17
  export type DaytonaTimeouts = HostedTimeouts & {
18
18
  retryMs: number;
19
19
  };
20
- /** The Daytona provider's options: the key and Daytona's own settings, then the shared adapter's (HostedOptions). */
21
- export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs" | "timeouts"> {
20
+ /**
21
+ * The Daytona provider's options: the key and Daytona's own settings, then the shared adapter's (HostedOptions), kind
22
+ * among them: a desktop on connect dial alone.
23
+ */
24
+ export interface DaytonaProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs" | "timeouts"> {
22
25
  /** The Daytona API key. The caller passes it; this provider never reads the environment and never puts it in a computer. */
23
26
  apiKey: string;
24
27
  /** Default https://app.daytona.io/api. */
package/dist/daytona.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // the computer is the shared machine-host adapter's (./hosted/provider.ts). Every Daytona fact used here is cited in the
8
8
  // README's Daytona section.
9
9
  import { randomBytes } from "node:crypto";
10
- import { mountsOf } from "./descriptor.js";
10
+ import { connectOf, mountsOf } from "./descriptor.js";
11
11
  import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
12
12
  import { COMPUTER_LABEL } from "./drift.js";
13
13
  import { HostError } from "./host.js";
@@ -16,7 +16,7 @@ import { HostedProvider, timeoutsOf } from "./hosted/provider.js";
16
16
  import { boundOf, orThrow, pause as sleep } from "./hosted/process.js";
17
17
  import { allPages, jsonOf, rest } from "./hosted/rest.js";
18
18
  import { shellLine } from "./hosted/scripts.js";
19
- import { connectOf, dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
19
+ import { dateOf, execDesktopRefusal, isWhole, sizeRefusals } from "./hosted/values.js";
20
20
  import { MAX_LINE_BYTES } from "./protocol.js";
21
21
  import { checkGpu } from "./provider.js";
22
22
  import { ok, vendorFail } from "./result.js";
@@ -142,6 +142,8 @@ class DaytonaHost {
142
142
  maxLifetimeMs: MAX_LIFETIME_MS,
143
143
  arch: options.arch,
144
144
  vendorAgentPorts: [TOOLBOX_PORT],
145
+ // A snapshot of box/Dockerfile has xfwm4 (box/install.sh's desktop step), for a desktop (connect dial alone).
146
+ windowManager: true,
145
147
  ...(options.connect === "dial" ? { connect: options.connect } : {}),
146
148
  };
147
149
  if (options.connect === "exec") {
@@ -512,7 +514,9 @@ class DaytonaHost {
512
514
  export class DaytonaProvider extends HostedProvider {
513
515
  constructor(options) {
514
516
  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");
517
+ const via = connectOf(DAYTONA, { connect });
518
+ if (hosted.kind === "desktop" && via === "exec")
519
+ throw new Error(execDesktopRefusal("Daytona", "a snapshot of box/Dockerfile"));
516
520
  if (typeof apiKey !== "string" || apiKey === "")
517
521
  throw new Error("options.apiKey, the Daytona API key, is required: the provider reads no environment, so the caller passes it");
518
522
  const base = new URL(apiUrl);
@@ -555,6 +559,6 @@ export class DaytonaProvider extends HostedProvider {
555
559
  pollMs,
556
560
  connect: via,
557
561
  });
558
- super(host, { ...hosted, kind: "linux", timeouts: hostedTimeouts });
562
+ super(host, { ...hosted, timeouts: hostedTimeouts });
559
563
  }
560
564
  }
@@ -58,7 +58,10 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
58
58
  readonly settings?: readonly DescriptorSetting[];
59
59
  /** The vendor bills by time; prices are the vendor's page, not ours. */
60
60
  readonly metered: boolean;
61
- /** The mount kinds its computers take, as its providers' capabilities().mount declare them; [] for none. */
61
+ /**
62
+ * The mount kinds its computers take beside the synced folder, bind or archil; [] for none. sync is never listed: it
63
+ * is derived (syncs, derivedMounts), and capabilities().mount declares both.
64
+ */
62
65
  readonly mounts: readonly MountKind[];
63
66
  /**
64
67
  * Mount kinds its computers don't take though a caller would ask for them, each with why in one sentence: check()
@@ -104,6 +107,14 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
104
107
  * provider's own check() still judges the image. Absent: its images are its defaultImage alone.
105
108
  */
106
109
  readonly imageEnv?: string;
110
+ /**
111
+ * How the server reaches its machines, where they may dial it (MachineHost facts.connect "dial": every connection goes
112
+ * over the socket the machine's computerd dials, which the server's attach hub takes). "dial": always (Fly Machines,
113
+ * Cloudflare). "either": its create() option `connect` says, "exec" (the default) or "dial", and a setting of its
114
+ * settings fills that option (E2B, Daytona, Modal). Absent: never. connectOf reads it; its built host's facts.connect
115
+ * is connectOf's answer.
116
+ */
117
+ readonly connect?: "dial" | "either";
107
118
  /** Its computers run on this machine's container engine: a server passes it its local host options (volume, host addresses). */
108
119
  readonly local?: boolean;
109
120
  /** create() takes a ledger the server keeps for it, as `options[ledger.option]` (the phone harness's sessions). */
@@ -138,12 +149,31 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
138
149
  export declare function defineProvider<const Descriptor extends ProviderDescriptor>(descriptor: Descriptor): Descriptor;
139
150
  /** What is wrong with a value offered as a descriptor, in words; none when it is one. */
140
151
  export declare function descriptorProblems(value: unknown): string[];
152
+ /**
153
+ * How a provider made with create() `options` reaches its machines: "dial", they dial the server (its descriptor's
154
+ * connect "dial", or "either" with options.connect "dial"); else "exec". The one answer to whether a provider's machines
155
+ * dial: each provider's host takes its facts.connect from it (hosted/provider.ts reads that), and a server reads it
156
+ * before it builds one (serve's Settings → Computers, where a runner in a process of its own has no attach hub). A
157
+ * connect other than exec or dial is refused in words.
158
+ */
159
+ export declare function connectOf(descriptor: Pick<ProviderDescriptor, "label" | "connect">, options?: {
160
+ readonly connect?: unknown;
161
+ }): "exec" | "dial";
162
+ /**
163
+ * Whether a configuration takes a synced folder: its groups have exec and files (all the runner reads and writes the
164
+ * folder through), and its descriptor binds no host folder (a bind is the folder itself) nor says why it takes none
165
+ * (unmounted.sync).
166
+ */
167
+ export declare function syncs(descriptor: Pick<ProviderDescriptor, "mounts" | "unmounted">, configuration: Pick<KindCapabilities, "groups">): boolean;
168
+ /** A descriptor's mounts, with sync where one of its configurations takes it (syncs). */
169
+ export declare function derivedMounts(descriptor: Pick<ProviderDescriptor, "mounts" | "unmounted" | "capabilities">): MountKind[];
141
170
  /**
142
171
  * The mount kinds a provider's computers take, and why not the others, with the keys `set` says the operator has set: its
143
- * mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with those
144
- * keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's folder.
172
+ * derived mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with
173
+ * those keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's
174
+ * folder.
145
175
  */
146
- export declare function mountsOf(descriptor: Pick<ProviderDescriptor, "mounts" | "unmounted" | "mountsWith">, set: (name: string) => boolean): {
176
+ export declare function mountsOf(descriptor: Pick<ProviderDescriptor, "mounts" | "unmounted" | "mountsWith" | "capabilities">, set: (name: string) => boolean): {
147
177
  mounts: MountKind[];
148
178
  unmounted: Unmounted;
149
179
  };
@@ -25,11 +25,11 @@ export function descriptorProblems(value) {
25
25
  if (typeof d.load !== "function")
26
26
  problems.push("load is not a function that imports the provider module");
27
27
  if (!Array.isArray(d.mounts) || d.mounts.some((kind) => kind !== "bind" && kind !== "archil"))
28
- problems.push("mounts is not a list of mount kinds (bind, archil)");
28
+ problems.push("mounts is not a list of mount kinds (bind, archil): sync is derived, never listed");
29
29
  if (d.unmounted !== undefined) {
30
30
  const entries = typeof d.unmounted === "object" && d.unmounted !== null && !Array.isArray(d.unmounted) ? Object.entries(d.unmounted) : undefined;
31
- if (entries === undefined || entries.some(([kind, why]) => (kind !== "bind" && kind !== "archil") || typeof why !== "string" || why.trim() === ""))
32
- problems.push("unmounted maps mount kinds (bind, archil) to why, in words");
31
+ if (entries === undefined || entries.some(([kind, why]) => (kind !== "bind" && kind !== "archil" && kind !== "sync") || typeof why !== "string" || why.trim() === ""))
32
+ problems.push("unmounted maps mount kinds (bind, archil, sync) to why, in words");
33
33
  else if (Array.isArray(d.mounts) && entries.some(([kind]) => d.mounts?.includes(kind)))
34
34
  problems.push("unmounted names a mount kind that mounts declares");
35
35
  }
@@ -84,6 +84,10 @@ export function descriptorProblems(value) {
84
84
  problems.push("each key says whether it is required");
85
85
  if (Array.isArray(d.keys) && d.keys.some((key) => key?.picked !== undefined && typeof key.picked !== "boolean"))
86
86
  problems.push("a key's picked is true or false");
87
+ if (d.connect !== undefined && d.connect !== "dial" && d.connect !== "either")
88
+ problems.push("connect is dial or either");
89
+ else if ((d.connect === "either") !== (Array.isArray(d.settings) && d.settings.some((setting) => setting?.option === "connect")))
90
+ problems.push("connect is either exactly where a setting fills the connect option");
87
91
  if (d.ledger !== undefined && (typeof d.ledger?.option !== "string" || d.ledger.option === ""))
88
92
  problems.push("ledger names the option it fills");
89
93
  if (d.imageEnv !== undefined && (typeof d.imageEnv !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(d.imageEnv)))
@@ -107,13 +111,43 @@ export function descriptorProblems(value) {
107
111
  }
108
112
  return problems;
109
113
  }
114
+ /**
115
+ * How a provider made with create() `options` reaches its machines: "dial", they dial the server (its descriptor's
116
+ * connect "dial", or "either" with options.connect "dial"); else "exec". The one answer to whether a provider's machines
117
+ * dial: each provider's host takes its facts.connect from it (hosted/provider.ts reads that), and a server reads it
118
+ * before it builds one (serve's Settings → Computers, where a runner in a process of its own has no attach hub). A
119
+ * connect other than exec or dial is refused in words.
120
+ */
121
+ export function connectOf(descriptor, options = {}) {
122
+ if (descriptor.connect !== "either")
123
+ return descriptor.connect === "dial" ? "dial" : "exec";
124
+ const { connect } = options;
125
+ if (connect === undefined || connect === "exec" || connect === "dial")
126
+ return connect ?? "exec";
127
+ throw new Error(`connect is how ${descriptor.label} reaches its machines, "exec" (the default) or "dial", not ${JSON.stringify(connect)}`);
128
+ }
129
+ /**
130
+ * Whether a configuration takes a synced folder: its groups have exec and files (all the runner reads and writes the
131
+ * folder through), and its descriptor binds no host folder (a bind is the folder itself) nor says why it takes none
132
+ * (unmounted.sync).
133
+ */
134
+ export function syncs(descriptor, configuration) {
135
+ return configuration.groups.includes("exec") && configuration.groups.includes("files") && !descriptor.mounts.includes("bind") && descriptor.unmounted?.sync === undefined;
136
+ }
137
+ /** A descriptor's mounts, with sync where one of its configurations takes it (syncs). */
138
+ export function derivedMounts(descriptor) {
139
+ const sync = !descriptor.mounts.includes("sync") && descriptor.capabilities.some((one) => syncs(descriptor, one));
140
+ return [...descriptor.mounts, ...(sync ? ["sync"] : [])];
141
+ }
110
142
  /**
111
143
  * The mount kinds a provider's computers take, and why not the others, with the keys `set` says the operator has set: its
112
- * mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with those
113
- * keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's folder.
144
+ * derived mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with
145
+ * those keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's
146
+ * folder.
114
147
  */
115
148
  export function mountsOf(descriptor, set) {
116
149
  const taken = Object.entries(descriptor.mountsWith ?? {}).flatMap(([kind, key]) => (typeof key === "string" && set(key) ? [kind] : []));
117
150
  const unmounted = Object.fromEntries(Object.entries(descriptor.unmounted ?? {}).filter(([kind]) => !taken.includes(kind)));
118
- return { mounts: [...descriptor.mounts, ...taken.filter((kind) => !descriptor.mounts.includes(kind))], unmounted };
151
+ const mounts = [...descriptor.mounts, ...taken.filter((kind) => !descriptor.mounts.includes(kind))];
152
+ return { mounts: derivedMounts({ ...descriptor, mounts }), unmounted };
119
153
  }
@@ -13,9 +13,22 @@ export declare const CLOUDFLARE: {
13
13
  readonly required: true;
14
14
  }];
15
15
  readonly metered: true;
16
+ readonly connect: "dial";
16
17
  readonly mounts: readonly [];
17
18
  readonly network: readonly ["none", "open", "allow"];
18
- readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
19
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
20
+ readonly options: {
21
+ readonly kind: "desktop";
22
+ };
23
+ readonly kind: import("../protocol.js").ComputerKind;
24
+ readonly groups: import("../protocol.js").Group[];
25
+ readonly gpu?: import("../provider.js").GpuCapability;
26
+ readonly persistence?: {
27
+ keepsState: true;
28
+ resume: boolean;
29
+ };
30
+ readonly image?: string;
31
+ }];
19
32
  readonly prepareImage: true;
20
33
  readonly load: () => Promise<typeof import("../cloudflare.js")>;
21
34
  };
@@ -4,7 +4,7 @@
4
4
  // call that starts or reaches into a container, so the relay creates, lists and deletes them, and computerd dials the
5
5
  // server's attach route.
6
6
  import { defineProvider } from "../descriptor.js";
7
- import { SANDBOX } from "./shared.js";
7
+ import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
8
8
  /** The relay's routes and rows this package speaks: the relay template's RELAY_VERSION; testConnection refuses another. */
9
9
  export const CLOUDFLARE_RELAY_VERSION = 1;
10
10
  export const CLOUDFLARE = defineProvider({
@@ -15,14 +15,18 @@ export const CLOUDFLARE = defineProvider({
15
15
  { name: "CLOUDFLARE_RELAY_TOKEN", option: "relayToken", required: true },
16
16
  ],
17
17
  metered: true,
18
+ // Its containers dial the server: Cloudflare has no REST call that reaches into one.
19
+ connect: "dial",
18
20
  // None: a machine that dials takes no Archil mount yet (its helper's root steps run through exec, which it has none of).
19
21
  mounts: [],
20
22
  // None: its programs run in init's network of their own, their loopback alone (isolation.ts). Open and a list: their
21
23
  // one way out is init's egress proxy (hosted/network.ts). The container itself always reaches out (enableInternet): it
22
24
  // fetches its daemon from the server and dials it.
23
25
  network: ["none", "open", "allow"],
24
- // A linux computer alone: agentrun-dial starts init with no display.
25
- capabilities: [SANDBOX],
26
+ // A linux computer, or a desktop: the box image's X server and xfwm4, started through computerd over the socket the
27
+ // container dialed. A desktop's size is the sandbox's, the adapter's default of 2 vCPUs and 4 GiB, which takes
28
+ // standard-3 (2 vCPUs, 8 GiB, 16 GB of disk; cloudflare.ts).
29
+ capabilities: [SANDBOX, { ...LINUX_DESKTOP, options: { kind: "desktop" } }],
26
30
  // No default image: every computer starts from the box image the relay was deployed with, which prepareImage() reads.
27
31
  prepareImage: true,
28
32
  load: () => import("../cloudflare.js"),
@@ -29,8 +29,8 @@ export declare const DAYTONA_GPU_SNAPSHOT_GPU: Readonly<DaytonaSnapshotGpu>;
29
29
  * daytona-gpu, alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it
30
30
  * (no pause, no snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory
31
31
  * and 400 GiB of disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and
32
- * it takes no mount: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client mounts
33
- * through FUSE, so an Archil mount is refused in words.
32
+ * it takes a synced folder alone: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client
33
+ * mounts through FUSE, so an Archil mount is refused in words.
34
34
  */
35
35
  export declare const DAYTONA_GPU: Readonly<GpuCapability>;
36
36
  /** The snapshot a provider makes its GPU computers from, and its GPU. */
@@ -43,7 +43,7 @@ export interface DaytonaGpuSnapshot extends DaytonaSnapshotGpu {
43
43
  * (box/build-daytona.py --gpu prints it).
44
44
  */
45
45
  export declare function daytonaGpuSnapshot(gpuSnapshot?: string): DaytonaGpuSnapshot;
46
- /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and no mount, the snapshot's GPU): a copy. */
46
+ /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and synced folder, the snapshot's GPU): a copy. */
47
47
  export declare function daytonaGpu(gpuSnapshot?: string): GpuCapability;
48
48
  export declare const DAYTONA: {
49
49
  readonly id: "daytona";
@@ -69,6 +69,7 @@ export declare const DAYTONA: {
69
69
  readonly name: "daytonaConnect";
70
70
  readonly option: "connect";
71
71
  }];
72
+ readonly connect: "either";
72
73
  readonly metered: true;
73
74
  readonly mounts: readonly [];
74
75
  readonly unmounted: {
@@ -88,6 +89,19 @@ export declare const DAYTONA: {
88
89
  };
89
90
  readonly image?: string;
90
91
  readonly options?: Readonly<Record<string, unknown>>;
92
+ }, {
93
+ readonly options: {
94
+ readonly kind: "desktop";
95
+ readonly connect: "dial";
96
+ };
97
+ readonly kind: import("../protocol.js").ComputerKind;
98
+ readonly groups: import("../protocol.js").Group[];
99
+ readonly gpu?: GpuCapability;
100
+ readonly persistence?: {
101
+ keepsState: true;
102
+ resume: boolean;
103
+ };
104
+ readonly image?: string;
91
105
  }];
92
106
  readonly defaultImage: {
93
107
  readonly sandbox: "default";
@@ -1,7 +1,7 @@
1
1
  // Daytona's descriptor: a sandbox on Daytona's cloud, with GPUs when asked; the run's folder on an Archil disk only where
2
2
  // the operator gives an Archil egress relay (a self-hosted Daytona target), never on Daytona's hosted cloud.
3
3
  import { defineProvider } from "../descriptor.js";
4
- import { SANDBOX } from "./shared.js";
4
+ import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
5
5
  /** The key that turns on a Daytona computer's Archil mount: the operator's Archil egress relay (archilEgress). */
6
6
  export const DAYTONA_ARCHIL_EGRESS = "DAYTONA_ARCHIL_EGRESS";
7
7
  /** Why a Daytona computer made with no Archil egress takes no Archil mount: check() refuses one in these words. */
@@ -23,8 +23,8 @@ export const DAYTONA_GPU_SNAPSHOT_GPU = Object.freeze({ type: "H100", count: 1 }
23
23
  * daytona-gpu, alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it
24
24
  * (no pause, no snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory
25
25
  * and 400 GiB of disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and
26
- * it takes no mount: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client mounts
27
- * through FUSE, so an Archil mount is refused in words.
26
+ * it takes a synced folder alone: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client
27
+ * mounts through FUSE, so an Archil mount is refused in words.
28
28
  */
29
29
  export const DAYTONA_GPU = Object.freeze({
30
30
  types: [DAYTONA_GPU_SNAPSHOT_GPU.type],
@@ -33,7 +33,7 @@ export const DAYTONA_GPU = Object.freeze({
33
33
  stopDeletes: true,
34
34
  region: DAYTONA_GPU_REGION,
35
35
  perGpu: { cpus: 16, memoryMb: 100 * 1024, diskMb: 400 * 1024 },
36
- mounts: [],
36
+ mounts: ["sync"],
37
37
  unmounted: Object.freeze({ why: "Daytona's GPU runtime gives it no /dev/fuse", yet: false }),
38
38
  });
39
39
  /**
@@ -58,10 +58,10 @@ export function daytonaGpuSnapshot(gpuSnapshot) {
58
58
  throw new Error(`gpuSnapshot ${JSON.stringify(gpuSnapshot)} is not a GPU snapshot of box/Dockerfile: box/build-daytona.py --gpu H100 prints its name, agentrun-archil-gpu-h100-<12 hex digits>`);
59
59
  return { snapshot: gpuSnapshot, type, count: 1 };
60
60
  }
61
- /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and no mount, the snapshot's GPU): a copy. */
61
+ /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and synced folder, the snapshot's GPU): a copy. */
62
62
  export function daytonaGpu(gpuSnapshot) {
63
63
  const { type, count } = daytonaGpuSnapshot(gpuSnapshot);
64
- return { ...DAYTONA_GPU, types: [type], max: count, perGpu: { ...DAYTONA_GPU.perGpu }, mounts: [] };
64
+ return { ...DAYTONA_GPU, types: [type], max: count, perGpu: { ...DAYTONA_GPU.perGpu }, mounts: ["sync"] };
65
65
  }
66
66
  export const DAYTONA = defineProvider({
67
67
  id: "daytona",
@@ -75,6 +75,7 @@ export const DAYTONA = defineProvider({
75
75
  // How the server reaches its machines: exec (the provider's default, when the server's settings name none), a session
76
76
  // command through the toolbox per connection, or dial, the machine dials the server (a snapshot of box/Dockerfile).
77
77
  settings: [{ name: "daytonaConnect", option: "connect" }],
78
+ connect: "either",
78
79
  metered: true,
79
80
  // No mount by default: on Daytona's hosted cloud, Archil's client (0.10.1) mounts on its container sandboxes, but
80
81
  // nothing reads its /dev/fuse after, so the first statx of the folder hangs, on every kernel and mount shape tried
@@ -89,8 +90,11 @@ export const DAYTONA = defineProvider({
89
90
  // its programs' one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts
90
91
  // alone (hosted/network.ts).
91
92
  network: ["none", "open", "allow"],
92
- // A linux computer, with GPUs when asked.
93
- capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
93
+ // A linux computer, with GPUs when asked; or, on connect dial alone, a desktop with none: a snapshot of box/Dockerfile's
94
+ // X server and xfwm4, started through computerd over the socket the sandbox dialed, at the snapshot's 2 CPUs and 4 GiB
95
+ // (box/build-daytona.py). The desktop's configuration selects dial itself, whatever daytonaConnect says: a provider on
96
+ // connect exec refuses kind desktop when it is made.
97
+ capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }, { ...LINUX_DESKTOP, options: { kind: "desktop", connect: "dial" } }],
94
98
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
95
99
  // The operator's own snapshot for every Daytona computer, named here; the default snapshot stands while unset. A
96
100
  // computer with an Archil mount needs a snapshot of box/Dockerfile (box/build-daytona.py prints its name).
@@ -10,6 +10,7 @@ export declare const E2B: {
10
10
  readonly name: "e2bConnect";
11
11
  readonly option: "connect";
12
12
  }];
13
+ readonly connect: "either";
13
14
  readonly metered: true;
14
15
  readonly mounts: readonly ["archil"];
15
16
  readonly network: readonly ["none", "open", "allow"];
@@ -7,8 +7,9 @@ export const E2B = defineProvider({
7
7
  label: "E2B",
8
8
  keys: [{ name: "E2B_API_KEY", option: "apiKey", required: true }],
9
9
  // How the server reaches its machines: exec (the provider's default, when the server's settings name none), a bridge
10
- // through envd per connection, or dial, the machine dials the server (a sandbox only).
10
+ // through envd per connection, or dial, the machine dials the server (a sandbox or a desktop, as on exec).
11
11
  settings: [{ name: "e2bConnect", option: "connect" }],
12
+ connect: "either",
12
13
  metered: true,
13
14
  mounts: ["archil"],
14
15
  // None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
@@ -11,9 +11,22 @@ export declare const FLY: {
11
11
  readonly required: true;
12
12
  }];
13
13
  readonly metered: true;
14
+ readonly connect: "dial";
14
15
  readonly mounts: readonly [];
15
16
  readonly network: readonly ["none", "open", "allow"];
16
- readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
17
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
18
+ readonly options: {
19
+ readonly kind: "desktop";
20
+ };
21
+ readonly kind: import("../protocol.js").ComputerKind;
22
+ readonly groups: import("../protocol.js").Group[];
23
+ readonly gpu?: import("../provider.js").GpuCapability;
24
+ readonly persistence?: {
25
+ keepsState: true;
26
+ resume: boolean;
27
+ };
28
+ readonly image?: string;
29
+ }];
17
30
  readonly prepareImage: true;
18
31
  readonly load: () => Promise<typeof import("../fly.js")>;
19
32
  };