@parcha/agentrun-computer 0.1.0-beta.38 → 0.1.0-beta.39

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 (85) hide show
  1. package/README.md +101 -76
  2. package/box/README.md +2 -1
  3. package/box/recipe.d.mts +5 -0
  4. package/dist/agent37.d.ts +17 -4
  5. package/dist/agent37.js +96 -16
  6. package/dist/box-image.d.ts +14 -0
  7. package/dist/box-image.js +24 -0
  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/agent37.d.ts +9 -4
  12. package/dist/conformance/agent37.js +23 -11
  13. package/dist/conformance/browserbase.js +3 -3
  14. package/dist/conformance/cases/apps.d.ts +1 -1
  15. package/dist/conformance/cases/apps.js +1 -1
  16. package/dist/conformance/cases/isolation.d.ts +18 -3
  17. package/dist/conformance/cases/isolation.js +57 -6
  18. package/dist/conformance/cases/mount.js +4 -2
  19. package/dist/conformance/cases/provider.js +41 -0
  20. package/dist/conformance/cli.js +6 -5
  21. package/dist/conformance/e2b.js +9 -4
  22. package/dist/conformance/exec-stream.d.ts +7 -0
  23. package/dist/conformance/exec-stream.js +8 -1
  24. package/dist/conformance/kernel.js +2 -2
  25. package/dist/conformance/modal.js +1 -1
  26. package/dist/conformance/orgo.js +2 -2
  27. package/dist/daytona.d.ts +0 -5
  28. package/dist/daytona.js +16 -27
  29. package/dist/descriptor.d.ts +5 -3
  30. package/dist/descriptors/agent37.d.ts +3 -11
  31. package/dist/descriptors/agent37.js +9 -10
  32. package/dist/descriptors/daytona.d.ts +1 -1
  33. package/dist/descriptors/daytona.js +5 -2
  34. package/dist/descriptors/docker.d.ts +13 -1
  35. package/dist/descriptors/docker.js +3 -1
  36. package/dist/descriptors/e2b.d.ts +2 -9
  37. package/dist/descriptors/e2b.js +8 -8
  38. package/dist/descriptors/index.d.ts +21 -19
  39. package/dist/descriptors/index.js +1 -3
  40. package/dist/descriptors/modal.d.ts +2 -6
  41. package/dist/descriptors/modal.js +8 -6
  42. package/dist/descriptors/orgo.js +2 -1
  43. package/dist/docker/egress-main.js +23 -15
  44. package/dist/docker/egress.d.ts +6 -4
  45. package/dist/docker/egress.js +24 -16
  46. package/dist/docker/inspect.d.ts +2 -2
  47. package/dist/docker/inspect.js +5 -5
  48. package/dist/docker.d.ts +6 -5
  49. package/dist/docker.js +12 -11
  50. package/dist/e2b.d.ts +12 -2
  51. package/dist/e2b.js +42 -19
  52. package/dist/host.d.ts +54 -41
  53. package/dist/hosted/network.d.ts +23 -0
  54. package/dist/hosted/network.js +77 -0
  55. package/dist/hosted/process.d.ts +2 -0
  56. package/dist/hosted/process.js +5 -0
  57. package/dist/hosted/provider.d.ts +6 -4
  58. package/dist/hosted/provider.js +244 -136
  59. package/dist/hosted/rest.d.ts +10 -2
  60. package/dist/hosted/rest.js +9 -4
  61. package/dist/hosted/scripts.d.ts +19 -7
  62. package/dist/hosted/scripts.js +55 -18
  63. package/dist/{agent37-ssh.d.ts → hosted/ssh-exec.d.ts} +19 -9
  64. package/dist/{agent37-ssh.js → hosted/ssh-exec.js} +38 -19
  65. package/dist/hosted/values.d.ts +21 -0
  66. package/dist/hosted/values.js +55 -0
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/isolation.d.ts +0 -2
  70. package/dist/isolation.js +3 -4
  71. package/dist/modal.d.ts +8 -2
  72. package/dist/modal.js +21 -15
  73. package/dist/mount-archil.d.ts +5 -4
  74. package/dist/mount-archil.js +5 -6
  75. package/dist/orgo.js +6 -4
  76. package/dist/providers.d.ts +4 -1
  77. package/dist/surface/api.d.ts +0 -9
  78. package/dist/surface/core.d.ts +7 -2
  79. package/dist/surface/core.js +12 -4
  80. package/dist/surface/index.d.ts +1 -1
  81. package/dist/surface/index.js +1 -1
  82. package/dist/surface/script.d.ts +4 -0
  83. package/dist/surface/script.js +9 -3
  84. package/package.json +1 -1
  85. package/box/build-agent37.mjs +0 -158
@@ -206,9 +206,10 @@ export function plantSecrets(names) {
206
206
  }
207
207
  /**
208
208
  * The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
209
- * it says of its run: conformanceImage(), the image when --image names none, and conformanceNotes, strings for the report.
209
+ * it says of its run: conformanceImage(), the image when --image names none (asked only then: a module's may make or
210
+ * register its image, so it is given the run's signal), and conformanceNotes, strings for the report.
210
211
  */
