@parcha/agentrun-computer 0.1.0-beta.35 → 0.1.0-beta.36

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 +108 -21
  2. package/box/Dockerfile +3 -1
  3. package/box/agentrun-archil +59 -7
  4. package/box/build-daytona.py +20 -4
  5. package/dist/browser.d.ts +61 -10
  6. package/dist/browser.js +125 -3
  7. package/dist/browserbase.d.ts +45 -20
  8. package/dist/browserbase.js +161 -17
  9. package/dist/chrome.d.ts +3 -4
  10. package/dist/chrome.js +6 -11
  11. package/dist/computerd-linux-amd64 +0 -0
  12. package/dist/computerd-linux-arm64 +0 -0
  13. package/dist/conformance/daytona.d.ts +4 -0
  14. package/dist/conformance/daytona.js +5 -0
  15. package/dist/daytona.d.ts +13 -1
  16. package/dist/daytona.js +55 -36
  17. package/dist/descriptor.d.ts +24 -2
  18. package/dist/descriptor.js +11 -0
  19. package/dist/descriptors/browserbase.d.ts +1 -0
  20. package/dist/descriptors/browserbase.js +2 -0
  21. package/dist/descriptors/daytona.d.ts +23 -2
  22. package/dist/descriptors/daytona.js +34 -2
  23. package/dist/descriptors/index.d.ts +28 -1
  24. package/dist/descriptors/index.js +1 -1
  25. package/dist/descriptors/kernel.d.ts +1 -0
  26. package/dist/descriptors/kernel.js +2 -0
  27. package/dist/descriptors/modal.d.ts +4 -0
  28. package/dist/descriptors/modal.js +11 -1
  29. package/dist/descriptors/orgo.d.ts +11 -0
  30. package/dist/descriptors/orgo.js +6 -1
  31. package/dist/descriptors/phone-harness.d.ts +5 -0
  32. package/dist/descriptors/phone-harness.js +3 -0
  33. package/dist/docker/egress.d.ts +4 -3
  34. package/dist/docker/egress.js +7 -6
  35. package/dist/docker.js +7 -5
  36. package/dist/e2b.js +1 -1
  37. package/dist/index.d.ts +5 -5
  38. package/dist/index.js +4 -4
  39. package/dist/janitor.d.ts +5 -4
  40. package/dist/janitor.js +1 -1
  41. package/dist/kernel.d.ts +16 -24
  42. package/dist/kernel.js +93 -18
  43. package/dist/kinds.d.ts +9 -4
  44. package/dist/labels.d.ts +10 -2
  45. package/dist/labels.js +30 -7
  46. package/dist/local-chrome.d.ts +3 -1
  47. package/dist/local-chrome.js +8 -4
  48. package/dist/modal.d.ts +3 -3
  49. package/dist/modal.js +71 -57
  50. package/dist/mount-archil.d.ts +25 -3
  51. package/dist/mount-archil.js +39 -8
  52. package/dist/orgo-desktop.d.ts +15 -6
  53. package/dist/orgo-desktop.js +295 -53
  54. package/dist/orgo-names.d.ts +129 -3
  55. package/dist/orgo-names.js +211 -8
  56. package/dist/orgo.d.ts +18 -7
  57. package/dist/orgo.js +381 -69
  58. package/dist/phone-harness.d.ts +3 -2
  59. package/dist/phone-harness.js +25 -8
  60. package/dist/protocol.d.ts +5 -0
  61. package/dist/provider.d.ts +63 -1
  62. package/dist/provider.js +8 -3
  63. package/package.json +1 -1
