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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +251 -46
  2. package/box/Dockerfile +3 -1
  3. package/box/agentrun-archil +59 -7
  4. package/box/build-daytona.py +20 -4
  5. package/dist/browser.d.ts +73 -23
  6. package/dist/browser.js +141 -17
  7. package/dist/browserbase.d.ts +48 -25
  8. package/dist/browserbase.js +176 -29
  9. package/dist/chrome.d.ts +3 -4
  10. package/dist/chrome.js +6 -11
  11. package/dist/computerd-linux-amd64 +0 -0
  12. package/dist/computerd-linux-arm64 +0 -0
  13. package/dist/conformance/browserbase.js +1 -1
  14. package/dist/conformance/cases/provider.js +78 -3
  15. package/dist/conformance/daytona.d.ts +4 -0
  16. package/dist/conformance/daytona.js +7 -1
  17. package/dist/conformance/e2b.js +2 -1
  18. package/dist/conformance/fixture.js +24 -2
  19. package/dist/conformance/kernel.js +1 -1
  20. package/dist/conformance/kind.js +2 -1
  21. package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
  22. package/dist/conformance/{local.js → local-chrome.js} +11 -11
  23. package/dist/conformance/orgo.d.ts +11 -5
  24. package/dist/conformance/orgo.js +37 -8
  25. package/dist/conformance/phone-harness.js +2 -1
  26. package/dist/conformance/report.js +3 -2
  27. package/dist/conformance/runner.js +25 -7
  28. package/dist/conformance/types.d.ts +21 -8
  29. package/dist/conformance/types.js +10 -0
  30. package/dist/conformance/windows-fixture.d.ts +1 -0
  31. package/dist/conformance/windows-fixture.js +37 -0
  32. package/dist/daytona.d.ts +16 -35
  33. package/dist/daytona.js +87 -95
  34. package/dist/descriptor.d.ts +116 -0
  35. package/dist/descriptor.js +92 -0
  36. package/dist/descriptors/browserbase.d.ts +25 -0
  37. package/dist/descriptors/browserbase.js +20 -0
  38. package/dist/descriptors/daytona.d.ts +83 -0
  39. package/dist/descriptors/daytona.js +81 -0
  40. package/dist/descriptors/docker.d.ts +12 -0
  41. package/dist/descriptors/docker.js +17 -0
  42. package/dist/descriptors/e2b.d.ts +22 -0
  43. package/dist/descriptors/e2b.js +19 -0
  44. package/dist/descriptors/index.d.ts +256 -0
  45. package/dist/descriptors/index.js +19 -0
  46. package/dist/descriptors/kernel.d.ts +21 -0
  47. package/dist/descriptors/kernel.js +17 -0
  48. package/dist/descriptors/local-chrome.d.ts +17 -0
  49. package/dist/descriptors/local-chrome.js +21 -0
  50. package/dist/descriptors/modal.d.ts +54 -0
  51. package/dist/descriptors/modal.js +48 -0
  52. package/dist/descriptors/orgo.d.ts +99 -0
  53. package/dist/descriptors/orgo.js +49 -0
  54. package/dist/descriptors/phone-harness.d.ts +33 -0
  55. package/dist/descriptors/phone-harness.js +23 -0
  56. package/dist/descriptors/shared.d.ts +7 -0
  57. package/dist/descriptors/shared.js +6 -0
  58. package/dist/desktop.d.ts +4 -4
  59. package/dist/desktop.js +4 -4
  60. package/dist/docker/egress.d.ts +5 -4
  61. package/dist/docker/egress.js +7 -6
  62. package/dist/docker/image.js +17 -15
  63. package/dist/docker/inspect.d.ts +147 -0
  64. package/dist/docker/inspect.js +335 -0
  65. package/dist/docker.d.ts +6 -6
  66. package/dist/docker.js +53 -47
  67. package/dist/drift.d.ts +3 -145
  68. package/dist/drift.js +5 -334
  69. package/dist/e2b.d.ts +2 -8
  70. package/dist/e2b.js +17 -23
  71. package/dist/index.d.ts +9 -12
  72. package/dist/index.js +14 -12
  73. package/dist/isolation.js +2 -2
  74. package/dist/janitor.d.ts +20 -2
  75. package/dist/janitor.js +67 -19
  76. package/dist/kernel.d.ts +19 -29
  77. package/dist/kernel.js +110 -32
  78. package/dist/kinds.d.ts +59 -34
  79. package/dist/kinds.js +19 -117
  80. package/dist/labels.d.ts +20 -0
  81. package/dist/labels.js +62 -1
  82. package/dist/{local.d.ts → local-chrome.d.ts} +8 -9
  83. package/dist/{local.js → local-chrome.js} +26 -19
  84. package/dist/local-supervisor.d.ts +3 -3
  85. package/dist/local-supervisor.js +3 -3
  86. package/dist/modal.d.ts +6 -25
  87. package/dist/modal.js +86 -88
  88. package/dist/mount-archil.d.ts +25 -3
  89. package/dist/mount-archil.js +43 -12
  90. package/dist/orgo-channel.js +16 -13
  91. package/dist/orgo-desktop.d.ts +162 -0
  92. package/dist/orgo-desktop.js +1856 -0
  93. package/dist/orgo-names.d.ts +178 -0
  94. package/dist/orgo-names.js +287 -0
  95. package/dist/orgo.d.ts +34 -20
  96. package/dist/orgo.js +424 -173
  97. package/dist/phone-harness.d.ts +7 -12
  98. package/dist/phone-harness.js +70 -54
  99. package/dist/protocol.d.ts +5 -0
  100. package/dist/provider.d.ts +153 -10
  101. package/dist/provider.js +48 -1
  102. package/dist/providers.d.ts +23 -24
  103. package/dist/providers.js +14 -17
  104. package/dist/result.d.ts +11 -1
  105. package/dist/result.js +11 -0
  106. package/dist/test-connection.js +2 -2
  107. package/package.json +42 -2
