@parcha/agentrun-computer 0.1.0-beta.32 → 0.1.0-beta.34

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 +190 -26
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +6 -3
  4. package/dist/browserbase.d.ts +3 -1
  5. package/dist/browserbase.js +3 -1
  6. package/dist/child.d.ts +2 -0
  7. package/dist/child.js +13 -2
  8. package/dist/chrome.d.ts +73 -0
  9. package/dist/chrome.js +224 -0
  10. package/dist/computerd-linux-amd64 +0 -0
  11. package/dist/computerd-linux-arm64 +0 -0
  12. package/dist/conformance/cases/gpu.d.ts +2 -0
  13. package/dist/conformance/cases/gpu.js +108 -0
  14. package/dist/conformance/cases/health.js +83 -3
  15. package/dist/conformance/cases/index.js +2 -0
  16. package/dist/conformance/cases/isolation.js +6 -0
  17. package/dist/conformance/cases/mount.d.ts +8 -1
  18. package/dist/conformance/cases/mount.js +4 -3
  19. package/dist/conformance/cases/provider.js +14 -0
  20. package/dist/conformance/cli.js +46 -7
  21. package/dist/conformance/daytona-sweep.js +17 -9
  22. package/dist/conformance/e2b-sweep.js +17 -10
  23. package/dist/conformance/local.d.ts +30 -0
  24. package/dist/conformance/local.js +36 -0
  25. package/dist/conformance/modal-sweep.js +32 -9
  26. package/dist/conformance/report.js +10 -5
  27. package/dist/conformance/runner.js +45 -13
  28. package/dist/conformance/types.d.ts +63 -16
  29. package/dist/daytona.d.ts +35 -4
  30. package/dist/daytona.js +113 -27
  31. package/dist/docker.d.ts +9 -1
  32. package/dist/docker.js +92 -7
  33. package/dist/drift.d.ts +3 -1
  34. package/dist/drift.js +9 -0
  35. package/dist/e2b.d.ts +6 -2
  36. package/dist/e2b.js +10 -6
  37. package/dist/index.d.ts +4 -2
  38. package/dist/index.js +4 -2
  39. package/dist/isolation.d.ts +0 -2
  40. package/dist/isolation.js +0 -16
  41. package/dist/kernel.d.ts +3 -1
  42. package/dist/kernel.js +3 -1
  43. package/dist/kinds.d.ts +10 -4
  44. package/dist/kinds.js +26 -6
  45. package/dist/labels.d.ts +6 -0
  46. package/dist/labels.js +26 -1
  47. package/dist/local-supervisor.d.ts +51 -0
  48. package/dist/local-supervisor.js +221 -0
  49. package/dist/local.d.ts +89 -0
  50. package/dist/local.js +472 -0
  51. package/dist/modal.d.ts +31 -4
  52. package/dist/modal.js +90 -30
  53. package/dist/orgo.d.ts +3 -1
  54. package/dist/orgo.js +14 -27
  55. package/dist/phone-harness.d.ts +3 -1
  56. package/dist/phone-harness.js +7 -4
  57. package/dist/protocol.d.ts +20 -0
  58. package/dist/protocol.js +9 -0
  59. package/dist/provider.d.ts +63 -3
  60. package/dist/provider.js +28 -0
  61. package/dist/providers.d.ts +7 -1
  62. package/dist/providers.js +1 -0
  63. package/package.json +1 -1
@@ -1,23 +1,25 @@
1
1
  import type { MountKind, MountSpec } from "../mount.js";
2
- import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult } from "../protocol.js";
3
- import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode } from "../provider.js";
2
+ import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
3
+ import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode, GpuSpec } from "../provider.js";
4
4
  import type { ComputerError, ComputerErrorCode, Result } from "../result.js";
5
- import type { ComputerSettingKind } from "../kinds.js";
5
+ import type { ComputerSettingKind, KindCapabilities } from "../kinds.js";
6
6
  import type { CdpDialer, CdpSocket } from "./cdp.js";
7
7
  import type { StartedFixture } from "./fixture.js";
8
8
  import type { KindVerdict } from "./kind.js";
9
9
  /** Core: what a computer of its kind must do. Full: an optional capability, tested only where it is declared. */
10
10
  export type Level = "core" | "full";
11
11
  /** The suite's own grouping of its cases, the first part of each case id; not the protocol's Group. */
12
- export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser";
12
+ export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser" | "gpu";
13
13
  /**
14
14
  * What a case needs: a group (declared by both the provider's capabilities().groups and the computer's hello), a
15
15
  * network the provider declares, the janitor as the keeper of deadlines, a spec.user the provider takes, a release that
16
16
  * stops a computer and keeps it, a mount kind capabilities().mount declares, a provider method that is optional
17
- * (extend, stream), declared by being there, or the ports of a vendor's agent in the computer (vendor-agent: declared
18
- * by capabilities().vendorAgentPorts, an empty list included).
17
+ * (extend, stream), declared by being there, the ports of a vendor's agent in the computer (vendor-agent: declared
18
+ * by capabilities().vendorAgentPorts, an empty list included), a secret the provider takes (secrets: declared by the
19
+ * run's planted provider, which its conformance module's ENV makes possible), or GPUs (gpu: declared by
20
+ * capabilities().gpu).
19
21
  */