package/dist/daytona.d.ts CHANGED
@@ -60,6 +60,18 @@ export interface DaytonaProviderOptions {
60
60
  sandboxClass?: "container" | "linux-vm";
61
61
  /** The Daytona target (region); default the organization's. */
62
62
  target?: string;
63
+ /**
64
+ * The egress gateway an Archil computer's archil client reaches Archil through, `<IPv4 gateway>:<mount lane>:<data
65
+ * lane>` such as 10.60.0.40:18100:42050 (parcha-proxy's archil-egress): for a target whose runners reach Archil only
66
+ * through it. Unset, the client reaches Archil as the sandbox's network allows, as before.
67
+ */
68
+ archilEgress?: string;
69
+ /**
70
+ * The snapshot GPU computers are made from: one of ours, box/Dockerfile built with a GPU (box/build-daytona.py --gpu
71
+ * H100 prints its name, agentrun-archil-gpu-h100-<hash>), whose user is root; its GPU is the one its name says.
72
+ * Default Daytona's own daytona-gpu. Either way a GPU computer takes no mount: Daytona's GPU host gives no /dev/fuse.
73
+ */
74
+ gpuSnapshot?: string;
63
75
  /**
64
76
  * Who the daemon runs as, uid:gid in numbers, never root. Default 2510:2510 (TOOL_USER), a uid no process of Daytona's
65
77
  * holds: init refuses to start while another process does.
@@ -123,7 +135,7 @@ export declare class DaytonaProvider implements ComputerProvider {
123
135
  #private;
124
136
  readonly id = "daytona";
125
137
  readonly version: string;
126
- constructor({ apiKey, onNote, apiUrl, daemonPath, arch, sandboxClass, target, daemonUser, autoStopMinutes, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }: DaytonaProviderOptions);
138
+ constructor({ apiKey, onNote, apiUrl, daemonPath, arch, sandboxClass, target, archilEgress, gpuSnapshot, daemonUser, autoStopMinutes, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }: DaytonaProviderOptions);
127
139
  /**
128
140
  * daemon child: Daytona's toolbox daemon is the sandbox's first process, and init is a command it runs in a session
129
141
  * (#prepare), so deleting that session ends init and leaves the sandbox. maxLifetimeMs is the 30 days check() has
package/dist/daytona.js CHANGED
@@ -1,4 +1,4 @@
1
- // The Daytona provisioner, over Daytona's v0 REST API with fetch (no SDK), as pi-transport's Daytona box does. The daemon
1
+ // The Daytona provisioner, over Daytona's v0 REST API with fetch (no SDK). The daemon
2
2
  // goes in through the toolbox's file upload and starts as a session command, dropped to a user with no capabilities;
3
3
  // connect() carries stdio over a session command's input calls and its log stream. Every Daytona fact used here is cited
4
4
  // in the README's Daytona section.
@@ -10,12 +10,12 @@ import { fileURLToPath } from "node:url";
10
10
  import { childCommands, daemonDrift, installerOf, shellCommand } from "./child.js";
11
11
  import { OWN_NETWORK_ONLY, readOwnNetwork, TOOL_USER } from "./isolation.js";
12
12
  import { DaemonClient } from "./client.js";
13
- import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, DAYTONA_GPU_SNAPSHOT_GPU } from "./descriptors/daytona.js";
13
+ import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./descriptors/daytona.js";
14
14
  import { COMPUTER_LABEL, DEADLINE_LABEL, helloDrift, WORK } from "./drift.js";
15
15
  import { releaseOlder } from "./janitor.js";
16
16
  import { epochOf, RUN_LABEL } from "./labels.js";
17
17
  import { checkMount, readBackOf } from "./mount.js";
18
- import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
18
+ import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilEgressOf, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
19
19
  import { MAX_LINE_BYTES } from "./protocol.js";
20
20
  import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
21
21
  import { errorOf, failFor, ok, vendorFail } from "./result.js";
@@ -29,13 +29,6 @@ const fail = failFor("daytona");
29
29
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
30
30
  */
31
31
  export const MOUNT = DAYTONA.mounts;
32
- /** A copy of its descriptor's DAYTONA_GPU, so no caller can change the provider's own. */
33
- const daytonaGpuCapability = () => ({
34
- ...DAYTONA_GPU,
35
- types: [...DAYTONA_GPU.types],
36
- perGpu: { ...DAYTONA_GPU.perGpu },
37
- mounts: [],
38
- });
39
32
  /** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
40
33
  export const CAPABILITIES = DAYTONA.capabilities;
41
34
  /**
@@ -356,7 +349,7 @@ class Rest {
356
349
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
357
350
  });
358
351
  const bytes = new Uint8Array(await response.arrayBuffer());
359
- if (response.ok || (init.anyStatus === true && response.status < 500 && response.status !== 429))
352
+ if (response.ok || response.status === init.answerStatus || (init.anyStatus === true && response.status < 500 && response.status !== 429))
360
353
  return ok({ status: response.status, bytes });
361
354
  const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
362
355
  retryable = response.status === 429 || response.status >= 500;
@@ -394,11 +387,12 @@ class Rest {
394
387
  function sandboxDrift(spec, sb, expected) {
395
388
  const found = [];
396
389
  const mismatch = (field, declared, actual) => found.push(`${field}: declared ${show(declared)}, read back ${show(actual)}`);
397
- // A GPU computer is made from daytona-gpu, whatever image named it. Daytona's default snapshot is whichever it names: a
398
- // computer made from it is not held to a name.
390
+ // A GPU computer is made from the provider's GPU snapshot, whatever image named it. Daytona's default snapshot is
391
+ // whichever it names: a computer made from it is not held to a name.
392
+ const gpu = expected.gpu;
399
393
  if (spec.gpu !== undefined) {
400
- if (sb.snapshot !== DAYTONA_GPU_SNAPSHOT)
401
- mismatch("snapshot", DAYTONA_GPU_SNAPSHOT, sb.snapshot);
394
+ if (sb.snapshot !== gpu.snapshot)
395
+ mismatch("snapshot", gpu.snapshot, sb.snapshot);
402
396
  }
403
397
  else if (spec.image !== DAYTONA_DEFAULT_SNAPSHOT && sb.snapshot !== spec.image)
404
398
  mismatch("snapshot", spec.image, sb.snapshot);
@@ -430,12 +424,12 @@ function sandboxDrift(spec, sb, expected) {
430
424
  mismatch("public", false, sb.public);
431
425
  if (sb.kvm === true)
432
426
  mismatch("kvm", false, sb.kvm);
433
- // The GPUs read back, held to the snapshot's own (a create sends none): daytona-gpu's for a GPU computer, none else.
434
- const gpus = spec.gpu === undefined ? 0 : DAYTONA_GPU_SNAPSHOT_GPU.count;
427
+ // The GPUs read back, held to the GPU snapshot's own (a create sends none) for a GPU computer, none else.
428
+ const gpus = spec.gpu === undefined ? 0 : gpu.count;
435
429
  if ((sb.gpu ?? 0) !== gpus)
436
430
  mismatch("gpu", gpus, sb.gpu);
437
- if (spec.gpu !== undefined && sb.gpuType !== DAYTONA_GPU_SNAPSHOT_GPU.type)
438
- mismatch("gpuType", DAYTONA_GPU_SNAPSHOT_GPU.type, sb.gpuType);
431
+ if (spec.gpu !== undefined && sb.gpuType !== gpu.type)
432
+ mismatch("gpuType", gpu.type, sb.gpuType);
439
433
  if (Array.isArray(sb.volumes) ? sb.volumes.length > 0 : sb.volumes !== undefined && sb.volumes !== null)
440
434
  mismatch("volumes", [], sb.volumes);
441
435
  if (typeof sb.linkedSandboxId === "string" && sb.linkedSandboxId !== "")
@@ -537,6 +531,9 @@ export class DaytonaProvider {
537
531
  #arch;
538
532
  #class;
539
533
  #target;
534
+ #archilEgress;
535
+ /** The snapshot its GPU computers are made from, their GPU, and the mounts they take. */
536
+ #gpu;
540
537
  #uid;
541
538
  #gid;
542
539
  #webSocket;
@@ -544,7 +541,7 @@ export class DaytonaProvider {
544
541
  #autoStop;
545
542
  #autoDelete;
546
543
  #onNote;
547
- constructor({ apiKey, onNote, apiUrl = DEFAULT_API_URL, daemonPath, arch = "amd64", sandboxClass = "container", target, daemonUser = TOOL_USER, autoStopMinutes = 0, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }) {
544
+ constructor({ apiKey, onNote, apiUrl = DEFAULT_API_URL, daemonPath, arch = "amd64", sandboxClass = "container", target, archilEgress, gpuSnapshot, daemonUser = TOOL_USER, autoStopMinutes = 0, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }) {
548
545
  this.#onNote = onNote;
549
546
  if (typeof apiKey !== "string" || apiKey === "")
550
547
  throw new Error("a Daytona API key is required");
@@ -574,6 +571,8 @@ export class DaytonaProvider {
574
571
  this.#arch = arch;
575
572
  this.#class = sandboxClass;
576
573
  this.#target = target;
574
+ this.#archilEgress = archilEgress === undefined || archilEgress === "" ? undefined : archilEgressOf(archilEgress);
575
+ this.#gpu = daytonaGpuSnapshot(gpuSnapshot);
577
576
  [this.#uid, this.#gid] = [String(Number(user[1])), String(Number(user[2]))];
578
577
  this.#webSocket = webSocket ?? ((url, init) => new WebSocket(url, init));
579
578
  }
@@ -600,14 +599,14 @@ export class DaytonaProvider {
600
599
  mount: [...MOUNT],
601
600
  vendorAgentPorts: [TOOLBOX_PORT],
602
601
  // A GPU sandbox's limits are stated in gpu: its stop deletes it, it runs in region earth, its size is per GPU.
603
- gpu: daytonaGpuCapability(),
602
+ gpu: daytonaGpu(this.#gpu.snapshot === DAYTONA_GPU_SNAPSHOT ? undefined : this.#gpu.snapshot),
604
603
  };
605
604
  }
606
605
  check(spec) {
607
606
  const refusals = [];
608
607
  const refuse = (field, message) => refusals.push({ field, message });
609
608
  const given = (typeof spec === "object" && spec !== null ? spec : {});
610
- const { image, lifetimeMs, network, labels } = given;
609
+ const { image, network, labels } = given;
611
610
  if (typeof image !== "string" || image.trim() === "")
612
611
  refuse("image", `an image is required: the id or name of a Daytona snapshot, or "${DAYTONA_DEFAULT_SNAPSHOT}" for Daytona's default snapshot`);
613
612
  else if (/[\0-\x1f]/.test(image))
@@ -632,12 +631,13 @@ export class DaytonaProvider {
632
631
  refuse("mount", `an Archil mount's tools run as agentrun-tool, ${tool}:${tool}, and this provider's daemon user is ${this.#uid}:${this.#gid}: give it daemonUser "${tool}:${tool}"`);
633
632
  }
634
633
  }
635
- // The GPU is the snapshot's (a create sends none): daytona-gpu's type and count alone, and no mount (DAYTONA_GPU).
634
+ // The GPU is the GPU snapshot's (a create sends none): its type and count alone, and the mounts it takes.
636
635
  const gpuRefused = checkGpu(given.gpu, this.capabilities(), given.mount);
637
636
  refusals.push(...gpuRefused);
638
- // A GPU computer is made from daytona-gpu: a spec names it, or Daytona's default, never another snapshot.
639
- if (given.gpu !== undefined && gpuRefused.length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== DAYTONA_GPU_SNAPSHOT) {
640
- refuse("image", `a Daytona GPU computer is made from Daytona's GPU snapshot ${DAYTONA_GPU_SNAPSHOT} alone, not ${JSON.stringify(image)}: give "${DAYTONA_GPU_SNAPSHOT}" or "${DAYTONA_DEFAULT_SNAPSHOT}"; no other snapshot is proven to give a GPU computer`);
637
+ // A GPU computer is made from the provider's GPU snapshot: a spec names it, or Daytona's default, never another.
638
+ const gpuSnapshot = this.#gpu.snapshot;
639
+ if (given.gpu !== undefined && gpuRefused.length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== gpuSnapshot) {
640
+ refuse("image", `a Daytona GPU computer here is made from the GPU snapshot ${gpuSnapshot} alone, not ${JSON.stringify(image)}: give "${gpuSnapshot}" or "${DAYTONA_DEFAULT_SNAPSHOT}"; no other snapshot is proven to give a GPU computer`);
641
641
  }
642
642
  for (const [field, value] of Object.entries(given)) {
643
643
  if (SPEC_FIELDS.has(field) || value === undefined)
@@ -672,9 +672,9 @@ export class DaytonaProvider {
672
672
  const archil = archilOf(spec);
673
673
  const body = {
674
674
  name,
675
- // A GPU sandbox is made from daytona-gpu (check() took "default" or that name). Otherwise "default" sends no
676
- // snapshot, and Daytona makes the sandbox from its default snapshot.
677
- ...(spec.gpu !== undefined ? { snapshot: DAYTONA_GPU_SNAPSHOT } : spec.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: spec.image }),
675
+ // A GPU sandbox is made from the provider's GPU snapshot (check() took "default" or that name). Otherwise
676
+ // "default" sends no snapshot, and Daytona makes the sandbox from its default snapshot.
677
+ ...(spec.gpu !== undefined ? { snapshot: this.#gpu.snapshot } : spec.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: spec.image }),
678
678
  // An Archil computer carries its mount as a label: kind and source, never the token.
679
679
  labels: { ...spec.labels, ...(archil ? archilLabels(archil) : {}), [COMPUTER_LABEL]: "1", [DEADLINE_LABEL]: deadline, [IMAGE_LABEL]: spec.image },
680
680
  env: {},
@@ -741,9 +741,7 @@ export class DaytonaProvider {
741
741
  if (!toolbox.ok)
742
742
  return toolbox;
743
743
  const staging = `${STAGING}${randomBytes(8).toString("hex")}`;
744
- const form = new FormData();
745
- form.append("file", new Blob([new Uint8Array(daemon)]), "computerd");
746
- const uploaded = await this.#rest.call("POST", `${toolbox.value}/files/upload-v2?${new URLSearchParams({ path: staging })}`, { form, retry: true, timeoutMs: this.#timeouts.uploadMs }, signal);
744
+ const uploaded = await this.#upload(toolbox.value, staging, daemon, signal);
747
745
  if (!uploaded.ok)
748
746
  return fail(uploaded.error.code, `the daemon's upload was refused: ${uploaded.error.message}`);
749
747
  // Init's flags are built here (childCommands): every remote computer, an Archil one included, starts init with
@@ -773,6 +771,7 @@ export class DaytonaProvider {
773
771
  self: ref,
774
772
  releaseOlder: () => releaseOlder(this, run, epoch, signal ? { signal } : {}),
775
773
  timeoutMs: this.#timeouts.execMs,
774
+ ...(this.#archilEgress ? { egress: this.#archilEgress } : {}),
776
775
  ...(signal ? { signal } : {}),
777
776
  });
778
777
  if (!mounted.ok)
@@ -870,7 +869,7 @@ export class DaytonaProvider {
870
869
  };
871
870
  }
872
871
  #sandboxExpected(deadline, gpu = false) {
873
- return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDeleteFor(gpu) };
872
+ return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDeleteFor(gpu), gpu: this.#gpu };
874
873
  }
875
874
  /** The autoDeleteInterval a sandbox is made and read back with: 0 for a GPU sandbox, which a stop deletes; else the option's. */
876
875
  #autoDeleteFor(gpu) {
@@ -904,7 +903,7 @@ export class DaytonaProvider {
904
903
  }
905
904
  }
906
905
  /**
907
- * Daytona's label listing trails a create (pi-transport measured 0.7 to 1.6 s, with flaps), and list() must show a
906
+ * Daytona's label listing trails a create (measured 0.7 to 1.6 s, with flaps), and list() must show a
908
907
  * computer once create returns: create waits until the listing has shown it, without a miss, for listedStableMs.
909
908
  */
910
909
  async #waitListed(id, signal) {
@@ -950,6 +949,26 @@ export class DaytonaProvider {
950
949
  return vendorFail("daytona", `the toolbox URL Daytona gave is not https (${url.protocol}), so the key is not sent to it`);
951
950
  return ok(`${url.href.replace(/\/+$/, "")}/${encodeURIComponent(sb.id)}`);
952
951
  }
952
+ /**
953
+ * A file's bytes to `path` in the sandbox: files/upload-v2, else files/upload. An older toolbox, as a self-hosted
954
+ * Daytona's runners may run (the open daemon's routes, daytonaio/daytona@b5a5d9e7 apps/daemon/pkg/toolbox/server.go),
955
+ * has no files/upload-v2 and answers it 404; its files/upload takes the same form (a path query, the bytes as
956
+ * "file"). A 404 alone moves to the older route, so a refusal of any other kind is never sent twice.
957
+ */
958
+ async #upload(toolbox, path, bytes, signal) {
959
+ const query = new URLSearchParams({ path });
960
+ const send = (route, answerStatus) => {
961
+ const form = new FormData();
962
+ form.append("file", new Blob([new Uint8Array(bytes)]), "computerd");
963
+ return this.#rest.call("POST", `${toolbox}/${route}?${query}`, { form, retry: true, timeoutMs: this.#timeouts.uploadMs, ...(answerStatus === undefined ? {} : { answerStatus }) }, signal);
964
+ };
965
+ const current = await send("files/upload-v2", 404);
966
+ if (!current.ok || current.value.status !== 404)
967
+ return current;
968
+ const missing = `POST ${new URL(`${toolbox}/files/upload-v2`).pathname}: 404 ${decoder.decode(current.value.bytes).replace(/\s+/g, " ").trim().slice(0, 300)}`;
969
+ const older = await send("files/upload");
970
+ return older.ok ? older : fail(older.error.code, `${missing}, then ${older.error.message}`);
971
+ }
953
972
  async #execute(toolbox, command, signal) {
954
973
  const seconds = Math.ceil(this.#timeouts.execMs / 1000);
955
974
  const ran = await this.#rest.json("POST", `${toolbox}/process/execute`, { json: { command, timeout: seconds }, timeoutMs: this.#timeouts.execMs + 15_000 }, signal);
@@ -1204,7 +1223,7 @@ export class DaytonaProvider {
1204
1223
  },
1205
1224
  });
1206
1225
  }
1207
- /** Every sandbox with this provider's label, all pages: one label query, the way pi-transport asks. */
1226
+ /** Every sandbox with this provider's label, all pages: one label query. */
1208
1227
  async #listOwn(signal) {
1209
1228
  const found = [];
1210
1229
  const seen = new Set();
@@ -1519,7 +1538,7 @@ export class DaytonaProvider {
1519
1538
  return "failed" in waited.value ? waited.value.failed : ok(undefined);
1520
1539
  }
1521
1540
  /**
1522
- * Deletes a sandbox and makes sure it is going, as pi-transport does: a DELETE that fails counts as done only when the
1541
+ * Deletes a sandbox and makes sure it is going: a DELETE that fails counts as done only when the
1523
1542
  * sandbox is gone or being destroyed; a forced stop comes before the last attempt. Never signalled: a delete that
1524
1543
  * cleans up after an abort must outlive it.
1525
1544
  */
@@ -27,6 +27,17 @@ export type ParkedConfiguration = KindCapabilities & {
27
27
  readonly image: string;
28
28
  readonly why: string;
29
29
  };
30
+ /** A program a provider runs on the server's own machine: the command it looks for on PATH, and what installs it. */
31
+ export interface HostCommand {
32
+ readonly command: string;
33
+ /** What gives the command, in words a person installs it by: "Android platform-tools". */
34
+ readonly from: string;
35
+ /**
36
+ * The machines it is built for, as Node names them (`${process.platform}-${process.arch}`: "linux-x64"). A server on
37
+ * any other cannot install it, and says so. Absent: every machine.
38
+ */
39
+ readonly builds?: readonly string[];
40
+ }
30
41
  /**
31
42
  * A provider, declared once. Every field is data but load(), which imports the provider module only when called:
32
43
  * reading a descriptor loads no provider and no vendor SDK.
@@ -63,6 +74,12 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
63
74
  readonly defaultImage?: Partial<Record<ComputerSettingKind, string>>;
64
75
  /** Its built providers have prepareImage(): the image a computer starts from is made or pulled before the first create. */
65
76
  readonly prepareImage?: boolean;
77
+ /**
78
+ * The server's environment variable that, when its operator sets it, names the image every computer of this provider
79
+ * starts from in place of defaultImage (Daytona's snapshot of box/Dockerfile, which an Archil mount needs). The
80
+ * provider's own check() still judges the image. Absent: its images are its defaultImage alone.
81
+ */
82
+ readonly imageEnv?: string;
66
83
  /** Its computers run on this machine's container engine: a server passes it its local host options (volume, host addresses). */
67
84
  readonly local?: boolean;
68
85
  /** create() takes a ledger the server keeps for it, as `options[ledger.option]` (the phone harness's sessions). */
@@ -71,10 +88,15 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
71
88
  };
72
89
  /**
73
90
  * The server's own environment variables its provider reads on this machine, by name (Local Chrome's, where it finds
74
- * Chrome): a server passes their values, and no other variable of its own, as `options.env`. The provider itself reads
75
- * no environment.
91
+ * Chrome; a cloud browser's, the gateway a server reaches its API through): a server passes their values, and no other
92
+ * variable of its own, as `options.env`. The provider itself reads no environment.
76
93
  */
77
94
  readonly hostEnv?: readonly string[];
95
+ /**
96
+ * A program its computers need on the server's own machine, found on PATH (the phone's adb): a server looks for it at
97
+ * its start and, when it is missing, says from this alone that the provider can't run there and why.
98
+ */
99
+ readonly hostCommand?: HostCommand;
78
100
  /**
79
101
  * Configurations its module builds but does not offer yet (Orgo's Windows and macOS desktops), each by the image a
80
102
  * setting would name and why: a setting naming one is refused in its words, saying it is parked, never as an unknown
@@ -69,8 +69,19 @@ export function descriptorProblems(value) {
69
69
  problems.push("each key says whether it is required");
70
70
  if (d.ledger !== undefined && (typeof d.ledger?.option !== "string" || d.ledger.option === ""))
71
71
  problems.push("ledger names the option it fills");
72
+ if (d.imageEnv !== undefined && (typeof d.imageEnv !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(d.imageEnv)))
73
+ problems.push("imageEnv is an environment variable name (capital letters, digits and underscores)");
72
74
  if (d.hostEnv !== undefined && (!Array.isArray(d.hostEnv) || d.hostEnv.some((name) => typeof name !== "string" || name === "")))
73
75
  problems.push("hostEnv is a list of environment variable names");
76
+ if (d.hostCommand !== undefined) {
77
+ const { command, from, builds } = (d.hostCommand ?? {});
78
+ if (typeof command !== "string" || !/^[A-Za-z0-9._-]+$/.test(command))
79
+ problems.push("hostCommand's command is a program's name, with no path");
80
+ if (typeof from !== "string" || from.trim() === "")
81
+ problems.push("hostCommand says in words what installs it (from)");
82
+ if (builds !== undefined && (!Array.isArray(builds) || builds.length === 0 || builds.some((one) => typeof one !== "string" || !/^[a-z0-9]+-[a-z0-9]+$/.test(one))))
83
+ problems.push("hostCommand's builds are machines as Node names them (linux-x64)");
84
+ }
74
85
  if (d.parked !== undefined) {
75
86
  if (!Array.isArray(d.parked) || d.parked.some((one) => typeof one?.image !== "string" || one.image === "" || typeof one.why !== "string" || one.why === "" || typeof one.kind !== "string" || !Array.isArray(one.groups)))
76
87
  problems.push("parked is a list of configurations, each with its image and why it is parked");
@@ -13,6 +13,7 @@ export declare const BROWSERBASE: {
13
13
  readonly metered: true;
14
14
  readonly mounts: readonly [];
15
15
  readonly network: readonly ["open"];
16
+ readonly hostEnv: readonly ["BROWSERBASE_BASE_URL", "BROWSERBASE_CONNECT_BASE_URL"];
16
17
  readonly capabilities: readonly [{
17
18
  readonly kind: "browser";
18
19
  readonly groups: ["cdp", "stream"];
@@ -12,6 +12,8 @@ export const BROWSERBASE = defineProvider({
12
12
  mounts: [],
13
13
  // Browserbase's own network, open: it cannot be closed or narrowed.
14
14
  network: ["open"],
15
+ // A server behind a gateway that fronts Browserbase's API or its sessions' sockets names it here.
16
+ hostEnv: ["BROWSERBASE_BASE_URL", "BROWSERBASE_CONNECT_BASE_URL"],
15
17
  capabilities: [{ kind: "browser", groups: ["cdp", "stream"] }],
16
18
  defaultImage: { browser: BROWSER_IMAGE },
17
19
  load: () => import("../browserbase.js"),
@@ -25,10 +25,22 @@ export declare const DAYTONA_GPU_SNAPSHOT_GPU: Readonly<DaytonaSnapshotGpu>;
25
25
  * daytona-gpu, alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it
26
26
  * (no pause, no snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory
27
27
  * and 400 GiB of disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and
28
- * it takes no mount: daytona-gpu's user is daytona, not root, and it has no Archil client, so an Archil mount is refused
29
- * in words.
28
+ * it takes no mount: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client mounts
29
+ * through FUSE, so an Archil mount is refused in words.
30
30
  */
31
31
  export declare const DAYTONA_GPU: Readonly<GpuCapability>;
32
+ /** The snapshot a provider makes its GPU computers from, and its GPU. */
33
+ export interface DaytonaGpuSnapshot extends DaytonaSnapshotGpu {
34
+ snapshot: string;
35
+ }
36
+ /**
37
+ * The GPU snapshot a provider with the gpuSnapshot option (or none) makes its GPU computers from: daytona-gpu when none
38
+ * is given; else ours, with the GPU its name says. Throws in words for a name that is not one of ours
39
+ * (box/build-daytona.py --gpu prints it).
40
+ */
41
+ export declare function daytonaGpuSnapshot(gpuSnapshot?: string): DaytonaGpuSnapshot;
42
+ /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and no mount, the snapshot's GPU): a copy. */
43
+ export declare function daytonaGpu(gpuSnapshot?: string): GpuCapability;
32
44
  export declare const DAYTONA: {
33
45
  readonly id: "daytona";
34
46
  readonly label: "Daytona";
@@ -44,6 +56,10 @@ export declare const DAYTONA: {
44
56
  readonly name: "DAYTONA_TARGET";
45
57
  readonly option: "target";
46
58
  readonly required: false;
59
+ }, {
60
+ readonly name: "DAYTONA_ARCHIL_EGRESS";
61
+ readonly option: "archilEgress";
62
+ readonly required: false;
47
63
  }];
48
64
  readonly metered: true;
49
65
  readonly mounts: readonly ["archil"];
@@ -52,11 +68,16 @@ export declare const DAYTONA: {
52
68
  readonly gpu: Readonly<GpuCapability>;
53
69
  readonly kind: import("../protocol.js").ComputerKind;
54
70
  readonly groups: import("../protocol.js").Group[];
71
+ readonly persistence?: {
72
+ keepsState: true;
73
+ resume: boolean;
74
+ };
55
75
  readonly image?: string;
56
76
  readonly options?: Readonly<Record<string, unknown>>;
57
77
  }];
58
78
  readonly defaultImage: {
59
79
  readonly sandbox: "default";
60
80
  };
81
+ readonly imageEnv: "AGENTRUN_DAYTONA_SNAPSHOT";
61
82
  readonly load: () => Promise<typeof import("../daytona.js")>;
62
83
  };
@@ -18,8 +18,8 @@ export const DAYTONA_GPU_SNAPSHOT_GPU = Object.freeze({ type: "H100", count: 1 }
18
18
  * daytona-gpu, alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it
19
19
  * (no pause, no snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory
20
20
  * and 400 GiB of disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and
21
- * it takes no mount: daytona-gpu's user is daytona, not root, and it has no Archil client, so an Archil mount is refused
22
- * in words.
21
+ * it takes no mount: Daytona's GPU host gives no /dev/fuse, even to root (live 11-11), and the archil client mounts
22
+ * through FUSE, so an Archil mount is refused in words.
23
23
  */
24
24
  export const DAYTONA_GPU = Object.freeze({
25
25
  types: [DAYTONA_GPU_SNAPSHOT_GPU.type],
@@ -29,7 +29,35 @@ export const DAYTONA_GPU = Object.freeze({
29
29
  region: DAYTONA_GPU_REGION,
30
30
  perGpu: { cpus: 16, memoryMb: 100 * 1024, diskMb: 400 * 1024 },
31
31
  mounts: [],
32
+ unmounted: Object.freeze({ why: "Daytona's GPU runtime gives it no /dev/fuse", yet: false }),
32
33
  });
34
+ /**
35
+ * Our GPU snapshots: box/Dockerfile built with a GPU (box/build-daytona.py --gpu <type>), named
36
+ * agentrun-archil-gpu-<type>-<the recipe's hash>. Their user is root and they carry the Archil client and our helper,
37
+ * but their GPU computers take no mount either: Daytona's GPU host gives no /dev/fuse. The name says the GPU: one of
38
+ * the type it names (the build's resources).
39
+ */
40
+ const ARCHIL_GPU_SNAPSHOT = /^agentrun-archil-gpu-(h100)-[0-9a-f]{12}$/;
41
+ const ARCHIL_GPU_TYPES = { h100: "H100" };
42
+ /**
43
+ * The GPU snapshot a provider with the gpuSnapshot option (or none) makes its GPU computers from: daytona-gpu when none
44
+ * is given; else ours, with the GPU its name says. Throws in words for a name that is not one of ours
45
+ * (box/build-daytona.py --gpu prints it).
46
+ */
47
+ export function daytonaGpuSnapshot(gpuSnapshot) {
48
+ if (gpuSnapshot === undefined)
49
+ return { snapshot: DAYTONA_GPU_SNAPSHOT, ...DAYTONA_GPU_SNAPSHOT_GPU };
50
+ const named = ARCHIL_GPU_SNAPSHOT.exec(gpuSnapshot);
51
+ const type = named === null ? undefined : ARCHIL_GPU_TYPES[named[1]];
52
+ if (type === undefined)
53
+ 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>`);
54
+ return { snapshot: gpuSnapshot, type, count: 1 };
55
+ }
56
+ /** The GPUs a provider declares for its GPU snapshot (DAYTONA_GPU's limits and no mount, the snapshot's GPU): a copy. */
57
+ export function daytonaGpu(gpuSnapshot) {
58
+ const { type, count } = daytonaGpuSnapshot(gpuSnapshot);
59
+ return { ...DAYTONA_GPU, types: [type], max: count, perGpu: { ...DAYTONA_GPU.perGpu }, mounts: [] };
60
+ }
33
61
  export const DAYTONA = defineProvider({
34
62
  id: "daytona",
35
63
  label: "Daytona",
@@ -37,6 +65,7 @@ export const DAYTONA = defineProvider({
37
65
  { name: "DAYTONA_API_KEY", option: "apiKey", required: true },
38
66
  { name: "DAYTONA_API_URL", option: "apiUrl", required: false },
39
67
  { name: "DAYTONA_TARGET", option: "target", required: false },
68
+ { name: "DAYTONA_ARCHIL_EGRESS", option: "archilEgress", required: false },
40
69
  ],
41
70
  metered: true,
42
71
  mounts: ["archil"],
@@ -45,5 +74,8 @@ export const DAYTONA = defineProvider({
45
74
  // A linux computer, with GPUs when asked.
46
75
  capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
47
76
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
77
+ // A Daytona computer that mounts the run's folder from Archil needs a snapshot of box/Dockerfile (build-daytona.py
78
+ // builds one and prints its name): the operator names it here, and the default snapshot stands while unset.
79
+ imageEnv: "AGENTRUN_DAYTONA_SNAPSHOT",
48
80
  load: () => import("../daytona.js"),
49
81
  });
@@ -33,6 +33,10 @@ export declare const DESCRIPTORS: readonly [{
33
33
  readonly name: "DAYTONA_TARGET";
34
34
  readonly option: "target";
35
35
  readonly required: false;
36
+ }, {
37
+ readonly name: "DAYTONA_ARCHIL_EGRESS";
38
+ readonly option: "archilEgress";
39
+ readonly required: false;
36
40
  }];
37
41
  readonly metered: true;
38
42
  readonly mounts: readonly ["archil"];
@@ -41,12 +45,17 @@ export declare const DESCRIPTORS: readonly [{
41
45
  readonly gpu: Readonly<import("../provider.js").GpuCapability>;
42
46
  readonly kind: import("../protocol.js").ComputerKind;
43
47
  readonly groups: import("../protocol.js").Group[];
48
+ readonly persistence?: {
49
+ keepsState: true;
50
+ resume: boolean;
51
+ };
44
52
  readonly image?: string;
45
53
  readonly options?: Readonly<Record<string, unknown>>;
46
54
  }];
47
55
  readonly defaultImage: {
48
56
  readonly sandbox: "default";
49
57
  };
58
+ readonly imageEnv: "AGENTRUN_DAYTONA_SNAPSHOT";
50
59
  readonly load: () => Promise<typeof import("../daytona.js")>;
51
60
  }, {
52
61
  readonly id: "modal";
@@ -72,6 +81,10 @@ export declare const DESCRIPTORS: readonly [{
72
81
  readonly gpu: Readonly<import("../provider.js").GpuCapability>;
73
82
  readonly kind: import("../protocol.js").ComputerKind;
74
83
  readonly groups: import("../protocol.js").Group[];
84
+ readonly persistence?: {
85
+ keepsState: true;
86
+ resume: boolean;
87
+ };
75
88
  readonly image?: string;
76
89
  readonly options?: Readonly<Record<string, unknown>>;
77
90
  }];
@@ -114,6 +127,10 @@ export declare const DESCRIPTORS: readonly [{
114
127
  readonly capabilities: readonly [{
115
128
  readonly image: "linux";
116
129
  readonly options: {};
130
+ readonly persistence: {
131
+ readonly keepsState: true;
132
+ readonly resume: true;
133
+ };
117
134
  readonly kind: import("../protocol.js").ComputerKind;
118
135
  readonly groups: import("../protocol.js").Group[];
119
136
  readonly gpu?: import("../provider.js").GpuCapability;
@@ -135,6 +152,9 @@ export declare const DESCRIPTORS: readonly [{
135
152
  };
136
153
  readonly why: "Orgo's macOS desktops are parked for now: Orgo offers Linux desktops";
137
154
  }];
155
+ readonly ledger: {
156
+ readonly option: "ledger";
157
+ };
138
158
  readonly defaultImage: {
139
159
  readonly desktop: "linux";
140
160
  };
@@ -160,6 +180,11 @@ export declare const DESCRIPTORS: readonly [{
160
180
  readonly ledger: {
161
181
  readonly option: "ledger";
162
182
  };
183
+ readonly hostCommand: {
184
+ readonly command: "adb";
185
+ readonly from: "Android platform-tools";
186
+ readonly builds: readonly ["linux-x64", "darwin-x64", "darwin-arm64", "win32-x64"];
187
+ };
163
188
  readonly load: () => Promise<typeof import("../phone-harness.js")>;
164
189
  }, {
165
190
  readonly id: "browserbase";
@@ -176,6 +201,7 @@ export declare const DESCRIPTORS: readonly [{
176
201
  readonly metered: true;
177
202
  readonly mounts: readonly [];
178
203
  readonly network: readonly ["open"];
204
+ readonly hostEnv: readonly ["BROWSERBASE_BASE_URL", "BROWSERBASE_CONNECT_BASE_URL"];
179
205
  readonly capabilities: readonly [{
180
206
  readonly kind: "browser";
181
207
  readonly groups: ["cdp", "stream"];
@@ -195,6 +221,7 @@ export declare const DESCRIPTORS: readonly [{
195
221
  readonly metered: true;
196
222
  readonly mounts: readonly [];
197
223
  readonly network: readonly ["open"];
224
+ readonly hostEnv: readonly ["KERNEL_BASE_URL"];
198
225
  readonly capabilities: readonly [{
199
226
  readonly kind: "browser";
200
227
  readonly groups: ["cdp", "stream"];
@@ -221,7 +248,7 @@ export declare const DESCRIPTORS: readonly [{
221
248
  readonly load: () => Promise<typeof import("../local-chrome.js")>;
222
249
  }];
223
250
  export { BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
224
- export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT } from "./daytona.js";
251
+ export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
225
252
  export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
226
253
  export { MODAL_DEFAULT_IMAGE } from "./modal.js";
227
254
  export { ORGO_BASE_IMAGE } from "./orgo.js";
@@ -11,7 +11,7 @@ import { ORGO } from "./orgo.js";
11
11
  import { PHONE_HARNESS } from "./phone-harness.js";
12
12
  export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL];
13
13
  export { BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
14
- export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT } from "./daytona.js";
14
+ export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
15
15
  export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
16
16
  export { MODAL_DEFAULT_IMAGE } from "./modal.js";
17
17
  export { ORGO_BASE_IMAGE } from "./orgo.js";
@@ -9,6 +9,7 @@ export declare const KERNEL: {
9
9
  readonly metered: true;
10
10
  readonly mounts: readonly [];
11
11
  readonly network: readonly ["open"];
12
+ readonly hostEnv: readonly ["KERNEL_BASE_URL"];
12
13
  readonly capabilities: readonly [{
13
14
  readonly kind: "browser";
14
15
  readonly groups: ["cdp", "stream"];
@@ -9,6 +9,8 @@ export const KERNEL = defineProvider({
9
9
  mounts: [],
10
10
  // Kernel's own network, open: it cannot be closed or narrowed.
11
11
  network: ["open"],
12
+ // A server behind a gateway that fronts Kernel's API names it here.
13
+ hostEnv: ["KERNEL_BASE_URL"],
12
14
  capabilities: [{ kind: "browser", groups: ["cdp", "stream"] }],
13
15
  defaultImage: { browser: BROWSER_IMAGE },
14
16
  load: () => import("../kernel.js"),
@@ -40,6 +40,10 @@ export declare const MODAL: {
40
40
  readonly gpu: Readonly<GpuCapability>;
41
41
  readonly kind: import("../protocol.js").ComputerKind;
42
42
  readonly groups: import("../protocol.js").Group[];
43
+ readonly persistence?: {
44
+ keepsState: true;
45
+ resume: boolean;
46
+ };
43
47
  readonly image?: string;
44
48
  readonly options?: Readonly<Record<string, unknown>>;
45
49
  }];
@@ -17,7 +17,17 @@ export const MODAL_GPU_MAX = 8;
17
17
  * being proven on gVisor; and the loopback fence made inside a user namespace, as gVisor's root may not make a network
18
18
  * namespace itself (a live probe, 11-11: unshare -n refused, unshare -Urn allowed).
19
19
  */
20
- export const MODAL_GPU = Object.freeze({ types: [...MODAL_GPU_TYPES], max: MODAL_GPU_MAX, isolation: "gvisor", preemptible: true, mounts: [], fence: "userns-netns" });
20
+ export const MODAL_GPU = Object.freeze({
21
+ types: [...MODAL_GPU_TYPES],
22
+ max: MODAL_GPU_MAX,
23
+ isolation: "gvisor",
24
+ preemptible: true,
25
+ mounts: [],
26
+ // Its gVisor runtime gives /dev/fuse (modal-6, 11-11: a character device 10:229 that opens), but Archil's FUSE mount
27
+ // under gVisor is not proven safe for the Archil client.
28
+ unmounted: Object.freeze({ why: "Archil's FUSE mount isn't proven on Modal's gVisor runtime (#2279)", yet: true }),
29
+ fence: "userns-netns",
30
+ });
21
31
  export const MODAL = defineProvider({
22
32
  id: "modal",
23
33
  label: "Modal",