@@ -22,3 +22,13 @@ export function coreGroups(kind, daemon) {
22
22
  return computerd;
23
23
  }
24
24
  }
25
+ /** The systems a case runs on: its own os; else Linux alone for one that runs programs, any but Windows for one that names paths. */
26
+ export function caseOs(c) {
27
+ if (c.os !== undefined)
28
+ return c.os;
29
+ if (c.needs.some((need) => need === "exec" || need === "processes"))
30
+ return ["linux"];
31
+ if (c.needs.includes("files"))
32
+ return ["linux", "macos", "android", "ios"];
33
+ return undefined;
34
+ }
@@ -0,0 +1 @@
1
+ export declare const WINDOWS_FIXTURE: string;
@@ -0,0 +1,37 @@
1
+ // The desktop fixture on Windows, where computerd-fixture (an X11 binary) cannot run: a PowerShell script that makes the
2
+ // same window (200x200 at (0, 0), borderless, on top, in the four FIXTURE_COLORS by quadrant) with Windows Forms, and
3
+ // logs what it gets as computerd-fixture does, one JSON object a line (FixtureEvent), to the file its argument names.
4
+ // Its ready line also carries its pid, which the case stops it by. It runs in a single-threaded apartment (-STA), as
5
+ // Windows Forms needs. UTF-8 with no byte order mark, so the log's first line parses as the rest do.
6
+ export const WINDOWS_FIXTURE = [
7
+ "# agentrun-computer: windows-fixture",
8
+ "param([Parameter(Mandatory = $true)][string]$Log)",
9
+ "$ErrorActionPreference = 'Stop'",
10
+ "Add-Type -AssemblyName System.Windows.Forms, System.Drawing",
11
+ "$utf8 = New-Object System.Text.UTF8Encoding($false)",
12
+ "function Say($o) { [IO.File]::AppendAllText($Log, ($o | ConvertTo-Json -Compress) + \"`n\", $utf8) }",
13
+ "function ButtonOf($b) { switch ($b) { 'Right' { 'right' } 'Middle' { 'middle' } default { 'left' } } }",
14
+ "$f = New-Object System.Windows.Forms.Form",
15
+ "$f.FormBorderStyle = 'None'",
16
+ "$f.StartPosition = 'Manual'",
17
+ "$f.Location = New-Object System.Drawing.Point(0, 0)",
18
+ "$f.ClientSize = New-Object System.Drawing.Size(200, 200)",
19
+ "$f.TopMost = $true",
20
+ "$f.ShowInTaskbar = $false",
21
+ "$f.KeyPreview = $true",
22
+ "$f.add_Paint({",
23
+ " param($s, $e)",
24
+ " $e.Graphics.FillRectangle([System.Drawing.Brushes]::Red, 0, 0, 100, 100)",
25
+ " $e.Graphics.FillRectangle((New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(0, 255, 0))), 100, 0, 100, 100)",
26
+ " $e.Graphics.FillRectangle((New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(0, 0, 255))), 0, 100, 100, 100)",
27
+ " $e.Graphics.FillRectangle((New-Object System.Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 255, 0))), 100, 100, 100, 100)",
28
+ "})",
29
+ "$f.add_MouseDown({ param($s, $e) Say @{ event = 'down'; button = (ButtonOf $e.Button); at = @($e.X, $e.Y) } })",
30
+ "$f.add_MouseUp({ param($s, $e) Say @{ event = 'up'; button = (ButtonOf $e.Button); at = @($e.X, $e.Y) } })",
31
+ "$f.add_MouseWheel({ param($s, $e) Say @{ event = 'wheel'; at = @($e.X, $e.Y); dx = 0; dy = [int](-$e.Delta / 120) } })",
32
+ "$f.add_KeyDown({ param($s, $e) Say @{ event = 'key'; key = $e.KeyCode.ToString().ToLower(); down = $true } })",
33
+ "$f.add_KeyUp({ param($s, $e) Say @{ event = 'key'; key = $e.KeyCode.ToString().ToLower(); down = $false } })",
34
+ "$f.add_KeyPress({ param($s, $e) if (-not [char]::IsControl($e.KeyChar)) { Say @{ event = 'text'; text = [string]$e.KeyChar } } })",
35
+ "$f.add_Shown({ $f.Activate(); Say @{ event = 'ready'; pid = $PID } })",
36
+ "[System.Windows.Forms.Application]::Run($f)",
37
+ ].join("\r\n");
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 CreatedComputer, type GpuCapability, type NetworkForm, 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 NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } 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. */
@@ -60,6 +60,18 @@ export interface DaytonaProviderOptions {
60
60
  sandboxClass?: "container" | "linux-vm";
61
61
  /** The Daytona target (region); default the organization's. */
62
62
  target?: string;
63
+ /**
64
+ * The egress gateway an Archil computer's archil client reaches Archil through, `<IPv4 gateway>:<mount lane>:<data
65
+ * lane>` such as 10.60.0.40:18100:42050 (parcha-proxy's archil-egress): for a target whose runners reach Archil only
66
+ * through it. Unset, the client reaches Archil as the sandbox's network allows, as before.
67
+ */
68
+ archilEgress?: string;
69
+ /**
70
+ * The snapshot GPU computers are made from: one of ours, box/Dockerfile built with a GPU (box/build-daytona.py --gpu
71
+ * H100 prints its name, agentrun-archil-gpu-h100-<hash>), whose user is root; its GPU is the one its name says.
72
+ * Default Daytona's own daytona-gpu. Either way a GPU computer takes no mount: Daytona's GPU host gives no /dev/fuse.
73
+ */
74
+ gpuSnapshot?: string;
63
75
  /**
64
76
  * Who the daemon runs as, uid:gid in numbers, never root. Default 2510:2510 (TOOL_USER), a uid no process of Daytona's
65
77
  * holds: init refuses to start while another process does.
@@ -87,36 +99,7 @@ export interface DaytonaProviderOptions {
87
99
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
88
100
  */
89
101
  export declare const MOUNT: readonly MountKind[];
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. */
102
+ /** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
120
103
  export declare const CAPABILITIES: readonly KindCapabilities[];
121
104
  /** What create() takes: the provider's options, the daemon optional (default this package's build for the arch). */
122
105
  export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> & {
@@ -130,8 +113,6 @@ export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> &
130
113
  export declare function create(options: DaytonaCreateOptions): DaytonaProvider;
131
114
  /** The conformance CLI's module for Daytona: the run's idle stop and auto-delete, its snapshot, notes and drifted twin. */
132
115
  export declare const conformance: () => Promise<typeof import("./conformance/daytona.js")>;
133
- /** The image that asks for Daytona's default snapshot: the create sends no snapshot field. */
134
- export declare const DAYTONA_DEFAULT_SNAPSHOT = "default";
135
116
  /**
136
117
  * The three commands the provider sends into a sandbox, exactly: install (through /process/execute), init and stdio
137
118
  * (each a session command), the child daemon's commands (childCommands). Exported so a test can run them where Daytona
@@ -154,7 +135,7 @@ export declare class DaytonaProvider implements ComputerProvider {
154
135
  #private;
155
136
  readonly id = "daytona";
156
137
  readonly version: string;
157
- constructor({ apiKey, onNote, apiUrl, daemonPath, arch, sandboxClass, target, daemonUser, autoStopMinutes, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }: DaytonaProviderOptions);
138
+ constructor({ apiKey, onNote, apiUrl, daemonPath, arch, sandboxClass, target, archilEgress, gpuSnapshot, daemonUser, autoStopMinutes, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }: DaytonaProviderOptions);
158
139
  /**
159
140
  * daemon child: Daytona's toolbox daemon is the sandbox's first process, and init is a command it runs in a session
160
141
  * (#prepare), so deleting that session ends init and leaves the sandbox. maxLifetimeMs is the 30 days check() has
@@ -205,5 +186,5 @@ export declare class DaytonaProvider implements ComputerProvider {
205
186
  * Daytona answers a delete or a stop before the sandbox is gone or stopped, and its listing trails both: release
206
187
  * returns once Daytona reads the computer as release left it, or fails naming the last state it read.
207
188
  */
208
- release(ref: ComputerRef, how: "stop" | "delete", { signal }?: CallContext): Promise<Result<void>>;
189
+ release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
209
190
  }
package/dist/daytona.js CHANGED
@@ -1,4 +1,4 @@
1
- // The Daytona provisioner, over Daytona's v0 REST API with fetch (no SDK), as pi-transport's Daytona box does. The daemon
1
+ // The Daytona provisioner, over Daytona's v0 REST API with fetch (no SDK). The daemon
2
2
  // goes in through the toolbox's file upload and starts as a session command, dropped to a user with no capabilities;
3
3
  // connect() carries stdio over a session command's input calls and its log stream. Every Daytona fact used here is cited
4
4
  // in the README's Daytona section.
@@ -10,59 +10,27 @@ import { fileURLToPath } from "node:url";
10
10
  import { childCommands, daemonDrift, installerOf, shellCommand } from "./child.js";
11
11
  import { OWN_NETWORK_ONLY, readOwnNetwork, TOOL_USER } from "./isolation.js";
12
12
  import { DaemonClient } from "./client.js";
13
+ import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./descriptors/daytona.js";
13
14
  import { COMPUTER_LABEL, DEADLINE_LABEL, helloDrift, WORK } from "./drift.js";
14
15
  import { releaseOlder } from "./janitor.js";
15
16
  import { epochOf, RUN_LABEL } from "./labels.js";
16
17
  import { checkMount, readBackOf } from "./mount.js";
17
- import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
18
+ import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilEgressOf, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
18
19
  import { MAX_LINE_BYTES } from "./protocol.js";
19
- import { checkGpu, checkLifetime, } from "./provider.js";
20
- import { fail, ok } from "./result.js";
20
+ import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
21
+ import { errorOf, failFor, ok, vendorFail } from "./result.js";
21
22
  import { daemonWatch } from "./screen-watch.js";
22
23
  import { countTested } from "./test-connection.js";
23
24
  import { waitUntil } from "./wait.js";
25
+ /** This module's failures: one with code vendor names Daytona. */
26
+ const fail = failFor("daytona");
24
27
  /**
25
28
  * The mount kinds a Daytona computer takes: an Archil mount of the run's folder (mount-archil.ts), made as root through
26
29
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
27
30
  */
28
- export const MOUNT = ["archil"];
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
+ export const MOUNT = DAYTONA.mounts;
32
+ /** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
33
+ export const CAPABILITIES = DAYTONA.capabilities;
66
34
  /**
67
35
  * A DaytonaProvider from its options alone; it reads no environment, so the key, the API URL (default Daytona's own) and
68
36
  * the target are the caller's: serve passes its DAYTONA_API_KEY, DAYTONA_API_URL and DAYTONA_TARGET, the conformance
@@ -82,8 +50,6 @@ export function create(options) {
82
50
  export const conformance = () => import("./conformance/daytona.js");
83
51
  const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
84
52
  const DEFAULT_API_URL = "https://app.daytona.io/api";
85
- /** The image that asks for Daytona's default snapshot: the create sends no snapshot field. */
86
- export const DAYTONA_DEFAULT_SNAPSHOT = "default";
87
53
  /** The label, in the provider's own namespace beside the deadline's, that holds the image create was asked for: Daytona
88
54
  * reports only the snapshot it resolved that image to, a name of its own for "default". */
89
55
  const IMAGE_LABEL = `${COMPUTER_LABEL}.image`;
@@ -324,7 +290,7 @@ function codeOf(status, text) {
324
290
  return "limit";
325
291
  if (status === 400 || status === 409 || status === 422)
326
292
  return "invalid";
327
- return "daytona";
293
+ return "vendor";
328
294
  }
329
295
  /** Whether fetch failed on a redirect it was told not to follow. */
330
296
  function redirected(cause) {
@@ -383,11 +349,11 @@ class Rest {
383
349
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
384
350
  });
385
351
  const bytes = new Uint8Array(await response.arrayBuffer());
386
- if (response.ok || (init.anyStatus === true && response.status < 500 && response.status !== 429))
352
+ if (response.ok || response.status === init.answerStatus || (init.anyStatus === true && response.status < 500 && response.status !== 429))
387
353
  return ok({ status: response.status, bytes });
388
354
  const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
389
355
  retryable = response.status === 429 || response.status >= 500;
390
- failure = { code: codeOf(response.status, text), message: `${what}: ${response.status} ${text}` };
356
+ failure = errorOf(codeOf(response.status, text), `${what}: ${response.status} ${text}`, "daytona");
391
357
  }