20
- export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent";
22
+ export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent" | "secrets" | "gpu";
21
23
  /**
22
24
  * A fresh run's folder for one mount kind, made by the provider's conformance module: the mount that reaches it, and its
23
25
  * outside, where a computer does not run (the folder on the host for a bind, the disk's file API for Archil).
@@ -86,8 +88,14 @@ export interface CaseContext {
86
88
  dir(): Promise<string>;
87
89
  /** The same provider with a daemon that reports another version; skips the case when none was given. */
88
90
  drifted(): Promise<ComputerProvider>;
91
+ /** What the provider declares of itself (ConformanceOptions.declared); undefined when the run was given none. */
92
+ readonly declared: readonly KindCapabilities[] | undefined;
93
+ /** The provider built with planted secrets (ConformanceOptions.planted); skips the case when none was given. */
94
+ planted(): Promise<PlantedProvider>;
89
95
  /** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
90
96
  runFolder(kind: MountKind): Promise<RunFolder>;
97
+ /** The GPU the run pays for (options.gpu, the CLI's --gpu); skips the case when the run names none. */
98
+ gpu(): GpuSpec;
91
99
  /**
92
100
  * Starts the run's fixture in the case's computer and waits until it is up: an app that logs each input event it
93
101
  * gets, so a case checks what an action did with no model. It is stopped when the case ends. Skips the case when the
@@ -158,12 +166,12 @@ export interface ConformanceReport {
158
166
  kind: ComputerKind;
159
167
  daemonMode: DaemonMode;
160
168
  image: string;
161
- /** What the run's computer said in hello; null when no computer could be made. */
162
- daemon: {
163
- version: string;
164
- os: string;
165
- arch: string;
166
- } | null;
169
+ /**
170
+ * What each computer of the run said in its first hello, one entry per computer in the order they answered, each
171
+ * naming the computer and its role, with the fence its programs are held behind when it says one; empty when no
172
+ * computer answered. Computers of one run may differ: a GPU computer's fence is not the run's computer's.
173
+ */
174
+ daemons: ComputerDaemon[];
167
175
  /** The groups or case ids the run was limited to, when it was. */
168
176
  only?: string[];
169
177
  /** When only or kind was given: the Core cases it left out, which did not run. */
@@ -193,9 +201,10 @@ export interface ConformanceReport {
193
201
  notes?: string[];
194
202
  /**
195
203
  * What create's read-back recorded of each computer the run made that does not refuse it (a probe target that
196
- * accepted and sent nothing back), one entry per note, naming the computer, in the order they came; absent when none.
204
+ * accepted and sent nothing back), one entry per note, naming the computer and its role, in the order they came;
205
+ * absent when none.
197
206
  */
198
- computerNotes?: ComputerNote[];
207
+ computerNotes?: CreatedNote[];
199
208
  /**
200
209
  * What the provider said through its onNote option during the run (a release that did not let an Archil folder go
201
210
  * cleanly), naming the computer, in the order it came: no failure of any case. The CLI gives the option and fills
@@ -203,11 +212,34 @@ export interface ConformanceReport {
203
212
  */
204
213
  providerNotes?: ComputerNote[];
205
214
  }
206
- /** One note a create returned: the computer's name and the note's words. */
215
+ /** One note about a computer: the computer's name and the note's words. */
207
216
  export interface ComputerNote {
208
217
  computer: string;
209
218
  note: string;
210
219
  }
