@parcha/agentrun-computer 0.1.0-beta.34 → 0.1.0-beta.35
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.
- package/README.md +144 -26
- package/dist/browser.d.ts +12 -13
- package/dist/browser.js +16 -14
- package/dist/browserbase.d.ts +3 -5
- package/dist/browserbase.js +16 -13
- package/dist/chrome.js +1 -1
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/provider.js +78 -3
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
- package/dist/conformance/{local.js → local-chrome.js} +11 -11
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +3 -2
- package/dist/conformance/runner.js +25 -7
- package/dist/conformance/types.d.ts +21 -8
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +3 -34
- package/dist/daytona.js +34 -61
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -6
- package/dist/docker.js +46 -42
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +16 -22
- package/dist/index.d.ts +8 -11
- package/dist/index.js +13 -11
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -5
- package/dist/kernel.js +19 -16
- package/dist/kinds.d.ts +54 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +12 -0
- package/dist/labels.js +39 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
- package/dist/{local.js → local-chrome.js} +19 -16
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +3 -22
- package/dist/modal.js +15 -31
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -15
- package/dist/orgo.js +46 -107
- package/dist/phone-harness.d.ts +4 -10
- package/dist/phone-harness.js +45 -46
- package/dist/provider.d.ts +91 -10
- package/dist/provider.js +42 -0
- package/dist/providers.d.ts +23 -24
- package/dist/providers.js +14 -17
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
|
@@ -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
|
|
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. */
|
|
@@ -87,36 +87,7 @@ 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
|
|
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. */
|
|
90
|
+
/** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
|
|
120
91
|
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
121
92
|
/** What create() takes: the provider's options, the daemon optional (default this package's build for the arch). */
|
|
122
93
|
export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> & {
|
|
@@ -130,8 +101,6 @@ export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> &
|
|
|
130
101
|
export declare function create(options: DaytonaCreateOptions): DaytonaProvider;
|
|
131
102
|
/** The conformance CLI's module for Daytona: the run's idle stop and auto-delete, its snapshot, notes and drifted twin. */
|
|
132
103
|
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
104
|
/**
|
|
136
105
|
* The three commands the provider sends into a sandbox, exactly: install (through /process/execute), init and stdio
|
|
137
106
|
* (each a session command), the child daemon's commands (childCommands). Exported so a test can run them where Daytona
|
|
@@ -205,5 +174,5 @@ export declare class DaytonaProvider implements ComputerProvider {
|
|
|
205
174
|
* Daytona answers a delete or a stop before the sandbox is gone or stopped, and its listing trails both: release
|
|
206
175
|
* returns once Daytona reads the computer as release left it, or fails naming the last state it read.
|
|
207
176
|
*/
|
|
208
|
-
release(ref: ComputerRef, how:
|
|
177
|
+
release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
|
|
209
178
|
}
|
package/dist/daytona.js
CHANGED
|
@@ -10,59 +10,34 @@ import { fileURLToPath } from "node:url";
|
|
|
10
10
|
import { childCommands, daemonDrift, installerOf, shellCommand } from "./child.js";
|
|
11
11
|
import { OWN_NETWORK_ONLY, readOwnNetwork, TOOL_USER } from "./isolation.js";
|
|
12
12
|
import { DaemonClient } from "./client.js";
|
|
13
|
+
import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, DAYTONA_GPU_SNAPSHOT_GPU } from "./descriptors/daytona.js";
|
|
13
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
18
|
import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilLabels, archilMount, archilRefusals, archilRelease, mountDrift, readArchilMount, recordedMount, syncingClient, } from "./mount-archil.js";
|
|
18
19
|
import { MAX_LINE_BYTES } from "./protocol.js";
|
|
19
|
-
import { checkGpu,
|
|
20
|
-
import {
|
|
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 =
|
|
29
|
-
/**
|
|
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. */
|
|
31
|
+
export const MOUNT = DAYTONA.mounts;
|
|
32
|
+
/** A copy of its descriptor's DAYTONA_GPU, so no caller can change the provider's own. */
|
|
58
33
|
const daytonaGpuCapability = () => ({
|
|
59
34
|
...DAYTONA_GPU,
|
|
60
35
|
types: [...DAYTONA_GPU.types],
|
|
61
36
|
perGpu: { ...DAYTONA_GPU.perGpu },
|
|
62
37
|
mounts: [],
|
|
63
38
|
});
|
|
64
|
-
/** The machine kind, groups and GPUs of its one configuration: a linux computer, with GPUs when asked. */
|
|
65
|
-
export const CAPABILITIES =
|
|
39
|
+
/** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
|
|
40
|
+
export const CAPABILITIES = DAYTONA.capabilities;
|
|
66
41
|
/**
|
|
67
42
|
* A DaytonaProvider from its options alone; it reads no environment, so the key, the API URL (default Daytona's own) and
|
|
68
43
|
* the target are the caller's: serve passes its DAYTONA_API_KEY, DAYTONA_API_URL and DAYTONA_TARGET, the conformance
|
|
@@ -82,8 +57,6 @@ export function create(options) {
|
|
|
82
57
|
export const conformance = () => import("./conformance/daytona.js");
|
|
83
58
|
const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
84
59
|
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
60
|
/** The label, in the provider's own namespace beside the deadline's, that holds the image create was asked for: Daytona
|
|
88
61
|
* reports only the snapshot it resolved that image to, a name of its own for "default". */
|
|
89
62
|
const IMAGE_LABEL = `${COMPUTER_LABEL}.image`;
|
|
@@ -324,7 +297,7 @@ function codeOf(status, text) {
|
|
|
324
297
|
return "limit";
|
|
325
298
|
if (status === 400 || status === 409 || status === 422)
|
|
326
299
|
return "invalid";
|
|
327
|
-
return "
|
|
300
|
+
return "vendor";
|
|
328
301
|
}
|
|
329
302
|
/** Whether fetch failed on a redirect it was told not to follow. */
|
|
330
303
|
function redirected(cause) {
|
|
@@ -387,7 +360,7 @@ class Rest {
|
|
|
387
360
|
return ok({ status: response.status, bytes });
|
|
388
361
|
const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
|
|
389
362
|
retryable = response.status === 429 || response.status >= 500;
|
|
390
|
-
failure =
|
|
363
|
+
failure = errorOf(codeOf(response.status, text), `${what}: ${response.status} ${text}`, "daytona");
|
|
391
364
|
}
|
|
392
365
|
catch (cause) {
|
|
393
366
|
if (signal?.aborted)
|
|
@@ -395,9 +368,9 @@ class Rest {
|
|
|
395
368
|
if (timeout.aborted)
|
|
396
369
|
failure = { code: "timeout", message: `${what} did not answer within ${timeoutMs / 1000} s` };
|
|
397
370
|
else if (redirected(cause))
|
|
398
|
-
return
|
|
371
|
+
return vendorFail("daytona", `${what}: Daytona answered with a redirect, which is never followed: it would carry the key`);
|
|
399
372
|
else
|
|
400
|
-
failure = { code: "daytona", message: `${what}: ${cause.message}` };
|
|
373
|
+
failure = { code: "vendor", vendor: "daytona", message: `${what}: ${cause.message}` };
|
|
401
374
|
}
|
|
402
375
|
if (!retryable || attempt >= attempts)
|
|
403
376
|
return { ok: false, error: failure };
|
|
@@ -414,7 +387,7 @@ class Rest {
|
|
|
414
387
|
if (!found.ok)
|
|
415
388
|
return found.error.code === "not_found" ? ok(undefined) : found;
|
|
416
389
|
const sb = found.value;
|
|
417
|
-
return typeof sb?.id === "string" ? ok(sb) :
|
|
390
|
+
return typeof sb?.id === "string" ? ok(sb) : vendorFail("daytona", `GET /sandbox/${idOrName}: no sandbox in the answer`);
|
|
418
391
|
}
|
|
419
392
|
}
|
|
420
393
|
/** Every way a sandbox, as Daytona reads it back, differs from what create asked for. Pure: no call. */
|
|
@@ -515,12 +488,12 @@ function sessionStream(socket, send) {
|
|
|
515
488
|
lines(Buffer.from(data), false);
|
|
516
489
|
});
|
|
517
490
|
socket.addEventListener("error", (event) => {
|
|
518
|
-
opened(
|
|
491
|
+
opened(vendorFail("daytona", `the log stream failed: ${event.message ?? "no reason given"}`));
|
|
519
492
|
if (!readable.destroyed)
|
|
520
493
|
readable.destroy(new Error(`the log stream failed${event.message ? `: ${event.message}` : ""}`));
|
|
521
494
|
});
|
|
522
495
|
socket.addEventListener("close", ({ code }) => {
|
|
523
|
-
opened(
|
|
496
|
+
opened(vendorFail("daytona", `the log stream closed before it opened (code ${code ?? "none"})`));
|
|
524
497
|
if (readable.destroyed)
|
|
525
498
|
return;
|
|
526
499
|
lines(Buffer.alloc(0), true);
|
|
@@ -615,7 +588,7 @@ export class DaytonaProvider {
|
|
|
615
588
|
return {
|
|
616
589
|
kind: "linux",
|
|
617
590
|
lifetime: "vendor",
|
|
618
|
-
network: [...
|
|
591
|
+
network: [...DAYTONA.network],
|
|
619
592
|
isolation: this.#class === "linux-vm" ? "vm" : "container",
|
|
620
593
|
os: "linux",
|
|
621
594
|
daemon: "child",
|
|
@@ -639,7 +612,7 @@ export class DaytonaProvider {
|
|
|
639
612
|
refuse("image", `an image is required: the id or name of a Daytona snapshot, or "${DAYTONA_DEFAULT_SNAPSHOT}" for Daytona's default snapshot`);
|
|
640
613
|
else if (/[\0-\x1f]/.test(image))
|
|
641
614
|
refuse("image", "a snapshot name has no control characters");
|
|
642
|
-
refusals.push(...
|
|
615
|
+
refusals.push(...checkTenure(given, this.capabilities(), "Daytona"));
|
|
643
616
|
if (network === "open" || (typeof network === "object" && network !== null && "allow" in network))
|
|
644
617
|
refuse("network", OWN_NETWORK_ONLY);
|
|
645
618
|
else if (network !== "none")
|
|
@@ -695,7 +668,7 @@ 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
|
|
671
|
+
const deadline = new Date(Date.now() + runLifetimeMs(spec)).toISOString();
|
|
699
672
|
const archil = archilOf(spec);
|
|
700
673
|
const body = {
|
|
701
674
|
name,
|
|
@@ -708,7 +681,7 @@ export class DaytonaProvider {
|
|
|
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
|
|
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
|
|
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.
|
|
@@ -863,7 +836,7 @@ export class DaytonaProvider {
|
|
|
863
836
|
return ran;
|
|
864
837
|
const commandId = ran.value?.cmdId;
|
|
865
838
|
if (typeof commandId !== "string")
|
|
866
|
-
return
|
|
839
|
+
return vendorFail("daytona", "POST exec: no command id in the answer");
|
|
867
840
|
const command = `${session}/command/${encodeURIComponent(commandId)}`;
|
|
868
841
|
if (stdin !== undefined) {
|
|
869
842
|
// Its words never carry stdin: it is the disk's token.
|
|
@@ -916,7 +889,7 @@ export class DaytonaProvider {
|
|
|
916
889
|
return ok(current);
|
|
917
890
|
if (current === undefined || GONE.has(current.state ?? "") || current.state === "error" || current.state === "build_failed") {
|
|
918
891
|
const reason = current?.errorReason ? `: ${current.errorReason}` : "";
|
|
919
|
-
return
|
|
892
|
+
return vendorFail("daytona", `the sandbox went to ${current?.state ?? "deleted"} while starting${reason}`);
|
|
920
893
|
}
|
|
921
894
|
if (!first && Date.now() >= end)
|
|
922
895
|
return fail("timeout", `the sandbox did not start within ${this.#timeouts.startMs / 1000} s (state ${current.state})`);
|
|
@@ -971,10 +944,10 @@ export class DaytonaProvider {
|
|
|
971
944
|
url = new URL(proxy ?? "");
|
|
972
945
|
}
|
|
973
946
|
catch {
|
|
974
|
-
return
|
|
947
|
+
return vendorFail("daytona", `Daytona gave no toolbox URL for ${sb.id}`);
|
|
975
948
|
}
|
|
976
949
|
if (url.protocol !== "https:")
|
|
977
|
-
return
|
|
950
|
+
return vendorFail("daytona", `the toolbox URL Daytona gave is not https (${url.protocol}), so the key is not sent to it`);
|
|
978
951
|
return ok(`${url.href.replace(/\/+$/, "")}/${encodeURIComponent(sb.id)}`);
|
|
979
952
|
}
|
|
980
953
|
async #execute(toolbox, command, signal) {
|
|
@@ -1017,7 +990,7 @@ export class DaytonaProvider {
|
|
|
1017
990
|
const commandId = ran.ok ? ran.value?.cmdId : undefined;
|
|
1018
991
|
if (!ran.ok || typeof commandId !== "string") {
|
|
1019
992
|
await removeSession();
|
|
1020
|
-
return ran.ok ?
|
|
993
|
+
return ran.ok ? vendorFail("daytona", "POST exec: no command id in the answer") : ran;
|
|
1021
994
|
}
|
|
1022
995
|
const command = `${session}/command/${encodeURIComponent(commandId)}`;
|
|
1023
996
|
const logs = `${command.replace(/^https:/, "wss:")}/logs?follow=true`;
|
|
@@ -1027,7 +1000,7 @@ export class DaytonaProvider {
|
|
|
1027
1000
|
}
|
|
1028
1001
|
catch (error) {
|
|
1029
1002
|
await removeSession();
|
|
1030
|
-
return
|
|
1003
|
+
return vendorFail("daytona", `opening the log stream: ${error.message}`);
|
|
1031
1004
|
}
|
|
1032
1005
|
const stream = sessionStream(socket, async (data) => {
|
|
1033
1006
|
const sent = await this.#rest.call("POST", `${command}/input`, { json: { data } });
|
|
@@ -1070,7 +1043,7 @@ export class DaytonaProvider {
|
|
|
1070
1043
|
return timedOut();
|
|
1071
1044
|
if (hello.error.code !== "gone")
|
|
1072
1045
|
return hello;
|
|
1073
|
-
return
|
|
1046
|
+
return vendorFail("daytona", `cannot reach the daemon in ${sb.name ?? sb.id}: ${stream.stderr() || hello.error.message}`);
|
|
1074
1047
|
}
|
|
1075
1048
|
return ok({ client, hello: hello.value, close });
|
|
1076
1049
|
}
|
|
@@ -1246,17 +1219,17 @@ export class DaytonaProvider {
|
|
|
1246
1219
|
const value = answer.value;
|
|
1247
1220
|
const items = Array.isArray(value) ? value : Array.isArray(value?.items) ? value.items : undefined;
|
|
1248
1221
|
if (items === undefined)
|
|
1249
|
-
return
|
|
1222
|
+
return vendorFail("daytona", "GET /sandbox: the listing is not a page of sandboxes");
|
|
1250
1223
|
found.push(...items);
|
|
1251
1224
|
const next = Array.isArray(value) ? undefined : value?.nextCursor;
|
|
1252
1225
|
if (typeof next !== "string" || next === "")
|
|
1253
1226
|
return ok(found);
|
|
1254
1227
|
if (seen.has(next))
|
|
1255
|
-
return
|
|
1228
|
+
return vendorFail("daytona", `GET /sandbox: the listing's cursor ${next} came back twice`);
|
|
1256
1229
|
seen.add(next);
|
|
1257
1230
|
cursor = next;
|
|
1258
1231
|
}
|
|
1259
|
-
return
|
|
1232
|
+
return vendorFail("daytona", `GET /sandbox: the listing ran past ${MAX_PAGES} pages`);
|
|
1260
1233
|
}
|
|
1261
1234
|
/**
|
|
1262
1235
|
* For the sweep after a live run: every sandbox Daytona lists with agentrun.computer=1, whatever its name or state, as
|
|
@@ -1294,7 +1267,7 @@ export class DaytonaProvider {
|
|
|
1294
1267
|
const value = answer.value;
|
|
1295
1268
|
const items = Array.isArray(value) ? value : Array.isArray(value?.items) ? value.items : undefined;
|
|
1296
1269
|
if (items === undefined)
|
|
1297
|
-
return countTested("Daytona",
|
|
1270
|
+
return countTested("Daytona", vendorFail("daytona", "GET /sandbox: the listing is not a page of sandboxes"));
|
|
1298
1271
|
const next = Array.isArray(value) ? undefined : value?.nextCursor;
|
|
1299
1272
|
return countTested("Daytona", ok({ count: items.filter((item) => ours(item) && !going(item)).length, more: typeof next === "string" && next !== "" }));
|
|
1300
1273
|
}
|
|
@@ -1505,7 +1478,7 @@ export class DaytonaProvider {
|
|
|
1505
1478
|
const sb = got.value;
|
|
1506
1479
|
last = stateWords(sb);
|
|
1507
1480
|
if (sb !== undefined && (sb.state === "error" || sb.state === "build_failed") && sb.desiredState !== "destroyed") {
|
|
1508
|
-
return { failed:
|
|
1481
|
+
return { failed: vendorFail("daytona", `release ${how} of ${ref.name}: it went to ${sb.state}${sb.errorReason ? `: ${sb.errorReason}` : ""}`) };
|
|
1509
1482
|
}
|
|
1510
1483
|
const gone = sb === undefined || sb.state === "destroyed";
|
|
1511
1484
|
const reached = gone ? "gone" : want === "stopped" && STOPPED.has(sb.state ?? "") ? "stopped" : undefined;
|
|
@@ -1565,6 +1538,6 @@ export class DaytonaProvider {
|
|
|
1565
1538
|
if (attempt < DELETE_ATTEMPTS)
|
|
1566
1539
|
await sleep(this.#timeouts.retryMs);
|
|
1567
1540
|
}
|
|
1568
|
-
return { ok: false, error: failure ?? { code: "daytona", message: `could not delete ${idOrName}` } };
|
|
1541
|
+
return { ok: false, error: failure ?? { code: "vendor", vendor: "daytona", message: `could not delete ${idOrName}` } };
|
|
1569
1542
|
}
|
|
1570
1543
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ComputerSettingKind, KindCapabilities } from "./kinds.js";
|
|
2
|
+
import type { MountKind } from "./mount.js";
|
|
3
|
+
import type { NetworkForm } from "./provider.js";
|
|
4
|
+
import type { ProviderModule } from "./providers.js";
|
|
5
|
+
/** One key a provider takes in Settings: its serve-side name, the create() option it fills, and whether it is needed. */
|
|
6
|
+
export interface DescriptorKey {
|
|
7
|
+
/** The name Settings stores it under and shows (DAYTONA_API_KEY); never a value. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The create() option it fills (apiKey). */
|
|
10
|
+
readonly option: string;
|
|
11
|
+
readonly required: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A setting that is no key but fills a create() option, with the value used when the server names none. */
|
|
14
|
+
export interface DescriptorSetting {
|
|
15
|
+
/** Its name in the server's settings (modalApp). */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** The create() option it fills (app). */
|
|
18
|
+
readonly option: string;
|
|
19
|
+
/** The value when the server's settings name none. */
|
|
20
|
+
readonly default?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A configuration its module builds but the provider does not offer yet: its kind, groups, image and create() options,
|
|
24
|
+
* as an offered one's, and why it is parked, in words. The conformance suite holds a built one to it as to an offered one.
|
|
25
|
+
*/
|
|
26
|
+
export type ParkedConfiguration = KindCapabilities & {
|
|
27
|
+
readonly image: string;
|
|
28
|
+
readonly why: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A provider, declared once. Every field is data but load(), which imports the provider module only when called:
|
|
32
|
+
* reading a descriptor loads no provider and no vendor SDK.
|
|
33
|
+
*/
|
|
34
|
+
export interface ProviderDescriptor<Module extends ProviderModule = ProviderModule> {
|
|
35
|
+
/** Its id, in the provider registry and in Settings: lowercase letters, digits and hyphens. */
|
|
36
|
+
readonly id: string;
|
|
37
|
+
/** Its name in words, as Settings shows it. */
|
|
38
|
+
readonly label: string;
|
|
39
|
+
/** The keys Settings takes for it, by name, and the option each fills; [] for none (Docker's host is local). */
|
|
40
|
+
readonly keys: readonly DescriptorKey[];
|
|
41
|
+
/** Settings that are no key but go to its options (Modal's app). */
|
|
42
|
+
readonly settings?: readonly DescriptorSetting[];
|
|
43
|
+
/** The vendor bills by time; prices are the vendor's page, not ours. */
|
|
44
|
+
readonly metered: boolean;
|
|
45
|
+
/** The mount kinds its computers take, as its providers' capabilities().mount declare them; [] for none. */
|
|
46
|
+
readonly mounts: readonly MountKind[];
|
|
47
|
+
/**
|
|
48
|
+
* The network forms its computers make, as its providers' capabilities().network declare them: ["none"], a remote
|
|
49
|
+
* computer whose programs run in a network of their own; ["open"], the vendor's own network, which no allowlist of
|
|
50
|
+
* this server reaches; Docker's makes all three. A provider of several configurations declares every form they make.
|
|
51
|
+
*/
|
|
52
|
+
readonly network: readonly NetworkForm[];
|
|
53
|
+
/**
|
|
54
|
+
* The machine kind and groups of each configuration it offers, as each built provider's capabilities() declare them;
|
|
55
|
+
* where it offers more than one image of a kind, each one's image (the name a setting selects it by) and the create()
|
|
56
|
+
* options that build it (KindCapabilities).
|
|
57
|
+
*/
|
|
58
|
+
readonly capabilities: readonly KindCapabilities[];
|
|
59
|
+
/**
|
|
60
|
+
* The image a computer of each setting kind starts from when its setting names none. A kind with no entry has no
|
|
61
|
+
* default, and the caller refuses the setting in words (Docker's sandbox: the server builds its image, prepareImage).
|
|
62
|
+
*/
|
|
63
|
+
readonly defaultImage?: Partial<Record<ComputerSettingKind, string>>;
|
|
64
|
+
/** Its built providers have prepareImage(): the image a computer starts from is made or pulled before the first create. */
|
|
65
|
+
readonly prepareImage?: boolean;
|
|
66
|
+
/** Its computers run on this machine's container engine: a server passes it its local host options (volume, host addresses). */
|
|
67
|
+
readonly local?: boolean;
|
|
68
|
+
/** create() takes a ledger the server keeps for it, as `options[ledger.option]` (the phone harness's sessions). */
|
|
69
|
+
readonly ledger?: {
|
|
70
|
+
readonly option: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The server's own environment variables its provider reads on this machine, by name (Local Chrome's, where it finds
|
|
74
|
+
* Chrome): a server passes their values, and no other variable of its own, as `options.env`. The provider itself reads
|
|
75
|
+
* no environment.
|
|
76
|
+
*/
|
|
77
|
+
readonly hostEnv?: readonly string[];
|
|
78
|
+
/**
|
|
79
|
+
* Configurations its module builds but does not offer yet (Orgo's Windows and macOS desktops), each by the image a
|
|
80
|
+
* setting would name and why: a setting naming one is refused in its words, saying it is parked, never as an unknown
|
|
81
|
+
* image. No setting kind lists one, and Settings never offers one.
|
|
82
|
+
*/
|
|
83
|
+
readonly parked?: readonly ParkedConfiguration[];
|
|
84
|
+
/** The provider module, loaded on demand: its create(), its conformance module. */
|
|
85
|
+
load(): Promise<Module>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A descriptor, checked: its id's shape, its keys' and settings' names and options unique and non-empty, and one
|
|
89
|
+
* configuration at least. Throws in words naming what is wrong, so a bad descriptor never reaches a registry. The const
|
|
90
|
+
* type parameter keeps its literal id and its module's type, so ProviderOptions can read a create()'s options from it.
|
|
91
|
+
*/
|
|
92
|
+
export declare function defineProvider<const Descriptor extends ProviderDescriptor>(descriptor: Descriptor): Descriptor;
|
|
93
|
+
/** What is wrong with a value offered as a descriptor, in words; none when it is one. */
|
|
94
|
+
export declare function descriptorProblems(value: unknown): string[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const ID = /^[a-z0-9][a-z0-9-]*$/;
|
|
2
|
+
/**
|
|
3
|
+
* A descriptor, checked: its id's shape, its keys' and settings' names and options unique and non-empty, and one
|
|
4
|
+
* configuration at least. Throws in words naming what is wrong, so a bad descriptor never reaches a registry. The const
|
|
5
|
+
* type parameter keeps its literal id and its module's type, so ProviderOptions can read a create()'s options from it.
|
|
6
|
+
*/
|
|
7
|
+
export function defineProvider(descriptor) {
|
|
8
|
+
const problems = descriptorProblems(descriptor);
|
|
9
|
+
if (problems.length > 0)
|
|
10
|
+
throw new Error(`the provider descriptor ${JSON.stringify(descriptor?.id)}: ${problems.join("; ")}`);
|
|
11
|
+
return descriptor;
|
|
12
|
+
}
|
|
13
|
+
/** What is wrong with a value offered as a descriptor, in words; none when it is one. */
|
|
14
|
+
export function descriptorProblems(value) {
|
|
15
|
+
if (typeof value !== "object" || value === null)
|
|
16
|
+
return ["it is not an object"];
|
|
17
|
+
const d = value;
|
|
18
|
+
const problems = [];
|
|
19
|
+
if (typeof d.id !== "string" || !ID.test(d.id))
|
|
20
|
+
problems.push(`id ${JSON.stringify(d.id)} is not lowercase letters, digits and hyphens`);
|
|
21
|
+
if (typeof d.label !== "string" || d.label.trim() === "")
|
|
22
|
+
problems.push("label is not a name in words");
|
|
23
|
+
if (typeof d.metered !== "boolean")
|
|
24
|
+
problems.push("metered is not true or false");
|
|
25
|
+
if (typeof d.load !== "function")
|
|
26
|
+
problems.push("load is not a function that imports the provider module");
|
|
27
|
+
if (!Array.isArray(d.mounts) || d.mounts.some((kind) => kind !== "bind" && kind !== "archil"))
|
|
28
|
+
problems.push("mounts is not a list of mount kinds (bind, archil)");
|
|
29
|
+
if (!Array.isArray(d.network) || d.network.length === 0 || d.network.some((form) => form !== "none" && form !== "open" && form !== "allow"))
|
|
30
|
+
problems.push("network is not a list of the network forms its computers make (none, open, allow)");
|
|
31
|
+
if (!Array.isArray(d.capabilities) || d.capabilities.length === 0)
|
|
32
|
+
problems.push("capabilities is not a list of one configuration or more");
|
|
33
|
+
else if (d.capabilities.some((one) => typeof one?.kind !== "string" || !Array.isArray(one.groups)))
|
|
34
|
+
problems.push("each configuration is a machine kind and its groups");
|
|
35
|
+
else {
|
|
36
|
+
const images = new Set();
|
|
37
|
+
for (const one of d.capabilities) {
|
|
38
|
+
if (one.image !== undefined && (typeof one.image !== "string" || one.image.trim() === "" || one.image !== one.image.trim()))
|
|
39
|
+
problems.push(`a configuration's image ${JSON.stringify(one.image)} is not a name`);
|
|
40
|
+
else if (one.image !== undefined && images.has(`${one.kind} ${one.image}`))
|
|
41
|
+
problems.push(`two ${one.kind} configurations have the image ${one.image}`);
|
|
42
|
+
else if (one.image !== undefined)
|
|
43
|
+
images.add(`${one.kind} ${one.image}`);
|
|
44
|
+
if (one.options !== undefined && (typeof one.options !== "object" || one.options === null || Array.isArray(one.options)))
|
|
45
|
+
problems.push("a configuration's options are an object, as create() takes them");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const named = (list, what) => {
|
|
49
|
+
if (list === undefined)
|
|
50
|
+
return;
|
|
51
|
+
if (!Array.isArray(list))
|
|
52
|
+
return void problems.push(`${what} is not a list`);
|
|
53
|
+
const names = new Set();
|
|
54
|
+
const options = new Set();
|
|
55
|
+
for (const one of list) {
|
|
56
|
+
if (typeof one?.name !== "string" || one.name === "" || typeof one.option !== "string" || one.option === "")
|
|
57
|
+
problems.push(`each of ${what} has a name and the option it fills`);
|
|
58
|
+
else if (names.has(one.name) || options.has(one.option))
|
|
59
|
+
problems.push(`${what} names ${one.name} or fills ${one.option} twice`);
|
|
60
|
+
else
|
|
61
|
+
names.add(one.name), options.add(one.option);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (d.keys === undefined)
|
|
65
|
+
problems.push("keys is not a list");
|
|
66
|
+
named(d.keys, "keys");
|
|
67
|
+
named(d.settings, "settings");
|
|
68
|
+
if (Array.isArray(d.keys) && d.keys.some((key) => typeof key?.required !== "boolean"))
|
|
69
|
+
problems.push("each key says whether it is required");
|
|
70
|
+
if (d.ledger !== undefined && (typeof d.ledger?.option !== "string" || d.ledger.option === ""))
|
|
71
|
+
problems.push("ledger names the option it fills");
|
|
72
|
+
if (d.hostEnv !== undefined && (!Array.isArray(d.hostEnv) || d.hostEnv.some((name) => typeof name !== "string" || name === "")))
|
|
73
|
+
problems.push("hostEnv is a list of environment variable names");
|
|
74
|
+
if (d.parked !== undefined) {
|
|
75
|
+
if (!Array.isArray(d.parked) || d.parked.some((one) => typeof one?.image !== "string" || one.image === "" || typeof one.why !== "string" || one.why === "" || typeof one.kind !== "string" || !Array.isArray(one.groups)))
|
|
76
|
+
problems.push("parked is a list of configurations, each with its image and why it is parked");
|
|
77
|
+
else if (Array.isArray(d.capabilities) && d.parked.some((one) => d.capabilities.some((offered) => offered?.image === one.image)))
|
|
78
|
+
problems.push("a parked image is also offered");
|
|
79
|
+
}
|
|
80
|
+
return problems;
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const BROWSERBASE: {
|
|
2
|
+
readonly id: "browserbase";
|
|
3
|
+
readonly label: "Browserbase";
|
|
4
|
+
readonly keys: readonly [{
|
|
5
|
+
readonly name: "BROWSERBASE_API_KEY";
|
|
6
|
+
readonly option: "apiKey";
|
|
7
|
+
readonly required: true;
|
|
8
|
+
}, {
|
|
9
|
+
readonly name: "BROWSERBASE_PROJECT_ID";
|
|
10
|
+
readonly option: "projectId";
|
|
11
|
+
readonly required: true;
|
|
12
|
+
}];
|
|
13
|
+
readonly metered: true;
|
|
14
|
+
readonly mounts: readonly [];
|
|
15
|
+
readonly network: readonly ["open"];
|
|
16
|
+
readonly capabilities: readonly [{
|
|
17
|
+
readonly kind: "browser";
|
|
18
|
+
readonly groups: ["cdp", "stream"];
|
|
19
|
+
}];
|
|
20
|
+
readonly defaultImage: {
|
|
21
|
+
readonly browser: "chromium";
|
|
22
|
+
};
|
|
23
|
+
readonly load: () => Promise<typeof import("../browserbase.js")>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Browserbase's descriptor: a cloud Chromium over CDP, with its live view.
|
|
2
|
+
import { defineProvider } from "../descriptor.js";
|
|
3
|
+
import { BROWSER_IMAGE } from "./shared.js";
|
|
4
|
+
export const BROWSERBASE = defineProvider({
|
|
5
|
+
id: "browserbase",
|
|
6
|
+
label: "Browserbase",
|
|
7
|
+
keys: [
|
|
8
|
+
{ name: "BROWSERBASE_API_KEY", option: "apiKey", required: true },
|
|
9
|
+
{ name: "BROWSERBASE_PROJECT_ID", option: "projectId", required: true },
|
|
10
|
+
],
|
|
11
|
+
metered: true,
|
|
12
|
+
mounts: [],
|
|
13
|
+
// Browserbase's own network, open: it cannot be closed or narrowed.
|
|
14
|
+
network: ["open"],
|
|
15
|
+
capabilities: [{ kind: "browser", groups: ["cdp", "stream"] }],
|
|
16
|
+
defaultImage: { browser: BROWSER_IMAGE },
|
|
17
|
+
load: () => import("../browserbase.js"),
|
|
18
|
+
});
|