392
358
  catch (cause) {
393
359
  if (signal?.aborted)
@@ -395,9 +361,9 @@ class Rest {
395
361
  if (timeout.aborted)
396
362
  failure = { code: "timeout", message: `${what} did not answer within ${timeoutMs / 1000} s` };
397
363
  else if (redirected(cause))
398
- return fail("daytona", `${what}: Daytona answered with a redirect, which is never followed: it would carry the key`);
364
+ return vendorFail("daytona", `${what}: Daytona answered with a redirect, which is never followed: it would carry the key`);
399
365
  else
400
- failure = { code: "daytona", message: `${what}: ${cause.message}` };
366
+ failure = { code: "vendor", vendor: "daytona", message: `${what}: ${cause.message}` };
401
367
  }
402
368
  if (!retryable || attempt >= attempts)
403
369
  return { ok: false, error: failure };
@@ -414,18 +380,19 @@ class Rest {
414
380
  if (!found.ok)
415
381
  return found.error.code === "not_found" ? ok(undefined) : found;
416
382
  const sb = found.value;
417
- return typeof sb?.id === "string" ? ok(sb) : fail("daytona", `GET /sandbox/${idOrName}: no sandbox in the answer`);
383
+ return typeof sb?.id === "string" ? ok(sb) : vendorFail("daytona", `GET /sandbox/${idOrName}: no sandbox in the answer`);
418
384
  }
419
385
  }