220
+ /**
221
+ * What a computer is for in a run: "shared", the run's computer, which the cases that need no computer of their own
222
+ * share; else the id of the case that made it.
223
+ */
224
+ export type ComputerRole = string;
225
+ /** One note a create returned: the computer, its role, and the note's words. */
226
+ export interface CreatedNote extends ComputerNote {
227
+ role: ComputerRole;
228
+ }
229
+ /** What one computer's first hello said: the computer, its role, and the fence when it names one. */
230
+ export interface ComputerDaemon {
231
+ computer: string;
232
+ role: ComputerRole;
233
+ version: string;
234
+ os: string;
235
+ arch: string;
236
+ fence?: NetworkFence;
237
+ }
238
+ /** A provider built with planted secrets, and the values planted: none of them may show in anything it answers. */
239
+ export interface PlantedProvider {
240
+ provider: ComputerProvider;
241
+ secrets: string[];
242
+ }
211
243
  export interface ConformanceOptions {
212
244
  /** The image every computer of the run starts from. */
213
245
  image: string;
@@ -223,6 +255,16 @@ export interface ConformanceOptions {
223
255
  cases?: Case[];
224
256
  /** The same provider with a daemon that reports another version, for the drift cases. */
225
257
  drifted?: () => Promise<ComputerProvider> | ComputerProvider;
258
+ /**
259
+ * What the provider declares of itself, each configuration's kind and groups, for health.declared: its descriptor
260
+ * (until the descriptor lands, its PROVIDERS entry, or its module's CAPABILITIES). Without it, that case skips.
261
+ */
262
+ declared?: readonly KindCapabilities[];
263
+ /**
264
+ * The same provider built with a planted value in place of each of its secrets (an API key, a token), and those
265
+ * values, for health.no-key-in-errors. Without it (a provider that takes no secret), that case skips.
266
+ */
267
+ planted?: () => Promise<PlantedProvider> | PlantedProvider;
226
268
  /**
227
269
  * A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
228
270
  * the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
@@ -243,6 +285,11 @@ export interface ConformanceOptions {
243
285
  * fixture APK for an Android phone. Without it those cases skip, and Core cannot pass where kind requires them.
244
286
  */
245
287
  fixture?: string;
288
+ /**
289
+ * The GPU the gpu case asks for: a type the provider declares and a count. A GPU bills by the second, so the run names
290
+ * the one it pays for; without it the case skips in words.
291
+ */
292
+ gpu?: GpuSpec;
246
293
  /** fetch for screen.stream; default the global one. */
247
294
  fetch?: CaseContext["fetch"];
248
295
  /** How the browser cases open a CDP socket; default a WebSocket (dialCdp). Tests give a fake browser's. */
package/dist/daytona.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { KindCapabilities } from "./kinds.js";
2
2
  import { type MountKind } from "./mount.js";
3
3
  import { type ProviderNote } from "./mount-archil.js";
4
- import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
4
+ import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type GpuCapability, type NetworkForm, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
5
5
  import { type Result } from "./result.js";
6
6
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
7
  /** The longest each kind of call may take, and the pauses between polls and retries. */
@@ -87,7 +87,36 @@ export interface DaytonaProviderOptions {
87
87
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
88
88
  */
89
89
  export declare const MOUNT: readonly MountKind[];
90
- /** The machine kind and groups of its one configuration: a linux computer. */
90
+ /** The network a Daytona computer's programs get: none, a network of their own (isolation.ts OWN_NETWORK_ONLY). */
91
+ export declare const NETWORK: readonly NetworkForm[];
92
+ /** The one region Daytona runs a GPU sandbox in, whatever the provider's target. */
93
+ export declare const DAYTONA_GPU_REGION = "earth";
94
+ /**
95
+ * The snapshot every GPU sandbox is made from: Daytona's general GPU snapshot, its default sandbox image (user daytona,
96
+ * passwordless sudo) with the CUDA toolkit, as Daytona's dashboard makes one (GET /snapshots/daytona-gpu, 11-11). A GPU
97
+ * spec names it, or "default"; no other snapshot is proven to give a GPU computer, so check() refuses one.
98
+ */
99
+ export declare const DAYTONA_GPU_SNAPSHOT = "daytona-gpu";
100
+ /**
101
+ * The GPU a snapshot gives every sandbox made from it. A Daytona snapshot carries its own resources, GPUs among them: a
102
+ * create that names a snapshot sends none (Daytona answers 400 "Cannot specify Sandbox resources when using a
103
+ * snapshot", live 11-11), so a GPU computer's type and count are its snapshot's, and the read-back is held to them.
104
+ */
105
+ export interface DaytonaSnapshotGpu {
106
+ type: string;
107
+ count: number;
108
+ }
109
+ /** daytona-gpu's GPU, as GET /snapshots/daytona-gpu declares it (gpu 1, gpuType H100; 11-11). */
110
+ export declare const DAYTONA_GPU_SNAPSHOT_GPU: Readonly<DaytonaSnapshotGpu>;
111
+ /**
112
+ * The GPUs Daytona offers, as capabilities().gpu and CAPABILITIES declare them: the GPU of its GPU snapshot, daytona-gpu,
113
+ * alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it (no pause, no
114
+ * snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory and 400 GiB of
115
+ * disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and it takes no
116
+ * mount: daytona-gpu's user is daytona, not root, and it has no Archil client, so an Archil mount is refused in words.
117
+ */
118
+ export declare const DAYTONA_GPU: Readonly<GpuCapability>;
119
+ /** The machine kind, groups and GPUs of its one configuration: a linux computer, with GPUs when asked. */
91
120
  export declare const CAPABILITIES: readonly KindCapabilities[];
92
121
  /** What create() takes: the provider's options, the daemon optional (default this package's build for the arch). */
93
122
  export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> & {
@@ -137,7 +166,7 @@ export declare class DaytonaProvider implements ComputerProvider {
137
166
  check(spec: ComputerSpec): Refusal[];
138
167
  create(spec: ComputerSpec, { signal }?: {
139
168
  signal?: AbortSignal;
140
- }): Promise<Result<ComputerRef>>;
169
+ }): Promise<Result<CreatedComputer>>;
141
170
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch); a sandbox has no screen. */
142
171
  watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
143
172
  connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
@@ -148,12 +177,14 @@ export declare class DaytonaProvider implements ComputerProvider {
148
177
  }, { signal }?: CallContext): Promise<Result<AttachedComputer>>;
149
178
  /**
150
179
  * For the sweep after a live run: every sandbox Daytona lists with agentrun.computer=1, whatever its name or state, as
151
- * Daytona reports it. list() keeps only this provider's computers; this keeps everything the label query returns.
180
+ * Daytona reports it, with its labels (the sweep deletes only a conformance run's). list() keeps only this provider's
181
+ * computers; this keeps everything the label query returns.
152
182
  */
153
183
  listLabelled({ signal }?: CallContext): Promise<Result<Array<{
154
184
  id: string;
155
185
  name?: string;
156
186
  state?: string;
187
+ labels: Record<string, string>;
157
188
  }>>>;
158
189
  /** For the sweep: GET /sandbox/{id} once, retried as every read is, and the status Daytona answered (404: none). */
159
190
  probe(id: string, { signal }?: CallContext): Promise<Result<{
package/dist/daytona.js CHANGED
@@ -7,7 +7,7 @@ import { readFileSync } from "node:fs";
7
7
  import { resolve } from "node:path";
8
8
  import { PassThrough, Writable } from "node:stream";
9
9
  import { fileURLToPath } from "node:url";
10
- import { childCommands, daemonDrift, shellCommand } from "./child.js";
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
13
  import { COMPUTER_LABEL, DEADLINE_LABEL, helloDrift, WORK } from "./drift.js";
@@ -16,7 +16,7 @@ import { epochOf, RUN_LABEL } from "./labels.js";
16
16
  import { checkMount, readBackOf } from "./mount.js";
17
17
  import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
18
18
  import { MAX_LINE_BYTES } from "./protocol.js";
19
- import { checkLifetime, } from "./provider.js";
19
+ import { checkGpu, checkLifetime, } from "./provider.js";
20
20
  import { fail, ok } from "./result.js";
21
21
  import { daemonWatch } from "./screen-watch.js";
22
22
  import { countTested } from "./test-connection.js";
@@ -26,8 +26,43 @@ import { waitUntil } from "./wait.js";
26
26
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
27
27
  */
28
28
  export const MOUNT = ["archil"];
29
- /** The machine kind and groups of its one configuration: a linux computer. */
30
- export const CAPABILITIES = [{ kind: "linux", groups: ["exec", "files", "processes"] }];
29
+ /** The network a Daytona computer's programs get: none, a network of their own (isolation.ts OWN_NETWORK_ONLY). */
30
+ export const NETWORK = ["none"];
31
+ /** The one region Daytona runs a GPU sandbox in, whatever the provider's target. */
32
+ export const DAYTONA_GPU_REGION = "earth";
33
+ /**
34
+ * The snapshot every GPU sandbox is made from: Daytona's general GPU snapshot, its default sandbox image (user daytona,
35
+ * passwordless sudo) with the CUDA toolkit, as Daytona's dashboard makes one (GET /snapshots/daytona-gpu, 11-11). A GPU
36
+ * spec names it, or "default"; no other snapshot is proven to give a GPU computer, so check() refuses one.
37
+ */
38
+ export const DAYTONA_GPU_SNAPSHOT = "daytona-gpu";
39
+ /** daytona-gpu's GPU, as GET /snapshots/daytona-gpu declares it (gpu 1, gpuType H100; 11-11). */
40
+ export const DAYTONA_GPU_SNAPSHOT_GPU = Object.freeze({ type: "H100", count: 1 });
41
+ /**
42
+ * The GPUs Daytona offers, as capabilities().gpu and CAPABILITIES declare them: the GPU of its GPU snapshot, daytona-gpu,
43
+ * alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it (no pause, no
44
+ * snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory and 400 GiB of
45
+ * disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and it takes no
46
+ * mount: daytona-gpu's user is daytona, not root, and it has no Archil client, so an Archil mount is refused in words.
47
+ */
48
+ export const DAYTONA_GPU = Object.freeze({
49
+ types: [DAYTONA_GPU_SNAPSHOT_GPU.type],
50
+ max: DAYTONA_GPU_SNAPSHOT_GPU.count,
51
+ preemptible: true,
52
+ stopDeletes: true,
53
+ region: DAYTONA_GPU_REGION,
54
+ perGpu: { cpus: 16, memoryMb: 100 * 1024, diskMb: 400 * 1024 },
55
+ mounts: [],
56
+ });
57
+ /** A copy of DAYTONA_GPU, so no caller can change the provider's own. */
58
+ const daytonaGpuCapability = () => ({
59
+ ...DAYTONA_GPU,
60
+ types: [...DAYTONA_GPU.types],
61
+ perGpu: { ...DAYTONA_GPU.perGpu },
62
+ mounts: [],
63
+ });
64
+ /** The machine kind, groups and GPUs of its one configuration: a linux computer, with GPUs when asked. */
65
+ export const CAPABILITIES = [{ kind: "linux", groups: ["exec", "files", "processes"], gpu: daytonaGpuCapability() }];
31
66
  /**
32
67
  * A DaytonaProvider from its options alone; it reads no environment, so the key, the API URL (default Daytona's own) and
33
68
  * the target are the caller's: serve passes its DAYTONA_API_KEY, DAYTONA_API_URL and DAYTONA_TARGET, the conformance
@@ -88,7 +123,7 @@ const MAX_CIDRS = 10;
88
123
  const TOOLBOX_PORT = 2280;
89
124
  const INIT_SESSION = "agentrun-computerd";
90
125
  const STAGING = "/tmp/agentrun-computerd-";
91
- const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "mount"]);
126
+ const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "mount", "gpu"]);
92
127
  /** The provider's root channel: argv run as root in a session of its own; the image's user is root, never sudo. */
93
128
  const ROOT_RUN = [
94
129
  "# agentrun-computer: root",
@@ -386,8 +421,13 @@ class Rest {
386
421
  function sandboxDrift(spec, sb, expected) {
387
422
  const found = [];
388
423
  const mismatch = (field, declared, actual) => found.push(`${field}: declared ${show(declared)}, read back ${show(actual)}`);
389
- // Daytona's default snapshot is whichever it names: a computer made from it is not held to a name.
390
- if (spec.image !== DAYTONA_DEFAULT_SNAPSHOT && sb.snapshot !== spec.image)
424
+ // A GPU computer is made from daytona-gpu, whatever image named it. Daytona's default snapshot is whichever it names: a
425
+ // computer made from it is not held to a name.
426
+ if (spec.gpu !== undefined) {
427
+ if (sb.snapshot !== DAYTONA_GPU_SNAPSHOT)
428
+ mismatch("snapshot", DAYTONA_GPU_SNAPSHOT, sb.snapshot);
429
+ }
430
+ else if (spec.image !== DAYTONA_DEFAULT_SNAPSHOT && sb.snapshot !== spec.image)
391
431
  mismatch("snapshot", spec.image, sb.snapshot);
392
432
  const network = networkOf(sb);
393
433
  if (!samePolicy(network, spec.network))
@@ -417,8 +457,12 @@ function sandboxDrift(spec, sb, expected) {
417
457
  mismatch("public", false, sb.public);
418
458
  if (sb.kvm === true)
419
459
  mismatch("kvm", false, sb.kvm);
420
- if (sb.gpu !== undefined && sb.gpu !== 0)
421
- mismatch("gpu", 0, sb.gpu);
460
+ // The GPUs read back, held to the snapshot's own (a create sends none): daytona-gpu's for a GPU computer, none else.
461
+ const gpus = spec.gpu === undefined ? 0 : DAYTONA_GPU_SNAPSHOT_GPU.count;
462
+ if ((sb.gpu ?? 0) !== gpus)
463
+ mismatch("gpu", gpus, sb.gpu);
464
+ if (spec.gpu !== undefined && sb.gpuType !== DAYTONA_GPU_SNAPSHOT_GPU.type)
465
+ mismatch("gpuType", DAYTONA_GPU_SNAPSHOT_GPU.type, sb.gpuType);
422
466
  if (Array.isArray(sb.volumes) ? sb.volumes.length > 0 : sb.volumes !== undefined && sb.volumes !== null)
423
467
  mismatch("volumes", [], sb.volumes);
424
468
  if (typeof sb.linkedSandboxId === "string" && sb.linkedSandboxId !== "")
@@ -571,7 +615,7 @@ export class DaytonaProvider {
571
615
  return {
572
616
  kind: "linux",
573
617
  lifetime: "vendor",
574
- network: ["none"],
618
+ network: [...NETWORK],
575
619
  isolation: this.#class === "linux-vm" ? "vm" : "container",
576
620
  os: "linux",
577
621
  daemon: "child",
@@ -582,6 +626,8 @@ export class DaytonaProvider {
582
626
  stopDeletes: this.#autoDelete === 0,
583
627
  mount: [...MOUNT],
584
628
  vendorAgentPorts: [TOOLBOX_PORT],
629
+ // A GPU sandbox's limits are stated in gpu: its stop deletes it, it runs in region earth, its size is per GPU.
630
+ gpu: daytonaGpuCapability(),
585
631
  };
586
632
  }
587
633
  check(spec) {
@@ -613,6 +659,13 @@ export class DaytonaProvider {
613
659
  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}"`);
614
660
  }
615
661
  }
662
+ // The GPU is the snapshot's (a create sends none): daytona-gpu's type and count alone, and no mount (DAYTONA_GPU).
663
+ const gpuRefused = checkGpu(given.gpu, this.capabilities(), given.mount);
664
+ refusals.push(...gpuRefused);
665
+ // A GPU computer is made from daytona-gpu: a spec names it, or Daytona's default, never another snapshot.
666
+ if (given.gpu !== undefined && gpuRefused.length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== DAYTONA_GPU_SNAPSHOT) {
667
+ 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`);
668
+ }
616
669
  for (const [field, value] of Object.entries(given)) {
617
670
  if (SPEC_FIELDS.has(field) || value === undefined)
618
671
  continue;
@@ -646,19 +699,26 @@ export class DaytonaProvider {
646
699
  const archil = archilOf(spec);
647
700
  const body = {
648
701
  name,
649
- // "default" sends no snapshot, and Daytona makes the sandbox from its default snapshot.
650
- ...(spec.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: spec.image }),
702
+ // A GPU sandbox is made from daytona-gpu (check() took "default" or that name). Otherwise "default" sends no
703
+ // snapshot, and Daytona makes the sandbox from its default snapshot.
704
+ ...(spec.gpu !== undefined ? { snapshot: DAYTONA_GPU_SNAPSHOT } : spec.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: spec.image }),
651
705
  // An Archil computer carries its mount as a label: kind and source, never the token.
652
706
  labels: { ...spec.labels, ...(archil ? archilLabels(archil) : {}), [COMPUTER_LABEL]: "1", [DEADLINE_LABEL]: deadline, [IMAGE_LABEL]: spec.image },
653
707
  env: {},
654
708
  public: false,
655
- ...(this.#target === undefined ? {} : { target: this.#target }),
709
+ // A GPU sandbox runs in region earth alone, whatever the provider's target.
710
+ ...(spec.gpu !== undefined ? { target: DAYTONA_GPU_REGION } : this.#target === undefined ? {} : { target: this.#target }),
656
711
  ttlMinutes: Math.max(1, Math.ceil(spec.lifetimeMs / 60_000)),
657
712
  autoStopInterval: this.#autoStop,
658
- autoDeleteInterval: this.#autoDelete,
713
+ // A GPU sandbox's stop deletes it (no pause, no snapshot), so it is asked for and read back as deleted at stop:
714
+ // autoDeleteInterval 0 is Daytona's ephemeral (its SDK's ephemeral sets it; CreateSandbox has no ephemeral field).
715
+ autoDeleteInterval: this.#autoDeleteFor(spec.gpu !== undefined),
659
716
  // An Archil computer's root reaches Archil: Daytona's network is open, and init's own namespace (loopback alone)
660
717
  // holds the tools to none.
661
718
  ...(networkBody(archil ? "open" : spec.network) ?? { networkBlockAll: true }),
719
+ // No resource field (cpu, gpu, gpuType, memory, disk): a snapshot carries its own, and Daytona refuses a create that
720
+ // names a snapshot and sends any (400 "Cannot specify Sandbox resources when using a snapshot"). A GPU computer's
721
+ // GPU is daytona-gpu's, held in the read-back.
662
722
  };
663
723
  const posted = await this.#rest.json("POST", this.#rest.sandbox(), { json: body, timeoutMs: this.#timeouts.createMs }, signal);
664
724
  const made = posted.ok ? posted.value : undefined;
@@ -678,7 +738,7 @@ export class DaytonaProvider {
678
738
  if (signal?.aborted)
679
739
  return this.#abandon(ref, { code: "aborted", message: "create was aborted" }, signal);
680
740
  if (prepared.ok)
681
- return ok(ref);
741
+ return ok(prepared.value.length > 0 ? { ...ref, notes: prepared.value } : ref);
682
742
  return this.#abandon(ref, prepared.error, signal);
683
743
  }
684
744
  async #abandon(ref, error, signal) {
@@ -701,7 +761,7 @@ export class DaytonaProvider {
701
761
  const sb = started.value;
702
762
  const archil = archilOf(spec);
703
763
  // An Archil computer's network at Daytona is open for root; init's own namespace holds the tools to the spec's none.
704
- const vendor = sandboxDrift(archil ? { ...spec, network: "open" } : spec, sb, this.#sandboxExpected(deadline));
764
+ const vendor = sandboxDrift(archil ? { ...spec, network: "open" } : spec, sb, this.#sandboxExpected(deadline, spec.gpu !== undefined));
705
765
  if (vendor.length > 0)
706
766
  return fail("refused", `it did not match its spec: ${vendor.join("; ")}`);
707
767
  const toolbox = await this.#toolbox(sb, signal);
@@ -725,6 +785,8 @@ export class DaytonaProvider {
725
785
  const read = /^sha256 ([0-9a-f]{64})$/m.exec(install.value.result)?.[1];
726
786
  if (read !== sha256)
727
787
  return fail("refused", `it did not match its spec: daemon: uploaded sha256 ${sha256}, the installed binary reads back ${show(read)}`);
788
+ // Who installed it, for the create's notes: root, or the snapshot's user through passwordless sudo (daytona-gpu's).
789
+ const installer = installerOf(install.value.result);
728
790
  // The run's folder, mounted before init starts, so no tool program runs before it is there.
729
791
  let epoch;
730
792
  if (archil) {
@@ -772,7 +834,8 @@ export class DaytonaProvider {
772
834
  return fail("refused", `it did not match its spec: mount: declared ${show(want)}, read back ${show(mountRead.value ?? "nothing")}`);
773
835
  }
774
836
  }
775
- return this.#waitListed(ref.id, signal);
837
+ const listed = await this.#waitListed(ref.id, signal);
838
+ return listed.ok ? ok(installer === undefined ? [] : [installer]) : listed;
776
839
  }
777
840
  /**
778
841
  * What an Archil computer mounts at /workspace, read back through its computerd: the mount table, and whether the
@@ -833,8 +896,12 @@ export class DaytonaProvider {
833
896
  },
834
897
  };
835
898
  }
836
- #sandboxExpected(deadline) {
837
- return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDelete };
899
+ #sandboxExpected(deadline, gpu = false) {
900
+ return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDeleteFor(gpu) };
901
+ }
902
+ /** The autoDeleteInterval a sandbox is made and read back with: 0 for a GPU sandbox, which a stop deletes; else the option's. */
903
+ #autoDeleteFor(gpu) {
904
+ return gpu ? 0 : this.#autoDelete;
838
905
  }
839
906
  #daemonExpected() {
840
907
  const { kind, groups } = this.capabilities();
@@ -975,7 +1042,18 @@ export class DaytonaProvider {
975
1042
  })());
976
1043
  const bound = AbortSignal.timeout(this.#timeouts.helloMs);
977
1044
  const either = signal ? AbortSignal.any([signal, bound]) : bound;
978
- const opened = await Promise.race([stream.open, new Promise((done) => either.addEventListener("abort", () => done(fail("aborted", "")), { once: true }))]);
1045
+ // The stream's open raced against the bound; the abort listener is removed once the race is decided, so no connect
1046
+ // leaves one behind on its signal.
1047
+ let onAbort = () => { };
1048
+ const aborted = new Promise((done) => {
1049
+ onAbort = () => done(fail("aborted", ""));
1050
+ if (either.aborted)
1051
+ onAbort();
1052
+ else
1053
+ either.addEventListener("abort", onAbort, { once: true });
1054
+ });
1055
+ const opened = await Promise.race([stream.open, aborted]);
1056
+ either.removeEventListener("abort", onAbort);
979
1057
  const timedOut = () => fail("timeout", `the daemon in ${sb.name ?? sb.id} did not answer hello within ${this.#timeouts.helloMs / 1000} s`);
980
1058
  if (!opened.ok) {
981
1059
  await close();
@@ -1025,7 +1103,7 @@ export class DaytonaProvider {
1025
1103
  if (!opened.ok)
1026
1104
  return opened;
1027
1105
  const { kind, groups } = this.capabilities();
1028
- const drifted = helloDrift(opened.value.hello, { version: VERSION, kind, groups, arch: this.#arch });
1106
+ const drifted = helloDrift(opened.value.hello, { version: VERSION, kind, groups, arch: this.#arch, fence: true });
1029
1107
  // An Archil computer's client syncs the run's folder after every call that may change it, before it answers.
1030
1108
  if (drifted.length === 0)
1031
1109
  return recordedMount(found.value.labels) ? ok({ ...opened.value, client: syncingClient(opened.value.client) }) : opened;
@@ -1092,9 +1170,11 @@ export class DaytonaProvider {
1092
1170
  // The image create was asked for, from its label; a computer made before the label was written reports its snapshot.
1093
1171
  const asked = sb.labels?.[IMAGE_LABEL];
1094
1172
  const specNetwork = archilComputer || (typeof network === "object" && "other" in network) ? "none" : network;
1095
- const spec = { image: asked ?? sb.snapshot, lifetimeMs: 1, network: specNetwork, labels };
1173
+ // The GPUs Daytona reports, held to what check() allows: a type this provider declares, a count up to its max.
1174
+ const gpu = isWhole(sb.gpu) && sb.gpu > 0 ? { type: String(sb.gpuType), count: sb.gpu } : undefined;
1175
+ const spec = { image: asked ?? sb.snapshot, lifetimeMs: 1, network: specNetwork, labels, ...(gpu === undefined ? {} : { gpu }) };
1096
1176
  found.push(...this.check(spec).map(({ field, message }) => `${field}: ${message}, read back from the computer`));
1097
- const vendor = sandboxDrift(spec, sb, this.#sandboxExpected(sb.labels?.[DEADLINE_LABEL] ?? ""));
1177
+ const vendor = sandboxDrift(spec, sb, this.#sandboxExpected(sb.labels?.[DEADLINE_LABEL] ?? "", gpu !== undefined));
1098
1178
  found.push(...vendor.filter((line) => !line.startsWith("network:") &&
1099
1179
  !line.startsWith(`label ${DEADLINE_LABEL}`) &&
1100
1180
  !(asked === undefined && line.startsWith(`label ${IMAGE_LABEL}`)) &&
@@ -1147,6 +1227,7 @@ export class DaytonaProvider {
1147
1227
  ...(workdir === undefined ? {} : { workdir }),
1148
1228
  ...(deadline === undefined ? {} : { deadline }),
1149
1229
  ...(kind === undefined ? {} : { kind }),
1230
+ ...(gpu === undefined ? {} : { gpu }),
1150
1231
  },
1151
1232
  });
1152
1233
  }
@@ -1179,13 +1260,16 @@ export class DaytonaProvider {
1179
1260
  }
1180
1261
  /**
1181
1262
  * For the sweep after a live run: every sandbox Daytona lists with agentrun.computer=1, whatever its name or state, as
1182
- * Daytona reports it. list() keeps only this provider's computers; this keeps everything the label query returns.
1263
+ * Daytona reports it, with its labels (the sweep deletes only a conformance run's). list() keeps only this provider's
1264
+ * computers; this keeps everything the label query returns.
1183
1265
  */
1184
1266
  async listLabelled({ signal } = {}) {
1185
1267
  const listed = await this.#listOwn(signal);
1186
1268
  if (!listed.ok)
1187
1269
  return listed;
1188
- return ok(listed.value.filter((sb) => typeof sb?.id === "string").map((sb) => ({ id: sb.id, ...(typeof sb.name === "string" ? { name: sb.name } : {}), ...(typeof sb.state === "string" ? { state: sb.state } : {}) })));
1270
+ return ok(listed.value
1271
+ .filter((sb) => typeof sb?.id === "string")
1272
+ .map((sb) => ({ id: sb.id, ...(typeof sb.name === "string" ? { name: sb.name } : {}), ...(typeof sb.state === "string" ? { state: sb.state } : {}), labels: { ...(sb.labels ?? {}) } })));
1189
1273
  }
1190
1274
  /** For the sweep: GET /sandbox/{id} once, retried as every read is, and the status Daytona answered (404: none). */
1191
1275
  async probe(id, { signal } = {}) {
@@ -1396,8 +1480,10 @@ export class DaytonaProvider {
1396
1480
  if (!stopped.ok && stopped.error.code !== "invalid" && stopped.error.code !== "not_found")
1397
1481
  return stopped;
1398
1482
  }
1399
- // With autoDeleteInterval 0, Daytona deletes a sandbox as it stops: such a stop is done once the computer is gone.
1400
- return this.#settle(ref, this.#autoDelete === 0 ? "gone" : "stopped", "stop", signal);
1483
+ // With autoDeleteInterval 0, Daytona deletes a sandbox as it stops: such a stop is done once the computer is gone. A
1484
+ // GPU sandbox is one of those whatever the option (its stop deletes it).
1485
+ const deletes = this.#autoDeleteFor(isWhole(sb.gpu) && sb.gpu > 0) === 0;
1486
+ return this.#settle(ref, deletes ? "gone" : "stopped", "stop", signal);
1401
1487
  }
1402
1488
  /**
1403
1489
  * Waits, through waitUntil, until Daytona reads the sandbox as wanted, twice running, by its own read and by the
package/dist/docker.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type DockerHost } from "./drift.js";
3
3
  import { type EnsureImageOptions, type ImageSource } from "./docker/image.js";
4
4
  import type { KindCapabilities } from "./kinds.js";
5
5
  import { type MountKind } from "./mount.js";
6
- import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
6
+ import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkForm, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
7
7
  import { type Result } from "./result.js";
8
8
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
9
9
  /**
@@ -70,6 +70,8 @@ export interface DockerProviderOptions {
70
70
  }
71
71
  /** The mount kinds a Docker computer takes, as capabilities().mount declares them: a bind of a folder on this host. */
72
72
  export declare const MOUNT: readonly MountKind[];
73
+ /** The networks a Docker computer takes: none, open, or an allowlist through the server's egress proxy. */
74
+ export declare const NETWORK: readonly NetworkForm[];
73
75
  /** The machine kind and groups of each configuration: a linux computer, and one made with the desktop option. */
74
76
  export declare const CAPABILITIES: readonly KindCapabilities[];
75
77
  /** What create() takes: the provider's options, the daemon optional. */
@@ -90,6 +92,12 @@ export declare function dockerArch({ docker, timeoutMs }?: Pick<DockerCreateOpti
90
92
  export declare function create(options?: DockerCreateOptions): Promise<DockerProvider>;
91
93
  /** The conformance CLI's module for Docker: the drifted twin. */
92
94
  export declare const conformance: () => Promise<typeof import("./conformance/docker.js")>;
95
+ /**
96
+ * Why #settle could not show its leftovers gone within SETTLE_MS, in words that always name them: `there`, what its
97
+ * last look still found; or, when the last look found none but the quiet window was not complete, every name it
98
+ * checked (`checked`), which could not be confirmed gone. Exported for its test.
99
+ */
100
+ export declare function settleWords(checked: readonly string[], there: readonly string[]): string;
93
101
  export declare class DockerProvider implements ComputerProvider {
94
102
  #private;
95
103
  readonly id = "docker";