@parcha/agentrun-computer 0.1.0-beta.40 → 0.1.0-beta.41

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 (48) hide show
  1. package/README.md +31 -14
  2. package/box/Dockerfile +6 -4
  3. package/box/README.md +8 -0
  4. package/box/build-daytona.py +3 -1
  5. package/box/install.sh +68 -7
  6. package/dist/attach.d.ts +46 -1
  7. package/dist/attach.js +48 -4
  8. package/dist/box-image.d.ts +2 -0
  9. package/dist/box-image.js +10 -0
  10. package/dist/computerd-linux-amd64 +0 -0
  11. package/dist/computerd-linux-arm64 +0 -0
  12. package/dist/computerd.json +2 -2
  13. package/dist/conformance/cases/provider.js +42 -26
  14. package/dist/conformance/cli.js +4 -1
  15. package/dist/conformance/daytona.d.ts +25 -0
  16. package/dist/conformance/daytona.js +26 -1
  17. package/dist/conformance/exec-stream.js +14 -6
  18. package/dist/conformance/runner.js +8 -4
  19. package/dist/conformance/sweep.d.ts +7 -2
  20. package/dist/conformance/sweep.js +17 -7
  21. package/dist/conformance/types.d.ts +21 -0
  22. package/dist/daytona.d.ts +8 -1
  23. package/dist/daytona.js +124 -101
  24. package/dist/descriptor.d.ts +22 -1
  25. package/dist/descriptor.js +18 -0
  26. package/dist/descriptors/daytona.d.ts +12 -3
  27. package/dist/descriptors/daytona.js +15 -7
  28. package/dist/descriptors/index.d.ts +8 -1
  29. package/dist/e2b.js +1 -1
  30. package/dist/host.d.ts +61 -37
  31. package/dist/hosted/framed-exec.d.ts +8 -19
  32. package/dist/hosted/framed-exec.js +21 -87
  33. package/dist/hosted/process.d.ts +2 -0
  34. package/dist/hosted/process.js +9 -2
  35. package/dist/hosted/provider.d.ts +41 -4
  36. package/dist/hosted/provider.js +289 -115
  37. package/dist/hosted/rest.d.ts +19 -0
  38. package/dist/hosted/rest.js +76 -0
  39. package/dist/hosted/scripts.d.ts +50 -0
  40. package/dist/hosted/scripts.js +116 -1
  41. package/dist/hosted/ssh-exec.d.ts +7 -6
  42. package/dist/hosted/ssh-exec.js +35 -52
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +2 -2
  45. package/dist/kinds.d.ts +2 -0
  46. package/dist/modal.js +21 -8
  47. package/dist/providers.d.ts +4 -2
  48. package/package.json +1 -1
@@ -1,5 +1,10 @@
1
1
  import { type DaytonaProvider, type DaytonaProviderOptions } from "../daytona.js";
2
2
  import type { MachineHost } from "../host.js";
3
+ import type { MountKind } from "../mount.js";
4
+ import { type ArchilRunFolderOptions } from "./archil.js";
5
+ import type { RunFolder } from "./types.js";
6
+ /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
7
+ export { ARCHIL_ENV } from "./archil.js";
3
8
  /** The environment this module reads, by name, each for the option its comment names. */