420
386
  /** Every way a sandbox, as Daytona reads it back, differs from what create asked for. Pure: no call. */
421
387
  function sandboxDrift(spec, sb, expected) {
422
388
  const found = [];
423
389
  const mismatch = (field, declared, actual) => found.push(`${field}: declared ${show(declared)}, read back ${show(actual)}`);
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.
390
+ // A GPU computer is made from the provider's GPU snapshot, whatever image named it. Daytona's default snapshot is
391
+ // whichever it names: a computer made from it is not held to a name.
392
+ const gpu = expected.gpu;
426
393
  if (spec.gpu !== undefined) {
427
- if (sb.snapshot !== DAYTONA_GPU_SNAPSHOT)
428
- mismatch("snapshot", DAYTONA_GPU_SNAPSHOT, sb.snapshot);
394
+ if (sb.snapshot !== gpu.snapshot)
395
+ mismatch("snapshot", gpu.snapshot, sb.snapshot);
429
396
  }
430
397
  else if (spec.image !== DAYTONA_DEFAULT_SNAPSHOT && sb.snapshot !== spec.image)
431
398
  mismatch("snapshot", spec.image, sb.snapshot);
@@ -457,12 +424,12 @@ function sandboxDrift(spec, sb, expected) {
457
424
  mismatch("public", false, sb.public);
458
425
  if (sb.kvm === true)
459
426
  mismatch("kvm", false, sb.kvm);
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;
427
+ // The GPUs read back, held to the GPU snapshot's own (a create sends none) for a GPU computer, none else.
428
+ const gpus = spec.gpu === undefined ? 0 : gpu.count;
462
429
  if ((sb.gpu ?? 0) !== gpus)
463
430
  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);
431
+ if (spec.gpu !== undefined && sb.gpuType !== gpu.type)
432
+ mismatch("gpuType", gpu.type, sb.gpuType);
466
433
  if (Array.isArray(sb.volumes) ? sb.volumes.length > 0 : sb.volumes !== undefined && sb.volumes !== null)
467
434
  mismatch("volumes", [], sb.volumes);
468
435
  if (typeof sb.linkedSandboxId === "string" && sb.linkedSandboxId !== "")
@@ -515,12 +482,12 @@ function sessionStream(socket, send) {
515
482
  lines(Buffer.from(data), false);
516
483
  });