211
- async function load(label, module, options, declared) {
212
+ async function load(label, module, options, { imageNamed, signal }, declared) {
212
213
  const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
213
214
  if (typeof createProvider !== "function")
214
215
  throw new Usage(`${label} does not export createProvider() or create()`);
@@ -235,8 +236,8 @@ async function load(label, module, options, declared) {
235
236
  }
236
237
  if (typeof mountFor === "function")
237
238
  target.mountFor = (kind) => mountFor(kind, options);
238
- if (conformanceImage !== undefined) {
239
- const image = typeof conformanceImage === "function" ? await conformanceImage(options) : undefined;
239
+ if (conformanceImage !== undefined && !imageNamed) {
240
+ const image = typeof conformanceImage === "function" ? await conformanceImage(options, signal ? { signal } : {}) : undefined;
240
241
  if (typeof image !== "string" || image === "")
241
242
  throw new Usage(`${label}: conformanceImage() did not return an image`);
242
243
  target.image = image;
@@ -306,7 +307,7 @@ export async function main(argv, io = {}) {
306
307
  let target;
307
308
  try {
308
309
  const { label, module, declared } = await conformanceModule(args.provider, cwd);
309
- target = await load(label, module, options, declared);
310
+ target = await load(label, module, options, { imageNamed: args.image !== undefined, ...(signal ? { signal } : {}) }, declared);
310
311
  }
311
312
  catch (error) {
312
313
  await write(stderr, `${error.message}\n`);
@@ -1,5 +1,5 @@
1
1
  // E2B for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider e2b [--image <template>]`.
2
- // It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key the lead has OKed, under
2
+ // It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key for an account you can bill, under
3
3
  // COMPUTER_E2B_API_KEY. The provider reads no environment: this module reads its own COMPUTER_E2B_* names (never
4
4
  // E2B_API_KEY, which may hold another team's key) and passes each to create() as its option; the provider gives the SDK
5
5
  // the key, domain and API URL explicitly, and refuses an ambient E2B_SANDBOX_URL (see create in ../e2b.ts). The live
@@ -15,7 +15,6 @@
15
15
  // disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
16
16
  // COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
17
17
  // are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
18
- import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../descriptors/e2b.js";
19
18
  import { create } from "../e2b.js";
20
19
  import { archilRunFolder, archilSettings } from "./archil.js";
21
20
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
@@ -77,12 +76,18 @@ export const conformanceNotes = [
77
76
  ];
78
77
  function live(env) {
79
78
  if (env[E2B_ENV.live] !== "1") {
80
- throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key the lead has OKed, to run it`);
79
+ throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key for an account you can bill, to run it`);
81
80
  }
82
81
  }
82
+ /**
83
+ * The conformance run's own default templates, E2B's stock ones: E2B Desktop's, and its plain one for kind linux. A server
84
+ * starts from the box template (the provider's prepareImage); a run on it names it with --image.
85
+ */
86
+ const DESKTOP_TEMPLATE = "desktop";
87
+ const BASE_TEMPLATE = "base";
83
88
  /** The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE, or E2B Desktop's (the plain one for kind linux). */
84
89
  export function conformanceImage({ env = process.env } = {}) {
85
- return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? E2B_BASE_TEMPLATE : E2B_DESKTOP_TEMPLATE);
90
+ return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? BASE_TEMPLATE : DESKTOP_TEMPLATE);
86
91
  }
87
92
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
88
93
  export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote } = {}) {
@@ -31,6 +31,13 @@ export interface ExecStreamOptions {
31
31
  export declare const DEFAULT_LONG_MS = 75000;
32
32
  /** --quick's no-timeout check: long enough to cross a second, short enough for CI. */
33
33
  export declare const QUICK_LONG_MS = 5000;
34
+ /**
35
+ * kill's probe, `sh -c PID_STATE_SCRIPT sh <pid>`: "running" or "gone". A killed process its parent has not reaped yet
36
+ * is a zombie, which kill -0 still finds; it has ended, so its /proc state (Z, or X) reads gone, and any other state
37
+ * running. Its state is read first, in one read, so a reap during the probe never reads as running; where there is no
38
+ * state to read (no /proc, a status hidden, or the process already gone), kill -0 answers.
39
+ */
40
+ export declare const PID_STATE_SCRIPT = "st=$(sed -n \"s/^State:[[:space:]]*\\([A-Z]\\).*/\\1/p\" \"/proc/$1/status\" 2>/dev/null); case \"$st\" in Z|X) echo gone ;; ?) echo running ;; *) if kill -0 \"$1\" 2>/dev/null; then echo running; else echo gone; fi ;; esac";
34
41
  /**
35
42
  * Why `got` is not `sent`, in words, or undefined when they are the same bytes. `way` is where they went ("on stdout");
36
43
  * the first byte that differs is named, and the usual ways an exec mangles bytes are named for what they are.
@@ -21,6 +21,13 @@ const DEFAULT_LARGE_MS = 180_000;
21
21
  const WRITE_CHUNK = 256 * 1024;
22
22
  /** How long stdout-live watches, after "early", that stdout stays open and wait() has no answer. */
23
23
  const LIVE_GRACE_MS = 1_000;
24
+ /**
25
+ * kill's probe, `sh -c PID_STATE_SCRIPT sh <pid>`: "running" or "gone". A killed process its parent has not reaped yet
26
+ * is a zombie, which kill -0 still finds; it has ended, so its /proc state (Z, or X) reads gone, and any other state
27
+ * running. Its state is read first, in one read, so a reap during the probe never reads as running; where there is no
28
+ * state to read (no /proc, a status hidden, or the process already gone), kill -0 answers.
29
+ */
30
+ export const PID_STATE_SCRIPT = 'st=$(sed -n "s/^State:[[:space:]]*\\([A-Z]\\).*/\\1/p" "/proc/$1/status" 2>/dev/null); case "$st" in Z|X) echo gone ;; ?) echo running ;; *) if kill -0 "$1" 2>/dev/null; then echo running; else echo gone; fi ;; esac';
24
31
  /** A failed check: its words are the report's. */
25
32
  class Problem extends Error {
26
33
  }
@@ -412,7 +419,7 @@ const CHECKS = {
412
419
  throw new Problem(`kill() did not answer within ${secondsOf(s.stepMs)}`);
413
420
  // wait() after kill, then the machine's own word on the pid, whichever fails first named by the second.
414
421
  const waited = await s.exit(run, s.stepMs, "the killed sleep").then(() => undefined, (error) => error);
415
- const probe = await s.start(["sh", "-c", 'if kill -0 "$1" 2>/dev/null; then echo running; else echo gone; fi', "sh", pid], false);
422
+ const probe = await s.start(["sh", "-c", PID_STATE_SCRIPT, "sh", pid], false);
416
423
  await probe.out.end(s.stepMs, s.signal);
417
424
  await s.exit(probe, s.stepMs, "kill -0");
418
425
  const state = probe.out.bytes().toString("latin1").trim();
@@ -1,5 +1,5 @@
1
1
  // Kernel for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider kernel`. It makes a
2
- // real, billed Kernel browser, so it runs only with AGENTRUN_COMPUTER_LIVE_KERNEL=1 and a key the lead has OKed, under
2
+ // real, billed Kernel browser, so it runs only with AGENTRUN_COMPUTER_LIVE_KERNEL=1 and a key for an account you can bill, under
3
3
  // COMPUTER_KERNEL_API_KEY. The provider reads no environment: this module reads its own COMPUTER_KERNEL_* names (never
4
4
  // KERNEL_API_KEY, which may hold another organization's key) and passes each to create() as its option. The live switch
5
5
  // is checked first, before any other setting is read. The run makes one browser, shared by every case, and deletes it.
@@ -34,7 +34,7 @@ export function conformanceImage() {
34
34
  /** The provider the CLI runs; throws in words without the live switch, or when the key is missing. */
35
35
  export async function createProvider({ env = process.env, ...transport } = {}) {
36
36
  if (env[KERNEL_ENV.live] !== "1") {
37
- throw new Error(`the Kernel conformance module makes a real, billed browser: set ${KERNEL_ENV.live}=1, with a key the lead has OKed, to run it`);
37
+ throw new Error(`the Kernel conformance module makes a real, billed browser: set ${KERNEL_ENV.live}=1, with a key for an account you can bill, to run it`);
38
38
  }
39
39
  return create({ ...settingsFromEnv(env), ...transport });
40
40
  }
@@ -39,7 +39,7 @@ export function settingsFromEnv(env = process.env) {
39
39
  export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
40
40
  function live(env) {
41
41
  if (env[MODAL_ENV.live] !== "1") {
42
- throw new Error(`the Modal conformance module makes real sandboxes: set ${MODAL_ENV.live}=1, with a key the lead has OKed, to run it`);
42
+ throw new Error(`the Modal conformance module makes real sandboxes: set ${MODAL_ENV.live}=1, with a key for an account you can bill, to run it`);
43
43
  }
44
44
  }
45
45
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
@@ -1,5 +1,5 @@
1
1
  // Orgo for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider orgo [--image <template>]`.
2
- // It makes real Orgo desktops, so it runs only with AGENTRUN_COMPUTER_LIVE_ORGO=1 and a key the lead has OKed, under
2
+ // It makes real Orgo desktops, so it runs only with AGENTRUN_COMPUTER_LIVE_ORGO=1 and a key for an account you can bill, under
3
3
  // COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names, or the key's account's one
4
4
  // workspace when it names none. The live switch is checked first, before any other setting is read.
5
5
  //
@@ -36,7 +36,7 @@ export const conformanceNotes = [
36
36
  ];
37
37
  function live(env) {
38
38
  if (env[ORGO_ENV.live] !== "1") {
39
- throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key the lead has OKed, to run it`);
39
+ throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key for an account you can bill, to run it`);
40
40
  }
41
41
  }
42
42
  /** The desktop COMPUTER_ORGO_OS names, linux when it names none; a throw in words for any other. */
package/dist/daytona.d.ts CHANGED
@@ -62,11 +62,6 @@ export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "de
62
62
  export declare function create(options: DaytonaProviderOptions): DaytonaProvider;
63
63
  /** The conformance CLI's module for Daytona: the run's idle stop and auto-delete, its snapshot, notes and drifted twin. */
64
64
  export declare const conformance: () => Promise<typeof import("./conformance/daytona.js")>;
65
- /**
66
- * Daytona's own path sockets outside /run: its D-Bus session bus, /tmp/dbus-<10 characters> (the live baseline's
67
- * isolation.vendor-agent connected to /tmp/dbus-Y8OW6E3FDx as the tool user). Create closes them to the tool user.
68
- */
69
- export declare const DAYTONA_SOCKETS: readonly string[];
70
65
  /**
71
66
  * Computers that are Daytona sandboxes, on the shared adapter. A spec's image is a Daytona snapshot (its id or name),
72
67
  * which gives the class and the size; "default" is Daytona's default snapshot. See the README's Daytona section for
package/dist/daytona.js CHANGED
@@ -5,14 +5,14 @@
5
5
  // Every Daytona fact used here is cited in the README's Daytona section.
6
6
  import { randomBytes } from "node:crypto";
7
7
  import { PassThrough } from "node:stream";
8
- import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, DAYTONA_NO_ARCHIL, daytonaGpu, daytonaGpuSnapshot } from "./descriptors/daytona.js";
8
+ import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_NO_ARCHIL, daytonaGpuSnapshot } from "./descriptors/daytona.js";
9
9
  import { COMPUTER_LABEL } from "./drift.js";
10
10
  import { HostError } from "./host.js";
11
11
  import { HostedProvider, timeoutsOf } from "./hosted/provider.js";
12
12
  import { boundOf, orThrow, pause as sleep } from "./hosted/process.js";
13
13
  import { allPages, jsonOf, rest } from "./hosted/rest.js";
14
14
  import { shellLine } from "./hosted/scripts.js";
15
- import { dateOf, isWhole } from "./hosted/values.js";
15
+ import { dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
16
16
  import { MAX_LINE_BYTES } from "./protocol.js";
17
17
  import { checkGpu } from "./provider.js";
18
18
  import { ok, vendorFail } from "./result.js";
@@ -38,11 +38,6 @@ const MAX_PAGES = 1000;
38
38
  const MAX_LIFETIME_MS = 30 * 24 * 60 * 60 * 1000;
39
39
  /** The toolbox's port, on every interface of the sandbox (daytonaio/daytona@b5a5d9e7 apps/daemon/pkg/toolbox/config/config.go:6). */
40
40
  const TOOLBOX_PORT = 2280;
41
- /**
42
- * Daytona's own path sockets outside /run: its D-Bus session bus, /tmp/dbus-<10 characters> (the live baseline's
43
- * isolation.vendor-agent connected to /tmp/dbus-Y8OW6E3FDx as the tool user). Create closes them to the tool user.
44
- */
45
- export const DAYTONA_SOCKETS = ["/tmp/dbus-*"];
46
41
  const QUOTA = /quota|capacity|limit exceeded|too many/i;
47
42
  const STARTING = new Set(["creating", "restoring", "starting", "pending_build", "building_snapshot", "pulling_snapshot", "resizing", "snapshotting", "forking", "resuming", "unknown"]);
48
43
  const GONE = new Set(["destroyed", "destroying"]);
@@ -121,8 +116,8 @@ class DaytonaHost {
121
116
  // daemon child: Daytona's toolbox daemon is the sandbox's first process, and init a command started through it.
122
117
  // maxLifetimeMs is the 30 days check() has always given; Daytona's TTL is in whole minutes and documents no cap of
123
118
  // its own. The toolbox listens on 2280 on every interface and runs commands for whoever reaches it, so init starts
124
- // with --own-network, and network none is all a computer takes. Its D-Bus session bus in /tmp, which no network
125
- // namespace cuts, is closed to the tool user before init starts (vendorSockets).
119
+ // with --own-network, and network none is all a computer takes. Its D-Bus session bus in /tmp (/tmp/dbus-*), which
120
+ // no network namespace cuts, is closed to the tool user before init starts, as on every child host.
126
121
  this.facts = {
127
122
  daemon: "child",
128
123
  isolation: options.sandboxClass === "linux-vm" ? "vm" : "container",
@@ -130,26 +125,22 @@ class DaytonaHost {
130
125
  maxLifetimeMs: MAX_LIFETIME_MS,
131
126
  arch: options.arch,
132
127
  vendorAgentPorts: [TOOLBOX_PORT],
133
- vendorSockets: [...DAYTONA_SOCKETS],
134
- // get reads sb.gpu and sb.gpuType back: a sandbox with none reads none.
135
- gpuReadBack: true,
136
- // A GPU sandbox's limits are stated in gpu: its stop deletes it, it runs in region earth, its size is per GPU.
137
- gpu: daytonaGpu(options.gpu.snapshot === DAYTONA_GPU_SNAPSHOT ? undefined : options.gpu.snapshot),
138
128
  };
139
129
  }
140
130
  /**
141
- * A snapshot name has no control characters; a GPU computer is made from the provider's GPU snapshot, which a spec
142
- * names, or Daytona's default, never another. No call.
131
+ * A snapshot name has no control characters, and its size is the snapshot's; a GPU computer is made from the
132
+ * provider's GPU snapshot, which a spec names, or Daytona's default, never another. No call.
143
133
  */
144
134
  check(given) {
145
135
  const { image } = given;
146
- const refusals = [];
136
+ const refusals = sizeRefusals(given, "a Daytona computer", "snapshot");
147
137
  if (typeof image === "string" && image !== "" && image.trim() === "")
148
138
  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` });
149
139
  else if (typeof image === "string" && /[\x01-\x1f]/.test(image))
150
140
  refusals.push({ field: "image", message: "a snapshot name has no control characters" });
151
141
  const gpuSnapshot = this.#gpu.snapshot;
152
- if (given.gpu !== undefined && checkGpu(given.gpu, this.facts, given.mount).length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== gpuSnapshot) {
142
+ const offered = { gpu: { ...DAYTONA_GPU, types: [this.#gpu.type], max: this.#gpu.count } };
143
+ if (given.gpu !== undefined && checkGpu(given.gpu, offered, given.mount).length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== gpuSnapshot) {
153
144
  refusals.push({
154
145
  field: "image",
155
146
  message: `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`,
@@ -157,7 +148,7 @@ class DaytonaHost {
157
148
  }
158
149
  return refusals;
159
150
  }
160
- /** A sandbox as the adapter reads a machine: its state, labels, start, end, GPUs, and Daytona's words for a failure. */
151
+ /** A sandbox as the adapter reads a machine: its state, labels, start, end, and Daytona's words for a failure. */
161
152
  #machineOf(sb) {
162
153
  const endsAt = dateOf(sb.autoDestroyAt);
163
154
  const made = dateOf(sb.createdAt);
@@ -167,7 +158,6 @@ class DaytonaHost {
167
158
  state: stateOf(sb),
168
159
  ...(made ? { createdAt: made } : {}),
169
160
  ...(endsAt ? { endsAt } : {}),
170
- ...(isWhole(sb.gpu) && sb.gpu > 0 ? { gpu: { type: String(sb.gpuType), count: sb.gpu } } : {}),
171
161
  // A failed sandbox always carries a why, Daytona's or ours, so create stops on it as vendor, never as gone.
172
162
  ...(typeof sb.errorReason === "string" && sb.errorReason !== "" ? { why: sb.errorReason } : FAILED.has(sb.state ?? "") ? { why: `Daytona reads the sandbox ${sb.state}, with no reason given` } : {}),
173
163
  };
@@ -176,7 +166,8 @@ class DaytonaHost {
176
166
  * POST /sandbox: its native name and labels, the lifetime as a TTL in whole minutes, the idle stop and auto-delete,
177
167
  * no public port, and network none (block-all), the one network check() takes. A GPU
178
168
  * computer is made from the GPU snapshot in region earth, ephemeral (its stop deletes it). Never cancelled: the adapter
179
- * races it, and deletes by name one whose answer never comes. A name Daytona already holds (409) made nothing: exists.
169
+ * races it, and deletes by name one whose answer never comes. A name Daytona already holds (409) made nothing: exists,
170
+ * and the adapter adopts the sandbox the name lists, as a retry does.
180
171
  */
181
172
  async create(req, ctx) {
182
173
  const gpu = req.gpu !== undefined;
@@ -189,19 +180,17 @@ class DaytonaHost {
189
180
  public: false,
190
181
  // A GPU sandbox runs in region earth alone, whatever the provider's target.
191
182
  ...(gpu ? { target: DAYTONA_GPU_REGION } : this.#target === undefined ? {} : { target: this.#target }),
192
- ttlMinutes: Math.max(1, Math.ceil((req.lifetimeMs ?? 0) / 60_000)),
183
+ ttlMinutes: Math.max(1, Math.ceil(req.lifetimeMs / 60_000)),
193
184
  autoStopInterval: this.#autoStop,
194
185
  // A GPU sandbox's stop deletes it (no pause, no snapshot): autoDeleteInterval 0 is Daytona's ephemeral (its SDK's
195
186
  // ephemeral sets it; CreateSandbox has no ephemeral field).
196
187
  autoDeleteInterval: gpu ? 0 : this.#autoDelete,
197
- networkBlockAll: req.network === "none",
188
+ networkBlockAll: !req.egress,
198
189
  // No resource field (cpu, gpu, gpuType, memory, disk): a snapshot carries its own, and Daytona refuses a create that
199
190
  // names a snapshot and sends any (400 "Cannot specify Sandbox resources when using a snapshot"). A GPU computer's
200
- // GPU is the snapshot's, held in the read-back.
191
+ // GPU is the snapshot's, held by the adapter's GPU label.
201
192
  };
202
- const posted = await this.#rest.json("POST", sandboxUrl(this.#rest), { json: body, timeoutMs: ctx.timeoutMs });
203
- if (!posted.ok && /: 409 /.test(posted.error.message))
204
- throw new HostError("exists", `Daytona already has a sandbox named ${req.name}: ${posted.error.message}`);
193
+ const posted = await this.#rest.json("POST", sandboxUrl(this.#rest), { json: body, timeoutMs: ctx.timeoutMs, named: true });
205
194
  const id = orThrow(posted)?.id;
206
195
  if (typeof id !== "string" || id === "")
207
196
  throw new Error("POST /sandbox: no sandbox id in the answer");
@@ -66,9 +66,11 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
66
66
  */
67
67
  readonly unmounted?: Unmounted;
68
68
  /**
69
- * The network forms its computers make, as its providers' capabilities().network declare them: ["none"], a remote
70
- * computer whose programs run in a network of their own; ["open"], the vendor's own network, which no allowlist of
71
- * this server reaches; Docker's makes all three. A provider of several configurations declares every form they make.
69
+ * The network forms its computers make and enforce, as its providers' capabilities().network declare them: ["none"],
70
+ * a remote computer whose programs run in a network of their own and nothing else; ["open"], the vendor's own network,
71
+ * which no allowlist of this server reaches; a hosted computer through init's egress proxy (hosted/network.ts) makes
72
+ * all three, as Docker's does. A form not declared is refused at check, never widened or narrowed to another. A
73
+ * provider of several configurations declares every form they make.
72
74
  */
73
75
  readonly network: readonly NetworkForm[];
74
76
  /**
@@ -1,10 +1,5 @@
1
- /** Agent37's plain Linux template: a sandbox when its setting names no image. */
1
+ /** Agent37's plain Linux template, a spec's image for a caller of the provider that names its own. */
2
2
  export declare const AGENT37_BASE_TEMPLATE = "agent37-base";
3
- /**
4
- * Our box image (box/Dockerfile, its desktop included) as a template of the key's own workspace, which box/build-agent37.mjs builds
5
- * and publishes under this one name: a desktop when its setting names no image.
6
- */
7
- export declare const AGENT37_BOX_TEMPLATE = "agentrun-box";
8
3
  export declare const AGENT37: {
9
4
  readonly id: "agent37";
10
5
  readonly label: "Agent37";
@@ -19,7 +14,7 @@ export declare const AGENT37: {
19
14
  }];
20
15
  readonly metered: true;
21
16
  readonly mounts: readonly ["archil"];
22
- readonly network: readonly ["none"];
17
+ readonly network: readonly ["none", "open", "allow"];
23
18
  readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
24
19
  readonly options: {
25
20
  readonly kind: "desktop";
@@ -33,9 +28,6 @@ export declare const AGENT37: {
33
28
  };
34
29
  readonly image?: string;
35
30
  }];
36
- readonly defaultImage: {
37
- readonly sandbox: "agent37-base";
38
- readonly desktop: "agentrun-box";
39
- };
31
+ readonly prepareImage: true;
40
32
  readonly load: () => Promise<typeof import("../agent37.js")>;
41
33
  };
@@ -1,14 +1,10 @@
1
1
  // Agent37's descriptor: a Linux sandbox or a Linux desktop on an Agent37 instance (a VM by default), the run's folder on
2
- // an Archil disk. The desktop starts from our box image built as a workspace template (box/build-agent37.mjs).
2
+ // an Archil disk. Both start from our box image, which its prepareImage() registers in the key's own workspace from the
3
+ // public image the release publishes (box-image.ts).
3
4
  import { defineProvider } from "../descriptor.js";
4
5
  import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
5
- /** Agent37's plain Linux template: a sandbox when its setting names no image. */
6
+ /** Agent37's plain Linux template, a spec's image for a caller of the provider that names its own. */
6
7
  export const AGENT37_BASE_TEMPLATE = "agent37-base";
7
- /**
8
- * Our box image (box/Dockerfile, its desktop included) as a template of the key's own workspace, which box/build-agent37.mjs builds
9
- * and publishes under this one name: a desktop when its setting names no image.
10
- */
11
- export const AGENT37_BOX_TEMPLATE = "agentrun-box";
12
8
  export const AGENT37 = defineProvider({
13
9
  id: "agent37",
14
10
  label: "Agent37",
@@ -19,10 +15,13 @@ export const AGENT37 = defineProvider({
19
15
  ],
20
16
  metered: true,
21
17
  mounts: ["archil"],
22
- // None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
23
- network: ["none"],
18
+ // None: its programs run in a network of their own, their loopback alone (isolation.ts), and the instance is made
19
+ // deny-all. Open and a list: the instance is made allow-all, and its programs' one way out is init's egress proxy,
20
+ // which reaches the public internet alone, and with a list its hosts alone (hosted/network.ts).
21
+ network: ["none", "open", "allow"],
24
22
  // Each configuration built by its own create() options: kind linux is the provider's default.
25
23
  capabilities: [SANDBOX, { ...LINUX_DESKTOP, options: { kind: "desktop" } }],
26
- defaultImage: { sandbox: AGENT37_BASE_TEMPLATE, desktop: AGENT37_BOX_TEMPLATE },
24
+ // No default image: every computer starts from the box template its prepareImage() registers (agentrun-box-<hash>).
25
+ prepareImage: true,
27
26
  load: () => import("../agent37.js"),
28
27
  });
@@ -64,7 +64,7 @@ export declare const DAYTONA: {
64
64
  readonly unmounted: {
65
65
  readonly archil: "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
66
66
  };
67
- readonly network: readonly ["none"];
67
+ readonly network: readonly ["none", "open", "allow"];
68
68
  readonly capabilities: readonly [{
69
69
  readonly gpu: Readonly<GpuCapability>;
70
70
  readonly kind: import("../protocol.js").ComputerKind;
@@ -74,8 +74,11 @@ export const DAYTONA = defineProvider({
74
74
  // no linux-vm class to try instead. An Archil mount is refused in these words, before any request.
75
75
  mounts: [],
76
76
  unmounted: { archil: DAYTONA_NO_ARCHIL },
77
- // None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
78
- network: ["none"],
77
+ // None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
78
+ // networkBlockAll. Open and a list: the sandbox is not blocked (the account's tier may still limit where it goes), and
79
+ // its programs' one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts
80
+ // alone (hosted/network.ts).
81
+ network: ["none", "open", "allow"],
79
82
  // A linux computer, with GPUs when asked.
80
83
  capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
81
84
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
@@ -5,7 +5,19 @@ export declare const DOCKER: {
5
5
  readonly metered: false;
6
6
  readonly mounts: readonly ["bind"];
7
7
  readonly network: readonly ["none", "open", "allow"];
8
- readonly capabilities: readonly [import("../kinds.js").KindCapabilities, import("../kinds.js").KindCapabilities];
8
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
9
+ readonly options: {
10
+ readonly desktop: {};
11
+ };
12
+ readonly kind: import("../protocol.js").ComputerKind;
13
+ readonly groups: import("../protocol.js").Group[];
14
+ readonly gpu?: import("../provider.js").GpuCapability;
15
+ readonly persistence?: {
16
+ keepsState: true;
17
+ resume: boolean;
18
+ };
19
+ readonly image?: string;
20
+ }];
9
21
  readonly prepareImage: true;
10
22
  readonly local: true;
11
23
  readonly load: () => Promise<typeof import("../docker.js")>;
@@ -9,7 +9,9 @@ export const DOCKER = defineProvider({
9
9
  mounts: ["bind"],
10
10
  // None, open, or an allowlist through the server's egress proxy.
11
11
  network: ["none", "open", "allow"],
12
- capabilities: [SANDBOX, LINUX_DESKTOP],
12
+ // Each configuration built by its own create() options: the desktop's start the X server (desktop: {}); without them
13
+ // the provider makes a linux computer, with no screen and no apps.
14
+ capabilities: [SANDBOX, { ...LINUX_DESKTOP, options: { desktop: {} } }],
13
15
  // No default image: the server makes one from the provider's recipe (prepareImage) before the first create.
14
16
  prepareImage: true,
15
17
  local: true,
@@ -1,7 +1,3 @@
1
- /** E2B Desktop's template: a desktop computer when its setting names no image. */
2
- export declare const E2B_DESKTOP_TEMPLATE = "desktop";
3
- /** E2B's base template: a sandbox when its setting names no image. */
4
- export declare const E2B_BASE_TEMPLATE = "base";
5
1
  export declare const E2B: {
6
2
  readonly id: "e2b";
7
3
  readonly label: "E2B";
@@ -12,11 +8,8 @@ export declare const E2B: {
12
8
  }];
13
9
  readonly metered: true;
14
10
  readonly mounts: readonly ["archil"];
15
- readonly network: readonly ["none"];
11
+ readonly network: readonly ["none", "open", "allow"];
16
12
  readonly capabilities: readonly [import("../kinds.js").KindCapabilities, import("../kinds.js").KindCapabilities];
17
- readonly defaultImage: {
18
- readonly sandbox: "base";
19
- readonly desktop: "desktop";
20
- };
13
+ readonly prepareImage: true;
21
14
  readonly load: () => Promise<typeof import("../e2b.js")>;
22
15
  };
@@ -1,19 +1,19 @@
1
- // E2B's descriptor: a sandbox (the base template) or a desktop (E2B Desktop), the run's folder on an Archil disk.
1
+ // E2B's descriptor: a sandbox or a desktop, the run's folder on an Archil disk. Both start from our box template, the
2
+ // public E2B template its prepareImage() answers (box-image.ts boxE2bTemplate), which has Archil's client and a desktop.
2
3
  import { defineProvider } from "../descriptor.js";
3
4
  import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
4
- /** E2B Desktop's template: a desktop computer when its setting names no image. */
5
- export const E2B_DESKTOP_TEMPLATE = "desktop";
6
- /** E2B's base template: a sandbox when its setting names no image. */
7
- export const E2B_BASE_TEMPLATE = "base";
8
5
  export const E2B = defineProvider({
9
6
  id: "e2b",
10
7
  label: "E2B",
11
8
  keys: [{ name: "E2B_API_KEY", option: "apiKey", required: true }],
12
9
  metered: true,
13
10
  mounts: ["archil"],
14
- // None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
15
- network: ["none"],
11
+ // None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
12
+ // no internet access. Open and a list: the sandbox gets internet access, and its programs' one way out is init's egress
13
+ // proxy, which reaches the public internet alone, and with a list its hosts alone (hosted/network.ts).
14
+ network: ["none", "open", "allow"],
16
15
  capabilities: [SANDBOX, LINUX_DESKTOP],
17
- defaultImage: { sandbox: E2B_BASE_TEMPLATE, desktop: E2B_DESKTOP_TEMPLATE },
16
+ // No default image: every computer, sandbox or desktop, starts from the box template its prepareImage() answers.
17
+ prepareImage: true,
18
18
  load: () => import("../e2b.js"),
19
19
  });
@@ -15,7 +15,19 @@ export declare const DESCRIPTORS: readonly [{
15
15
  readonly metered: false;
16
16
  readonly mounts: readonly ["bind"];
17
17
  readonly network: readonly ["none", "open", "allow"];
18
- readonly capabilities: readonly [import("../kinds.js").KindCapabilities, import("../kinds.js").KindCapabilities];
18
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
19
+ readonly options: {
20
+ readonly desktop: {};
21
+ };
22
+ readonly kind: import("../protocol.js").ComputerKind;
23
+ readonly groups: import("../protocol.js").Group[];
24
+ readonly gpu?: import("../provider.js").GpuCapability;
25
+ readonly persistence?: {
26
+ keepsState: true;
27
+ resume: boolean;
28
+ };
29
+ readonly image?: string;
30
+ }];
19
31
  readonly prepareImage: true;
20
32
  readonly local: true;
21
33
  readonly load: () => Promise<typeof import("../docker.js")>;
@@ -40,7 +52,7 @@ export declare const DESCRIPTORS: readonly [{
40
52
  readonly unmounted: {
41
53
  readonly archil: "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
42
54
  };
43
- readonly network: readonly ["none"];
55
+ readonly network: readonly ["none", "open", "allow"];
44
56
  readonly capabilities: readonly [{
45
57
  readonly gpu: Readonly<import("../provider.js").GpuCapability>;
46
58
  readonly kind: import("../protocol.js").ComputerKind;
@@ -76,7 +88,7 @@ export declare const DESCRIPTORS: readonly [{
76
88
  }];
77
89
  readonly metered: true;
78
90
  readonly mounts: readonly ["archil"];
79
- readonly network: readonly ["none"];
91
+ readonly network: readonly ["none", "open", "allow"];
80
92
  readonly capabilities: readonly [{
81
93
  readonly gpu: Readonly<import("../provider.js").GpuCapability>;
82
94
  readonly kind: import("../protocol.js").ComputerKind;
@@ -88,9 +100,7 @@ export declare const DESCRIPTORS: readonly [{
88
100
  readonly image?: string;
89
101
  readonly options?: Readonly<Record<string, unknown>>;
90
102
  }];
91
- readonly defaultImage: {
92
- readonly sandbox: "debian:bookworm-slim";
93
- };
103
+ readonly prepareImage: true;
94
104
  readonly load: () => Promise<typeof import("../modal.js")>;
95
105
  }, {
96
106
  readonly id: "e2b";
@@ -102,12 +112,9 @@ export declare const DESCRIPTORS: readonly [{
102
112
  }];
103
113
  readonly metered: true;
104
114
  readonly mounts: readonly ["archil"];
105
- readonly network: readonly ["none"];
115
+ readonly network: readonly ["none", "open", "allow"];
106
116
  readonly capabilities: readonly [import("../kinds.js").KindCapabilities, import("../kinds.js").KindCapabilities];
107
- readonly defaultImage: {
108
- readonly sandbox: "base";
109
- readonly desktop: "desktop";
110
- };
117
+ readonly prepareImage: true;
111
118
  readonly load: () => Promise<typeof import("../e2b.js")>;
112
119
  }, {
113
120
  readonly id: "agent37";
@@ -123,7 +130,7 @@ export declare const DESCRIPTORS: readonly [{
123
130
  }];
124
131
  readonly metered: true;
125
132
  readonly mounts: readonly ["archil"];
126
- readonly network: readonly ["none"];
133
+ readonly network: readonly ["none", "open", "allow"];
127
134
  readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
128
135
  readonly options: {
129
136
  readonly kind: "desktop";
@@ -137,10 +144,7 @@ export declare const DESCRIPTORS: readonly [{
137
144
  };
138
145
  readonly image?: string;
139
146
  }];
140
- readonly defaultImage: {
141
- readonly sandbox: "agent37-base";
142
- readonly desktop: "agentrun-box";
143
- };
147
+ readonly prepareImage: true;
144
148
  readonly load: () => Promise<typeof import("../agent37.js")>;
145
149
  }, {
146
150
  readonly id: "orgo";
@@ -282,10 +286,8 @@ export declare const DESCRIPTORS: readonly [{
282
286
  readonly load: () => Promise<typeof import("../local-chrome.js")>;
283
287
  }];
284
288
  export { AGENT37, BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
285
- export { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "./agent37.js";
289
+ export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
286
290
  export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
287
- export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
288
- export { MODAL_DEFAULT_IMAGE } from "./modal.js";
289
291
  export { ORGO_BASE_IMAGE } from "./orgo.js";
290
292
  export { PHONE_GROUPS, PHONE_IMAGE } from "./phone-harness.js";
291
293
  export { BROWSER_IMAGE, LINUX_DESKTOP, SANDBOX } from "./shared.js";
@@ -12,10 +12,8 @@ import { ORGO } from "./orgo.js";
12
12
  import { PHONE_HARNESS } from "./phone-harness.js";
13
13
  export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL];
14
14
  export { AGENT37, BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
15
- export { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "./agent37.js";
15
+ export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
16
16
  export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
17
- export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
18
- export { MODAL_DEFAULT_IMAGE } from "./modal.js";
19
17
  export { ORGO_BASE_IMAGE } from "./orgo.js";
20
18
  export { PHONE_GROUPS, PHONE_IMAGE } from "./phone-harness.js";
21
19
  export { BROWSER_IMAGE, LINUX_DESKTOP, SANDBOX } from "./shared.js";
@@ -1,6 +1,4 @@
1
1
  import type { GpuCapability } from "../provider.js";
2
- /** The image a Modal computer starts from when its setting names none. */
3
- export declare const MODAL_DEFAULT_IMAGE = "debian:bookworm-slim";
4
2
  /**
5
3
  * The GPU types Modal takes, by its own names (guide/gpu, 11-10): "A100" is the 40 GB one, "A100-40GB" its explicit
6
4
  * name. Its "H100!" and "B200+" variants (no upgrade to an H200; a B200 or B300) are not offered: what a computer gets
@@ -35,7 +33,7 @@ export declare const MODAL: {
35
33
  }];
36
34
  readonly metered: true;
37
35
  readonly mounts: readonly ["archil"];
38
- readonly network: readonly ["none"];
36
+ readonly network: readonly ["none", "open", "allow"];
39
37
  readonly capabilities: readonly [{
40
38
  readonly gpu: Readonly<GpuCapability>;
41
39
  readonly kind: import("../protocol.js").ComputerKind;
@@ -47,8 +45,6 @@ export declare const MODAL: {
47
45
  readonly image?: string;
48
46
  readonly options?: Readonly<Record<string, unknown>>;
49
47
  }];
50
- readonly defaultImage: {
51
- readonly sandbox: "debian:bookworm-slim";
52
- };
48
+ readonly prepareImage: true;
53
49
  readonly load: () => Promise<typeof import("../modal.js")>;
54
50
  };