4
9
  export declare const DAYTONA_ENV: {
5
10
  /** apiKey, required: the Daytona API key. */
@@ -20,6 +25,11 @@ export declare const DAYTONA_ENV: {
20
25
  readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
21
26
  /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
22
27
  readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
28
+ /**
29
+ * archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
30
+ * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
31
+ */
32
+ readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
23
33
  };
24
34
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
25
35
  export declare const ENV: {
@@ -41,6 +51,11 @@ export declare const ENV: {
41
51
  readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
42
52
  /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
43
53
  readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
54
+ /**
55
+ * archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
56
+ * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
57
+ */
58
+ readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
44
59
  };
45
60
  /**
46
61
  * The provider's options this module reads from env, each only when its name is set; throws in words without the key,
@@ -65,6 +80,16 @@ export interface DaytonaModuleOptions {
65
80
  }
66
81
  /** The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT, or Daytona's default snapshot. */
67
82
  export declare function conformanceImage({ env }?: Pick<DaytonaModuleOptions, "env">): string;
83
+ /**
84
+ * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
85
+ * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
86
+ * COMPUTER_DAYTONA_ARCHIL_EGRESS names the target's relay, since the provider takes an Archil mount only then; none
87
+ * otherwise, and none for a bind, which a remote computer cannot take.
88
+ */
89
+ export declare function mountFor(kind: MountKind, { env, archil }?: {
90
+ env?: Record<string, string | undefined>;
91
+ archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
92
+ }): Promise<RunFolder | undefined>;
68
93
  /** The provider the CLI runs; throws in words when a setting is missing or wrong. */
69
94
  export declare function createProvider(options?: DaytonaModuleOptions): DaytonaProvider;
70
95
  /**
@@ -3,10 +3,15 @@
3
3
  // another organization's key on a host that runs other Daytona work) and passes each to create() as its option, the key
4
4
  // read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
5
5
  // after 30 minutes with no outside activity and deletes it as soon as it stops (see conformanceNotes). The live sweep
6
- // (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing.
6
+ // (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing. The mount cases run on a
7
+ // self-hosted Daytona target alone: COMPUTER_DAYTONA_ARCHIL_EGRESS names its Archil egress relay, and the
8
+ // COMPUTER_ARCHIL_* settings the disk (mountFor).
7
9
  import { create } from "../daytona.js";
8
10
  import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
11
+ import { archilRunFolder, archilSettings } from "./archil.js";
9
12
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
13
+ /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
14
+ export { ARCHIL_ENV } from "./archil.js";
10
15
  /** The environment this module reads, by name, each for the option its comment names. */
11
16
  export const DAYTONA_ENV = {
12
17
  /** apiKey, required: the Daytona API key. */
@@ -27,6 +32,11 @@ export const DAYTONA_ENV = {
27
32
  snapshot: "COMPUTER_DAYTONA_SNAPSHOT",
28
33
  /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
29
34
  gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT",
35
+ /**
36
+ * archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
37
+ * provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
38
+ */
39
+ archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS",
30
40
  };
31
41
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
32
42
  export const ENV = DAYTONA_ENV;
@@ -46,6 +56,7 @@ export function settingsFromEnv(env = process.env) {
46
56
  const sandboxClass = named(DAYTONA_ENV.sandboxClass);
47
57
  const user = named(DAYTONA_ENV.user);
48
58
  const gpuSnapshot = named(DAYTONA_ENV.gpuSnapshot);
59
+ const archilEgress = named(DAYTONA_ENV.archilEgress);
49
60
  return {
50
61
  apiKey,
51
62
  ...(url ? { apiUrl: url.value } : {}),
@@ -58,6 +69,8 @@ export function settingsFromEnv(env = process.env) {
58
69
  ...(user ? { daemonUser: user.value } : {}),
59
70
  // create() refuses a name that is not one of ours in words.
60
71
  ...(gpuSnapshot ? { gpuSnapshot: gpuSnapshot.value } : {}),
72
+ // create() refuses one of another shape in words.
73
+ ...(archilEgress ? { archilEgress: archilEgress.value } : {}),
61
74
  };
62
75
  }
63
76
  /** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
@@ -84,6 +97,18 @@ function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote }) {
84
97
  export function conformanceImage({ env = process.env } = {}) {
85
98
  return env[DAYTONA_ENV.snapshot] || DAYTONA_DEFAULT_SNAPSHOT;
86
99
  }
100
+ /**
101
+ * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
102
+ * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
103
+ * COMPUTER_DAYTONA_ARCHIL_EGRESS names the target's relay, since the provider takes an Archil mount only then; none
104
+ * otherwise, and none for a bind, which a remote computer cannot take.
105
+ */
106
+ export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
107
+ if (kind !== "archil" || !env[DAYTONA_ENV.archilEgress])
108
+ return undefined;
109
+ const settings = archilSettings(env);
110
+ return settings === undefined ? undefined : archilRunFolder({ ...settings, ...archil });
111
+ }
87
112
  /** The provider the CLI runs; throws in words when a setting is missing or wrong. */
88
113
  export function createProvider(options = {}) {
89
114
  return create(optionsOf(options));
@@ -12,7 +12,7 @@
12
12
  // host (root's network namespace, /dev/fuse, the arch, the kernel, the TCP listeners): facts, each with what it means
13
13
  // for the provider, never a pass or a fail of exec.
14
14
  import { createHash, randomBytes } from "node:crypto";
15
- import { words } from "../hosted/process.js";
15
+ import { execOf, words } from "../hosted/process.js";
16
16
  /** The checks, in the order they run. */
17
17
  export const EXEC_STREAM_CHECKS = ["stdout-text", "stdin-text", "large", "stdout-live", "stdin-live", "stdout-unread", "stderr", "exit-code", "kill", "no-timeout"];
18
18
  /** What the capability probe reads, in the order the report gives it. */
@@ -53,7 +53,11 @@ const range = (from, to) => String.fromCodePoint(...Array.from({ length: to - fr
53
53
  */
54
54
  const CODE_POINTS = `\u{feff}${range(0x01, 0x7f)}${range(0x80, 0xff)}ĀſΩЖאعह中文日本語한국어€

�𝄞😀\u{10ffff}éä\u{1f469}‍\u{1f4bb}carriage\rreturn\r\nline`;
55
55
  /** 16 KiB of text of every width (1, 2, 3 and 4 bytes a character), no newline: 64 of them are the 1 MiB line. */
56
- const LONG_PIECE = `${"aé€𝄞".repeat(1638)}abcd`;
56
+ const LONG_UNIT = "aé€𝄞";
57
+ const LONG_UNITS = 1638;
58
+ /** ASCII, so the script writes it as it is. */
59
+ const LONG_TAIL = "abcd";
60
+ const LONG_PIECE = `${LONG_UNIT.repeat(LONG_UNITS)}${LONG_TAIL}`;
57
61
  const LONG_PIECES = 64;
58
62
  /** What stdout-text and stdin-text carry: every class of code point, \r and \r\n, a line of 1 MiB, and a lone \n at the end. */
59
63
  const TEXT = Buffer.from(`${CODE_POINTS}${LONG_PIECE.repeat(LONG_PIECES)}\n`, "utf8");
@@ -239,7 +243,7 @@ class Session {
239
243
  const what = `exec of ${shown(argv)}`;
240
244
  let answer;
241
245
  try {
242
- answer = Promise.resolve(this.#host.exec(this.#machine, argv, { timeoutMs: this.#stepMs, ...(this.#signal ? { signal: this.#signal } : {}) }));
246
+ answer = Promise.resolve(execOf(this.#host)(this.#machine, argv, { timeoutMs: this.#stepMs, ...(this.#signal ? { signal: this.#signal } : {}) }));
243
247
  }
244
248
  catch (error) {
245
249
  throw new Problem(`${what} threw: ${words(error)}`);
@@ -345,10 +349,14 @@ class Deadline {
345
349
  }
346
350
  }
347
351
  const CHECKS = {
348
- /** Text of every kind out, on stdout alone: printf in the machine writes it, the 1 MiB line a piece at a time. */
352
+ /**
353
+ * Text of every kind out, on stdout alone: printf in the machine writes it, the 1 MiB line a piece at a time. Only the
354
+ * piece's short unit crosses argv; sh repeats it, doubling, into the piece, so the command stays far under a vendor's
355
+ * 64 KiB argv cap (Modal's).
356
+ */
349
357
  async "stdout-text"(s) {
350
- const script = `printf "$1"; i=0; while [ "$i" -lt ${LONG_PIECES} ]; do printf "$2"; i=$((i+1)); done; printf '\\n'`;
351
- const run = await s.start(["sh", "-c", script, "sh", printfOf(CODE_POINTS), printfOf(LONG_PIECE)], false);
358
+ const script = `printf "$1"; u=$(printf "$2"); n=${LONG_UNITS}; p=; while [ "$n" -gt 0 ]; do if [ $((n % 2)) -eq 1 ]; then p="$p$u"; fi; u="$u$u"; n=$((n / 2)); done; p="$p"${LONG_TAIL}; i=0; while [ "$i" -lt ${LONG_PIECES} ]; do printf '%s' "$p"; i=$((i+1)); done; printf '\\n'`;
359
+ const run = await s.start(["sh", "-c", script, "sh", printfOf(CODE_POINTS), printfOf(LONG_UNIT)], false);
352
360
  if (!(await run.out.end(s.stepMs, s.signal)))
353
361
  throw new Problem(`stdout of printf did not end within ${secondsOf(s.stepMs)} of its start`);
354
362
  const code = await s.exit(run, s.stepMs, "printf");
@@ -85,7 +85,7 @@ function whenAborted(signal) {
85
85
  */
86
86
  export async function runConformance(provider, options) {
87
87
  // Given no cases, the run takes its computer's suite: a browser's own cases, as the CLI does, else the suite's.
88
- const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu, long = false, concurrency } = options;
88
+ const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, dial, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu, long = false, concurrency } = options;
89
89
  if (kind !== undefined && only !== undefined)
90
90
  throw new TypeError("a run takes kind and only apart: a kind runs its own cases");
91
91
  if (concurrency !== undefined && !(Number.isSafeInteger(concurrency) && concurrency >= 1))
@@ -569,6 +569,10 @@ export async function runConformance(provider, options) {
569
569
  plantedBy.add(got.provider);
570
570
  return got;
571
571
  },
572
+ async dial() {
573
+ t.assert(dial !== undefined, "the provider's machines dial the server, and the run was given no server for them: a conformance module exports dialKit() (ConformanceOptions.dial)");
574
+ return await dial();
575
+ },
572
576
  async runFolder(kind) {
573
577
  const none = `the run was given no run folder for mount kind ${kind}`;
574
578
  if (mountFor === undefined)
@@ -713,7 +717,7 @@ export async function runConformance(provider, options) {
713
717
  for (const what of pending.values()) {
714
718
  report.cleanup.errors.push(`${what} did not settle within ${cleanupTimeoutMs / 1000} s of the run's end: what it makes may be left`);
715
719
  }
716
- await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs);
720
+ await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs, image);
717
721
  }
718
722
  // A Core case skipped for an optional group the computer does not declare, or written for another system, is not part
719
723
  // of Core's verdict.
@@ -729,7 +733,7 @@ export async function runConformance(provider, options) {
729
733
  return report;
730
734
  }
731
735
  /** Sweeps a janitor provider by the run's label, past every deadline, and lists the label to show nothing is left. */
732
- async function cleanup(provider, lifetime, labels, report, deleted, ms) {
736
+ async function cleanup(provider, lifetime, labels, report, deleted, ms, image) {
733
737
  try {
734
738
  if (lifetime === "janitor") {
735
739
  const stop = new AbortController();
@@ -754,7 +758,7 @@ async function cleanup(provider, lifetime, labels, report, deleted, ms) {
754
758
  if (host !== undefined && typeof host.list === "function") {
755
759
  const { sweepMachines } = await import("./sweep.js");
756
760
  const said = [];
757
- const swept = await within(sweepMachines(host, { labels, waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
761
+ const swept = await within(sweepMachines(host, { labels, waitMs: ms, image, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
758
762
  report.cleanup.errors.push(...said.map((words) => `sweep: ${words}`));
759
763
  if (!swept.ok)
760
764
  report.cleanup.errors.push(`sweep: ${swept.error.code}: ${swept.error.message}`);
@@ -20,15 +20,20 @@ export interface SweepMachinesOptions {
20
20
  requestMs?: number;
21
21
  /** One whole listing's bound; default 60 s. */
22
22
  listMs?: number;
23
- /** Told, in words, of a machine not deleted or still there. */
23
+ /** Told, in words, of a machine not read, not deleted or still there. */
24
24
  onWords?: (words: string) => void;
25
+ /**
26
+ * The image the run's computers started from. With facts.labels "machine", labels are read only in a machine of this
27
+ * image or a box image (HostedOptions.image): one of another image is never read, so never swept.
28
+ */
29
+ image?: string;
25
30
  }
26
31
  /**
27
32
  * The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`, that carries a
28
33
  * conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
29
34
  * vendor refused is the error, with nothing deleted.
30
35
  */
31
- export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords }?: SweepMachinesOptions): Promise<Result<SweepCounts>>;
36
+ export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords, image }?: SweepMachinesOptions): Promise<Result<SweepCounts>>;
32
37
  /** A stream as main writes to it: done is called once the text is handed on. */
33
38
  export interface Writer {
34
39
  write(text: string, done?: (error?: Error | null) => void): unknown;
@@ -12,7 +12,8 @@
12
12
  // labelled machines with no conformance label, which another user of the account made during the run: never touched. A
13
13
  // machine in <file> is never touched either: no call names it, and a before file of another provider is refused, as is
14
14
  // one listed elsewhere for a provider whose module names where it lists (sweepScope: an app and a server), since
15
- // every machine there would read as new.
15
+ // every machine there would read as new. A host that keeps its labels in the machine has them read only in a machine
16
+ // of a box image or of --after's --image <image>, the image the run started from.
16
17
  // Exit 0 when every swept machine is gone, 1 when one is still there, 2 on a usage error, a before file it cannot read,
17
18
  // missing settings, or a listing the vendor refused (nothing is deleted then). It makes nothing, so it needs no live switch.
18
19
  //
@@ -31,8 +32,8 @@ import { RUN_LABEL } from "./runner.js";
31
32
  * conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
32
33
  * vendor refused is the error, with nothing deleted.
33
34
  */
34
- export async function sweepMachines(host, { labels = {}, before = new Set(), waitMs = 60_000, pollMs = 2_000, requestMs = 30_000, listMs = 60_000, onWords = () => { } } = {}) {
35
- const listed = await foundBy(host, "the listing", { ...labels, [COMPUTER_LABEL]: "1" }, { listMs, requestMs });
35
+ export async function sweepMachines(host, { labels = {}, before = new Set(), waitMs = 60_000, pollMs = 2_000, requestMs = 30_000, listMs = 60_000, onWords = () => { }, image } = {}) {
36
+ const listed = await foundBy(host, "the listing", { ...labels, [COMPUTER_LABEL]: "1" }, { listMs, requestMs, image, onNote: ({ computer, note }) => onWords(`${computer} was not read: ${note}`) });
36
37
  if (!listed.ok)
37
38
  return listed;
38
39
  const added = listed.value.filter((machine) => !before.has(machine.id));
@@ -61,6 +62,8 @@ const USAGE = `usage: node packages/computer/dist/conformance/sweep.js --provide
61
62
  --after <file> delete every machine listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
62
63
  each back until the vendor no longer has it (up to 60 s each), and print
63
64
  {"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
65
+ --image <image> with --after, for a host that keeps its labels in the machine: the image the run's computers started
66
+ from, read beside the box images (a machine of any other image is never read, so never swept)
64
67
  settings: the provider's conformance module's (COMPUTER_<VENDOR>_*), never the vendor's own names
65
68
  exit: 0 every swept machine is gone, 1 one is still there, 2 usage error, unreadable before file, no settings, or a refused listing`;
66
69
  class Usage extends Error {
@@ -68,20 +71,27 @@ class Usage extends Error {
68
71
  const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
69
72
  function parse(argv) {
70
73
  let provider;
74
+ let image;
71
75
  let found;
72
76
  for (let i = 0; i < argv.length; i++) {
73
77
  const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
74
- if (flag !== "--before" && flag !== "--after" && flag !== "--provider")
78
+ if (flag !== "--before" && flag !== "--after" && flag !== "--provider" && flag !== "--image")
75
79
  throw new Usage(`unknown option ${flag}`);
76
80
  const value = inline ?? argv[++i];
77
81
  if (value === undefined || value === "" || value.startsWith("--"))
78
- throw new Usage(`${flag} needs a ${flag === "--provider" ? "provider id" : "file"}`);
82
+ throw new Usage(`${flag} needs a ${flag === "--provider" ? "provider id" : flag === "--image" ? "image" : "file"}`);
79
83
  if (flag === "--provider") {
80
84
  if (provider !== undefined)
81
85
  throw new Usage("give --provider once");
82
86
  provider = value;
83
87
  continue;
84
88
  }
89
+ if (flag === "--image") {
90
+ if (image !== undefined)
91
+ throw new Usage("give --image once");
92
+ image = value;
93
+ continue;
94
+ }
85
95
  if (found !== undefined)
86
96
  throw new Usage("give --before <file> or --after <file>, one of them");
87
97
  found = { mode: flag === "--before" ? "before" : "after", file: value };
@@ -90,7 +100,7 @@ function parse(argv) {
90
100
  throw new Usage("give --provider <id>");
91
101
  if (found === undefined)
92
102
  throw new Usage("give --before <file> or --after <file>, one of them");
93
- return { provider, ...found };
103
+ return { provider, ...found, ...(image === undefined ? {} : { image }) };
94
104
  }
95
105
  /** The ids a before file of this provider (and of this scope, when the provider names one) holds, or why it is not one. */
96
106
  function beforeIds(file, provider, scope) {
@@ -172,7 +182,7 @@ export async function main(argv, io = {}) {
172
182
  return 0;
173
183
  }
174
184
  const said = [];
175
- const swept = await sweepMachines(host, { before, waitMs, pollMs, onWords: (words) => said.push(words) });
185
+ const swept = await sweepMachines(host, { before, waitMs, pollMs, image: args.image, onWords: (words) => said.push(words) });
176
186
  for (const words of said)
177
187
  await write(stderr, `${words}\n`);
178
188
  if (!swept.ok) {
@@ -93,6 +93,8 @@ export interface CaseContext {
93
93
  readonly declared: readonly KindCapabilities[] | undefined;
94
94
  /** The provider built with planted secrets (ConformanceOptions.planted); skips the case when none was given. */
95
95
  planted(): Promise<PlantedProvider>;
96
+ /** The server a dial host's machines reach (ConformanceOptions.dial); fails the case when none was given. */
97
+ dial(): Promise<DialKit>;
96
98
  /** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
97
99
  runFolder(kind: MountKind): Promise<RunFolder>;
98
100
  /** The GPU the run pays for (options.gpu, the CLI's --gpu); skips the case when the run names none. */
@@ -266,6 +268,23 @@ export interface ComputerDaemon {
266
268
  arch: string;
267
269
  fence?: NetworkFence;
268
270
  }
271
+ /**
272
+ * The server a dial host's machines reach (MachineHost facts.connect "dial"), as the run stands it up: its machine
273
+ * tokens and its attach route, for provider.dial-token.
274
+ */
275
+ export interface DialKit {
276
+ /** The machine (computer name) a token is good for at a time, as the server's attach route reads it; undefined: refused. */
277
+ check(token: string, at: Date): Promise<string | undefined> | string | undefined;
278
+ /** The token a computer's machine was given at its create (its AGENTRUN_ATTACH_TOKEN). */
279
+ token(ref: ComputerRef): string | undefined;
280
+ /** Dials the server's attach route with a token and answers its hello with this one: the code the socket closed with. */
281
+ dialAs(token: string, hello: HelloResult): Promise<number | undefined>;
282
+ /** The same provider with no public address, and how many creates its host has been asked for since. */
283
+ unreachable(): {
284
+ provider: ComputerProvider;
285
+ creates(): number;
286
+ };
287
+ }
269
288
  /** A provider built with planted secrets, and the values planted: none of them may show in anything it answers. */
270
289
  export interface PlantedProvider {
271
290
  provider: ComputerProvider;
@@ -296,6 +315,8 @@ export interface ConformanceOptions {
296
315
  * values, for health.no-key-in-errors. Without it (a provider that takes no secret), that case skips.
297
316
  */
298
317
  planted?: () => Promise<PlantedProvider> | PlantedProvider;
318
+ /** The server a dial host's machines reach, for provider.dial-token: a dial host's run fails that case without it. */
319
+ dial?: () => Promise<DialKit> | DialKit;
299
320
  /**
300
321
  * A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
301
322
  * the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
package/dist/daytona.d.ts CHANGED
@@ -18,7 +18,7 @@ export type DaytonaTimeouts = HostedTimeouts & {
18
18
  retryMs: number;
19
19
  };
20
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" | "archilEgress"> {
21
+ export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs" | "timeouts"> {
22
22
  /** The Daytona API key. The caller passes it; this provider never reads the environment and never puts it in a computer. */
23
23
  apiKey: string;
24
24
  /** Default https://app.daytona.io/api. */
@@ -29,6 +29,13 @@ export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "de
29
29
  sandboxClass?: "container" | "linux-vm";
30
30
  /** The Daytona target (region); default the organization's. */
31
31
  target?: string;
32
+ /**
33
+ * The operator's Archil egress relay, `<IPv4 gateway>:<mount lane>:<data lane>` (HostedOptions.archilEgress, checked
34
+ * as the adapter checks it): for a self-hosted Daytona target whose sandboxes reach Archil only through it. With it,
35
+ * this provider takes an Archil mount (DAYTONA.mountsWith); without it, check() refuses one in DAYTONA_NO_ARCHIL's
36
+ * words, since Archil's client hangs on Daytona's hosted cloud. Set it only for such a target.
37
+ */
38
+ archilEgress?: string;
32
39
  /**
33
40
  * The snapshot GPU computers are made from: one of ours, box/Dockerfile built with a GPU (box/build-daytona.py --gpu
34
41
  * H100 prints its name, agentrun-archil-gpu-h100-<hash>), whose user is root; its GPU is the one its name says.