517
484
  socket.addEventListener("error", (event) => {
518
- opened(fail("daytona", `the log stream failed: ${event.message ?? "no reason given"}`));
485
+ opened(vendorFail("daytona", `the log stream failed: ${event.message ?? "no reason given"}`));
519
486
  if (!readable.destroyed)
520
487
  readable.destroy(new Error(`the log stream failed${event.message ? `: ${event.message}` : ""}`));
521
488
  });
522
489
  socket.addEventListener("close", ({ code }) => {
523
- opened(fail("daytona", `the log stream closed before it opened (code ${code ?? "none"})`));
490
+ opened(vendorFail("daytona", `the log stream closed before it opened (code ${code ?? "none"})`));
524
491
  if (readable.destroyed)
525
492
  return;
526
493
  lines(Buffer.alloc(0), true);
@@ -564,6 +531,9 @@ export class DaytonaProvider {
564
531
  #arch;
565
532
  #class;
566
533
  #target;
534
+ #archilEgress;
535
+ /** The snapshot its GPU computers are made from, their GPU, and the mounts they take. */
536
+ #gpu;
567
537
  #uid;
568
538
  #gid;
569
539
  #webSocket;
@@ -571,7 +541,7 @@ export class DaytonaProvider {
571
541
  #autoStop;
572
542
  #autoDelete;
573
543
  #onNote;
574
- constructor({ apiKey, onNote, apiUrl = DEFAULT_API_URL, daemonPath, arch = "amd64", sandboxClass = "container", target, daemonUser = TOOL_USER, autoStopMinutes = 0, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }) {
544
+ constructor({ apiKey, onNote, apiUrl = DEFAULT_API_URL, daemonPath, arch = "amd64", sandboxClass = "container", target, archilEgress, gpuSnapshot, daemonUser = TOOL_USER, autoStopMinutes = 0, autoDeleteMinutes, fetch: fetcher, webSocket, timeouts, }) {
575
545
  this.#onNote = onNote;
576
546
  if (typeof apiKey !== "string" || apiKey === "")
577
547
  throw new Error("a Daytona API key is required");
@@ -601,6 +571,8 @@ export class DaytonaProvider {
601
571
  this.#arch = arch;
602
572
  this.#class = sandboxClass;
603
573
  this.#target = target;
574
+ this.#archilEgress = archilEgress === undefined || archilEgress === "" ? undefined : archilEgressOf(archilEgress);
575
+ this.#gpu = daytonaGpuSnapshot(gpuSnapshot);
604
576
  [this.#uid, this.#gid] = [String(Number(user[1])), String(Number(user[2]))];
605
577
  this.#webSocket = webSocket ?? ((url, init) => new WebSocket(url, init));
606
578
  }
@@ -615,7 +587,7 @@ export class DaytonaProvider {
615
587
  return {
616
588
  kind: "linux",
617
589
  lifetime: "vendor",
618
- network: [...NETWORK],
590
+ network: [...DAYTONA.network],
619
591
  isolation: this.#class === "linux-vm" ? "vm" : "container",
620
592
  os: "linux",
621
593
  daemon: "child",
@@ -627,19 +599,19 @@ export class DaytonaProvider {
627
599
  mount: [...MOUNT],
628
600
  vendorAgentPorts: [TOOLBOX_PORT],
629
601
  // 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(),
602
+ gpu: daytonaGpu(this.#gpu.snapshot === DAYTONA_GPU_SNAPSHOT ? undefined : this.#gpu.snapshot),
631
603
  };
632
604
  }
633
605
  check(spec) {
634
606
  const refusals = [];
635
607
  const refuse = (field, message) => refusals.push({ field, message });
636
608
  const given = (typeof spec === "object" && spec !== null ? spec : {});
637
- const { image, lifetimeMs, network, labels } = given;
609
+ const { image, network, labels } = given;
638
610
  if (typeof image !== "string" || image.trim() === "")
639
611
  refuse("image", `an image is required: the id or name of a Daytona snapshot, or "${DAYTONA_DEFAULT_SNAPSHOT}" for Daytona's default snapshot`);
640
612
  else if (/[\0-\x1f]/.test(image))
641
613
  refuse("image", "a snapshot name has no control characters");
642
- refusals.push(...checkLifetime(lifetimeMs, this.capabilities()));
614
+ refusals.push(...checkTenure(given, this.capabilities(), "Daytona"));
643
615
  if (network === "open" || (typeof network === "object" && network !== null && "allow" in network))
644
616
  refuse("network", OWN_NETWORK_ONLY);
645
617
  else if (network !== "none")
@@ -659,12 +631,13 @@ export class DaytonaProvider {
659
631
  refuse("mount", `an Archil mount's tools run as agentrun-tool, ${tool}:${tool}, and this provider's daemon user is ${this.#uid}:${this.#gid}: give it daemonUser "${tool}:${tool}"`);
660
632
  }
661
633
  }
662
- // The GPU is the snapshot's (a create sends none): daytona-gpu's type and count alone, and no mount (DAYTONA_GPU).
634
+ // The GPU is the GPU snapshot's (a create sends none): its type and count alone, and the mounts it takes.
663
635
  const gpuRefused = checkGpu(given.gpu, this.capabilities(), given.mount);
664
636
  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`);
637
+ // A GPU computer is made from the provider's GPU snapshot: a spec names it, or Daytona's default, never another.
638
+ const gpuSnapshot = this.#gpu.snapshot;
639
+ if (given.gpu !== undefined && gpuRefused.length === 0 && typeof image === "string" && image !== DAYTONA_DEFAULT_SNAPSHOT && image !== gpuSnapshot) {
640
+ refuse("image", `a Daytona GPU computer here is made from the GPU snapshot ${gpuSnapshot} alone, not ${JSON.stringify(image)}: give "${gpuSnapshot}" or "${DAYTONA_DEFAULT_SNAPSHOT}"; no other snapshot is proven to give a GPU computer`);
668
641
  }
669
642
  for (const [field, value] of Object.entries(given)) {
670
643
  if (SPEC_FIELDS.has(field) || value === undefined)
@@ -695,20 +668,20 @@ export class DaytonaProvider {
695
668
  if (signal?.aborted)
696
669
  return fail("aborted", "create was aborted before Daytona was called");
697
670
  const name = `computer-${randomBytes(6).toString("hex")}`;
698
- const deadline = new Date(Date.now() + spec.lifetimeMs).toISOString();
671
+ const deadline = new Date(Date.now() + runLifetimeMs(spec)).toISOString();
699
672
  const archil = archilOf(spec);
700
673
  const body = {
701
674
  name,
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 }),
675
+ // A GPU sandbox is made from the provider's GPU snapshot (check() took "default" or that name). Otherwise
676
+ // "default" sends no snapshot, and Daytona makes the sandbox from its default snapshot.
677
+ ...(spec.gpu !== undefined ? { snapshot: this.#gpu.snapshot } : spec.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: spec.image }),
705
678
  // An Archil computer carries its mount as a label: kind and source, never the token.
706
679
  labels: { ...spec.labels, ...(archil ? archilLabels(archil) : {}), [COMPUTER_LABEL]: "1", [DEADLINE_LABEL]: deadline, [IMAGE_LABEL]: spec.image },
707
680
  env: {},
708
681
  public: false,
709
682
  // A GPU sandbox runs in region earth alone, whatever the provider's target.
710
683
  ...(spec.gpu !== undefined ? { target: DAYTONA_GPU_REGION } : this.#target === undefined ? {} : { target: this.#target }),
711
- ttlMinutes: Math.max(1, Math.ceil(spec.lifetimeMs / 60_000)),
684
+ ttlMinutes: Math.max(1, Math.ceil(runLifetimeMs(spec) / 60_000)),
712
685
  autoStopInterval: this.#autoStop,
713
686
  // A GPU sandbox's stop deletes it (no pause, no snapshot), so it is asked for and read back as deleted at stop:
714
687
  // autoDeleteInterval 0 is Daytona's ephemeral (its SDK's ephemeral sets it; CreateSandbox has no ephemeral field).
@@ -730,7 +703,7 @@ export class DaytonaProvider {
730
703
  const left = removed.ok ? "" : `; a sandbox named ${name} may be left (${removed.error.message}), which Daytona ends by ${deadline}`;
731
704
  if (!posted.ok)
732
705
  return fail(posted.error.code, `${posted.error.code === "aborted" ? "create was aborted" : "Daytona did not create the sandbox"}: ${posted.error.message}${left}`);
733
- return fail("daytona", `POST /sandbox: no sandbox id in the answer${left}`);
706
+ return vendorFail("daytona", `POST /sandbox: no sandbox id in the answer${left}`);
734
707
  }
735
708
  const ref = { id: made.id, name };
736
709
  // From here the sandbox exists: every step takes the caller's signal, and a failure or an abort deletes it.
@@ -768,9 +741,7 @@ export class DaytonaProvider {
768
741
  if (!toolbox.ok)
769
742
  return toolbox;
770
743
  const staging = `${STAGING}${randomBytes(8).toString("hex")}`;
771
- const form = new FormData();
772
- form.append("file", new Blob([new Uint8Array(daemon)]), "computerd");
773
- const uploaded = await this.#rest.call("POST", `${toolbox.value}/files/upload-v2?${new URLSearchParams({ path: staging })}`, { form, retry: true, timeoutMs: this.#timeouts.uploadMs }, signal);
744
+ const uploaded = await this.#upload(toolbox.value, staging, daemon, signal);
774
745
  if (!uploaded.ok)
775
746
  return fail(uploaded.error.code, `the daemon's upload was refused: ${uploaded.error.message}`);
776
747
  // Init's flags are built here (childCommands): every remote computer, an Archil one included, starts init with
@@ -800,6 +771,7 @@ export class DaytonaProvider {
800
771
  self: ref,
801
772
  releaseOlder: () => releaseOlder(this, run, epoch, signal ? { signal } : {}),
802
773
  timeoutMs: this.#timeouts.execMs,
774
+ ...(this.#archilEgress ? { egress: this.#archilEgress } : {}),
803
775
  ...(signal ? { signal } : {}),
804
776
  });
805
777
  if (!mounted.ok)
@@ -863,7 +835,7 @@ export class DaytonaProvider {
863
835
  return ran;
864
836
  const commandId = ran.value?.cmdId;
865
837
  if (typeof commandId !== "string")
866
- return fail("daytona", "POST exec: no command id in the answer");
838
+ return vendorFail("daytona", "POST exec: no command id in the answer");
867
839
  const command = `${session}/command/${encodeURIComponent(commandId)}`;
868
840
  if (stdin !== undefined) {
869
841
  // Its words never carry stdin: it is the disk's token.
@@ -897,7 +869,7 @@ export class DaytonaProvider {
897
869
  };
898
870
  }
899
871
  #sandboxExpected(deadline, gpu = false) {
900
- return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDeleteFor(gpu) };
872
+ return { deadline, sandboxClass: this.#class, autoStopInterval: this.#autoStop, autoDeleteInterval: this.#autoDeleteFor(gpu), gpu: this.#gpu };
901
873
  }
902
874
  /** The autoDeleteInterval a sandbox is made and read back with: 0 for a GPU sandbox, which a stop deletes; else the option's. */
903
875
  #autoDeleteFor(gpu) {
@@ -916,7 +888,7 @@ export class DaytonaProvider {
916
888
  return ok(current);
917
889
  if (current === undefined || GONE.has(current.state ?? "") || current.state === "error" || current.state === "build_failed") {
918
890
  const reason = current?.errorReason ? `: ${current.errorReason}` : "";
919
- return fail("daytona", `the sandbox went to ${current?.state ?? "deleted"} while starting${reason}`);
891
+ return vendorFail("daytona", `the sandbox went to ${current?.state ?? "deleted"} while starting${reason}`);
920
892
  }
921
893
  if (!first && Date.now() >= end)
922
894
  return fail("timeout", `the sandbox did not start within ${this.#timeouts.startMs / 1000} s (state ${current.state})`);
@@ -931,7 +903,7 @@ export class DaytonaProvider {
931
903
  }
932
904
  }
933
905
  /**
934
- * Daytona's label listing trails a create (pi-transport measured 0.7 to 1.6 s, with flaps), and list() must show a
906
+ * Daytona's label listing trails a create (measured 0.7 to 1.6 s, with flaps), and list() must show a
935
907
  * computer once create returns: create waits until the listing has shown it, without a miss, for listedStableMs.
936
908
  */
937
909
  async #waitListed(id, signal) {
@@ -971,12 +943,32 @@ export class DaytonaProvider {
971
943
  url = new URL(proxy ?? "");
972
944
  }
973
945
  catch {
974
- return fail("daytona", `Daytona gave no toolbox URL for ${sb.id}`);
946
+ return vendorFail("daytona", `Daytona gave no toolbox URL for ${sb.id}`);
975
947
  }
976
948
  if (url.protocol !== "https:")
977
- return fail("daytona", `the toolbox URL Daytona gave is not https (${url.protocol}), so the key is not sent to it`);
949
+ return vendorFail("daytona", `the toolbox URL Daytona gave is not https (${url.protocol}), so the key is not sent to it`);
978
950
  return ok(`${url.href.replace(/\/+$/, "")}/${encodeURIComponent(sb.id)}`);
979
951
  }
952
+ /**
953
+ * A file's bytes to `path` in the sandbox: files/upload-v2, else files/upload. An older toolbox, as a self-hosted
954
+ * Daytona's runners may run (the open daemon's routes, daytonaio/daytona@b5a5d9e7 apps/daemon/pkg/toolbox/server.go),
955
+ * has no files/upload-v2 and answers it 404; its files/upload takes the same form (a path query, the bytes as
956
+ * "file"). A 404 alone moves to the older route, so a refusal of any other kind is never sent twice.
957
+ */
958
+ async #upload(toolbox, path, bytes, signal) {
959
+ const query = new URLSearchParams({ path });
960
+ const send = (route, answerStatus) => {
961
+ const form = new FormData();
962
+ form.append("file", new Blob([new Uint8Array(bytes)]), "computerd");
963
+ return this.#rest.call("POST", `${toolbox}/${route}?${query}`, { form, retry: true, timeoutMs: this.#timeouts.uploadMs, ...(answerStatus === undefined ? {} : { answerStatus }) }, signal);
964
+ };
965
+ const current = await send("files/upload-v2", 404);
966
+ if (!current.ok || current.value.status !== 404)
967
+ return current;
968
+ const missing = `POST ${new URL(`${toolbox}/files/upload-v2`).pathname}: 404 ${decoder.decode(current.value.bytes).replace(/\s+/g, " ").trim().slice(0, 300)}`;
969
+ const older = await send("files/upload");
970
+ return older.ok ? older : fail(older.error.code, `${missing}, then ${older.error.message}`);
971
+ }
980
972
  async #execute(toolbox, command, signal) {
981
973
  const seconds = Math.ceil(this.#timeouts.execMs / 1000);
982
974
  const ran = await this.#rest.json("POST", `${toolbox}/process/execute`, { json: { command, timeout: seconds }, timeoutMs: this.#timeouts.execMs + 15_000 }, signal);
@@ -1017,7 +1009,7 @@ export class DaytonaProvider {
1017
1009
  const commandId = ran.ok ? ran.value?.cmdId : undefined;
1018
1010
  if (!ran.ok || typeof commandId !== "string") {
1019
1011
  await removeSession();
1020
- return ran.ok ? fail("daytona", "POST exec: no command id in the answer") : ran;
1012
+ return ran.ok ? vendorFail("daytona", "POST exec: no command id in the answer") : ran;
1021
1013
  }
1022
1014
  const command = `${session}/command/${encodeURIComponent(commandId)}`;
1023
1015
  const logs = `${command.replace(/^https:/, "wss:")}/logs?follow=true`;
@@ -1027,7 +1019,7 @@ export class DaytonaProvider {
1027
1019
  }
1028
1020
  catch (error) {
1029
1021
  await removeSession();
1030
- return fail("daytona", `opening the log stream: ${error.message}`);
1022
+ return vendorFail("daytona", `opening the log stream: ${error.message}`);
1031
1023
  }
1032
1024
  const stream = sessionStream(socket, async (data) => {
1033
1025
  const sent = await this.#rest.call("POST", `${command}/input`, { json: { data } });
@@ -1070,7 +1062,7 @@ export class DaytonaProvider {
1070
1062
  return timedOut();
1071
1063
  if (hello.error.code !== "gone")
1072
1064
  return hello;
1073
- return fail("daytona", `cannot reach the daemon in ${sb.name ?? sb.id}: ${stream.stderr() || hello.error.message}`);
1065
+ return vendorFail("daytona", `cannot reach the daemon in ${sb.name ?? sb.id}: ${stream.stderr() || hello.error.message}`);
1074
1066
  }
1075
1067
  return ok({ client, hello: hello.value, close });
1076
1068
  }
@@ -1231,7 +1223,7 @@ export class DaytonaProvider {
1231
1223
  },
1232
1224
  });
1233
1225
  }
1234
- /** Every sandbox with this provider's label, all pages: one label query, the way pi-transport asks. */
1226
+ /** Every sandbox with this provider's label, all pages: one label query. */
1235
1227
  async #listOwn(signal) {
1236
1228
  const found = [];
1237
1229
  const seen = new Set();
@@ -1246,17 +1238,17 @@ export class DaytonaProvider {
1246
1238
  const value = answer.value;
1247
1239
  const items = Array.isArray(value) ? value : Array.isArray(value?.items) ? value.items : undefined;
1248
1240
  if (items === undefined)
1249
- return fail("daytona", "GET /sandbox: the listing is not a page of sandboxes");
1241
+ return vendorFail("daytona", "GET /sandbox: the listing is not a page of sandboxes");
1250
1242
  found.push(...items);
1251
1243
  const next = Array.isArray(value) ? undefined : value?.nextCursor;
1252
1244
  if (typeof next !== "string" || next === "")
1253
1245
  return ok(found);
1254
1246
  if (seen.has(next))
1255
- return fail("daytona", `GET /sandbox: the listing's cursor ${next} came back twice`);
1247
+ return vendorFail("daytona", `GET /sandbox: the listing's cursor ${next} came back twice`);
1256
1248
  seen.add(next);
1257
1249
  cursor = next;
1258
1250
  }
1259
- return fail("daytona", `GET /sandbox: the listing ran past ${MAX_PAGES} pages`);
1251
+ return vendorFail("daytona", `GET /sandbox: the listing ran past ${MAX_PAGES} pages`);
1260
1252
  }
1261
1253
  /**
1262
1254
  * For the sweep after a live run: every sandbox Daytona lists with agentrun.computer=1, whatever its name or state, as
@@ -1294,7 +1286,7 @@ export class DaytonaProvider {
1294
1286
  const value = answer.value;
1295
1287
  const items = Array.isArray(value) ? value : Array.isArray(value?.items) ? value.items : undefined;
1296
1288
  if (items === undefined)
1297
- return countTested("Daytona", fail("daytona", "GET /sandbox: the listing is not a page of sandboxes"));
1289
+ return countTested("Daytona", vendorFail("daytona", "GET /sandbox: the listing is not a page of sandboxes"));
1298
1290
  const next = Array.isArray(value) ? undefined : value?.nextCursor;
1299
1291
  return countTested("Daytona", ok({ count: items.filter((item) => ours(item) && !going(item)).length, more: typeof next === "string" && next !== "" }));
1300
1292
  }
@@ -1505,7 +1497,7 @@ export class DaytonaProvider {
1505
1497
  const sb = got.value;
1506
1498
  last = stateWords(sb);
1507
1499
  if (sb !== undefined && (sb.state === "error" || sb.state === "build_failed") && sb.desiredState !== "destroyed") {
1508
- return { failed: fail("daytona", `release ${how} of ${ref.name}: it went to ${sb.state}${sb.errorReason ? `: ${sb.errorReason}` : ""}`) };
1500
+ return { failed: vendorFail("daytona", `release ${how} of ${ref.name}: it went to ${sb.state}${sb.errorReason ? `: ${sb.errorReason}` : ""}`) };
1509
1501
  }
1510
1502
  const gone = sb === undefined || sb.state === "destroyed";
1511
1503
  const reached = gone ? "gone" : want === "stopped" && STOPPED.has(sb.state ?? "") ? "stopped" : undefined;
@@ -1546,7 +1538,7 @@ export class DaytonaProvider {
1546
1538
  return "failed" in waited.value ? waited.value.failed : ok(undefined);
1547
1539
  }
1548
1540
  /**
1549
- * Deletes a sandbox and makes sure it is going, as pi-transport does: a DELETE that fails counts as done only when the
1541
+ * Deletes a sandbox and makes sure it is going: a DELETE that fails counts as done only when the
1550
1542
  * sandbox is gone or being destroyed; a forced stop comes before the last attempt. Never signalled: a delete that
1551
1543
  * cleans up after an abort must outlive it.
1552
1544
  */
@@ -1565,6 +1557,6 @@ export class DaytonaProvider {
1565
1557
  if (attempt < DELETE_ATTEMPTS)
1566
1558
  await sleep(this.#timeouts.retryMs);
1567
1559
  }
1568
- return { ok: false, error: failure ?? { code: "daytona", message: `could not delete ${idOrName}` } };
1560
+ return { ok: false, error: failure ?? { code: "vendor", vendor: "daytona", message: `could not delete ${idOrName}` } };
1569
1561
  }
1570
1562
  }