@parcha/agentrun-computer 0.1.0-beta.35 → 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.
- package/README.md +108 -21
- package/box/Dockerfile +3 -1
- package/box/agentrun-archil +59 -7
- package/box/build-daytona.py +20 -4
- package/dist/browser.d.ts +61 -10
- package/dist/browser.js +125 -3
- package/dist/browserbase.d.ts +45 -20
- package/dist/browserbase.js +161 -17
- package/dist/chrome.d.ts +3 -4
- package/dist/chrome.js +6 -11
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/daytona.d.ts +4 -0
- package/dist/conformance/daytona.js +5 -0
- package/dist/daytona.d.ts +13 -1
- package/dist/daytona.js +55 -36
- package/dist/descriptor.d.ts +24 -2
- package/dist/descriptor.js +11 -0
- package/dist/descriptors/browserbase.d.ts +1 -0
- package/dist/descriptors/browserbase.js +2 -0
- package/dist/descriptors/daytona.d.ts +23 -2
- package/dist/descriptors/daytona.js +34 -2
- package/dist/descriptors/index.d.ts +28 -1
- package/dist/descriptors/index.js +1 -1
- package/dist/descriptors/kernel.d.ts +1 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/modal.d.ts +4 -0
- package/dist/descriptors/modal.js +11 -1
- package/dist/descriptors/orgo.d.ts +11 -0
- package/dist/descriptors/orgo.js +6 -1
- package/dist/descriptors/phone-harness.d.ts +5 -0
- package/dist/descriptors/phone-harness.js +3 -0
- package/dist/docker/egress.d.ts +4 -3
- package/dist/docker/egress.js +7 -6
- package/dist/docker.js +7 -5
- package/dist/e2b.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/janitor.d.ts +5 -4
- package/dist/janitor.js +1 -1
- package/dist/kernel.d.ts +16 -24
- package/dist/kernel.js +93 -18
- package/dist/kinds.d.ts +9 -4
- package/dist/labels.d.ts +10 -2
- package/dist/labels.js +30 -7
- package/dist/local-chrome.d.ts +3 -1
- package/dist/local-chrome.js +8 -4
- package/dist/modal.d.ts +3 -3
- package/dist/modal.js +71 -57
- package/dist/mount-archil.d.ts +25 -3
- package/dist/mount-archil.js +39 -8
- package/dist/orgo-desktop.d.ts +15 -6
- package/dist/orgo-desktop.js +295 -53
- package/dist/orgo-names.d.ts +129 -3
- package/dist/orgo-names.js +211 -8
- package/dist/orgo.d.ts +18 -7
- package/dist/orgo.js +381 -69
- package/dist/phone-harness.d.ts +3 -2
- package/dist/phone-harness.js +25 -8
- package/dist/protocol.d.ts +5 -0
- package/dist/provider.d.ts +63 -1
- package/dist/provider.js +8 -3
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -109,16 +109,18 @@ export async function recoverCreate(what, find, release, sleep) {
|
|
|
109
109
|
}
|
|
110
110
|
return words.join("; ");
|
|
111
111
|
}
|
|
112
|
-
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "gpu"]);
|
|
112
|
+
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "gpu", "browser"]);
|
|
113
113
|
/**
|
|
114
114
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
|
115
|
-
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds,
|
|
116
|
-
*
|
|
115
|
+
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds, the session's
|
|
116
|
+
* options are ones capabilities().browser declares (browserSpecRefusals), and no field a browser does not take (a size,
|
|
117
|
+
* a user, a workdir, a mount).
|
|
117
118
|
*/
|
|
118
119
|
export function checkBrowser(spec, capabilities, vendor, minLifetimeMs = 1) {
|
|
119
120
|
const refusals = [];
|
|
120
121
|
const given = (typeof spec === "object" && spec !== null ? spec : {});
|
|
121
122
|
const { image, lifetimeMs, network, labels } = given;
|
|
123
|
+
refusals.push(...browserSpecRefusals(given.browser, capabilities.browser ?? { timeout: "wall-clock" }, vendor));
|
|
122
124
|
if (image !== BROWSER_IMAGE)
|
|
123
125
|
refusals.push({ field: "image", message: `a ${vendor} computer runs ${vendor}'s own Chromium: image is "${BROWSER_IMAGE}", not ${JSON.stringify(image)}` });
|
|
124
126
|
const lifetime = checkLifetime(lifetimeMs, capabilities);
|
|
@@ -308,3 +310,123 @@ export function httpsBase(url, what) {
|
|
|
308
310
|
}
|
|
309
311
|
/** A vendor's session id as a ref or attach gives it: a plain token, never a path. */
|
|
310
312
|
export const idProblem = (id, vendor) => typeof id === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(id) ? undefined : `${typeof id === "string" ? JSON.stringify(id) : String(id)} is not a ${vendor} session's id`;
|
|
313
|
+
/**
|
|
314
|
+
* A GET whose success is bytes, streamed (Accept application/octet-stream); undefined when the vendor answers 404. A
|
|
315
|
+
* redirect is followed once, to https only, and without the key's headers, so a storage host is never handed the key.
|
|
316
|
+
* A failure throws a BrowserVendorError that names the call and the status alone.
|
|
317
|
+
*/
|
|
318
|
+
export async function restBytes(o, route, call, signal) {
|
|
319
|
+
const get = (url, headers) => o.fetch(url, { method: "GET", headers: { ...headers, Accept: "application/octet-stream" }, redirect: "manual", ...(signal ? { signal } : {}) });
|
|
320
|
+
const drop = (response) => response.body?.cancel().catch(() => undefined);
|
|
321
|
+
let response;
|
|
322
|
+
try {
|
|
323
|
+
response = await get(`${o.base}${route}`, o.headers);
|
|
324
|
+
if (response.status >= 300 && response.status < 400) {
|
|
325
|
+
const location = response.headers.get("location");
|
|
326
|
+
await drop(response);
|
|
327
|
+
let next;
|
|
328
|
+
try {
|
|
329
|
+
next = location ? new URL(location, `${o.base}${route}`) : undefined;
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
next = undefined;
|
|
333
|
+
}
|
|
334
|
+
if (next === undefined)
|
|
335
|
+
throw new BrowserVendorError(o.vendor, call, response.status, "no_location");
|
|
336
|
+
if (next.protocol !== "https:")
|
|
337
|
+
throw new BrowserVendorError(o.vendor, call, response.status, "redirect_not_https");
|
|
338
|
+
response = await get(next.href, {});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
if (isAbort(error) || error instanceof BrowserVendorError)
|
|
343
|
+
throw error;
|
|
344
|
+
throw new BrowserVendorError(o.vendor, call, undefined, undefined, { cause: error });
|
|
345
|
+
}
|
|
346
|
+
if (response.status === 404) {
|
|
347
|
+
await drop(response);
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
if (!response.ok) {
|
|
351
|
+
await drop(response);
|
|
352
|
+
throw new BrowserVendorError(o.vendor, call, response.status);
|
|
353
|
+
}
|
|
354
|
+
if (response.body === null)
|
|
355
|
+
throw new BrowserVendorError(o.vendor, call, response.status, "no_body");
|
|
356
|
+
return response.body;
|
|
357
|
+
}
|
|
358
|
+
/** The bytes as they come, failing in words once they pass maxBytes: what reached the reader before then is all it gets. */
|
|
359
|
+
export async function* limitedBytes(body, maxBytes, what) {
|
|
360
|
+
let total = 0;
|
|
361
|
+
for await (const chunk of body) {
|
|
362
|
+
total += chunk.byteLength;
|
|
363
|
+
if (total > maxBytes)
|
|
364
|
+
throw new Error(`${what} is larger than the ${maxBytes}-byte limit`);
|
|
365
|
+
yield chunk;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/** Whether a provider is a browser provider: its capabilities are of kind browser and declare its sessions' features. */
|
|
369
|
+
export function isBrowserProvider(provider) {
|
|
370
|
+
let capabilities;
|
|
371
|
+
try {
|
|
372
|
+
capabilities = typeof provider?.capabilities === "function" ? provider.capabilities() : undefined;
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
const browser = capabilities?.browser;
|
|
378
|
+
return capabilities?.kind === "browser" && typeof browser === "object" && browser !== null;
|
|
379
|
+
}
|
|
380
|
+
/** A viewport's longest side, in pixels. */
|
|
381
|
+
const MAX_VIEWPORT = 10_000;
|
|
382
|
+
const SESSION_FIELDS = new Set(["viewport", "profile", "stealth", "headless"]);
|
|
383
|
+
/** A profile's pointer as a provider takes it: a plain token, so it is a path segment and never a path. */
|
|
384
|
+
export const pointerOk = (pointer) => typeof pointer === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(pointer);
|
|
385
|
+
const only = (value, fields) => Object.keys(value).every((key) => fields.includes(key));
|
|
386
|
+
/**
|
|
387
|
+
* Why spec.browser is not one this provider takes, field by field: a malformed option, or one its features
|
|
388
|
+
* (capabilities().browser) do not declare (a flag set false asks for nothing, so it is never refused). The words never
|
|
389
|
+
* carry a pointer.
|
|
390
|
+
*/
|
|
391
|
+
export function browserSpecRefusals(session, features, vendor) {
|
|
392
|
+
if (session === undefined)
|
|
393
|
+
return [];
|
|
394
|
+
if (typeof session !== "object" || session === null || Array.isArray(session))
|
|
395
|
+
return [{ field: "browser", message: "a browser's options are an object" }];
|
|
396
|
+
const refusals = [];
|
|
397
|
+
const given = session;
|
|
398
|
+
for (const [field, value] of Object.entries(given)) {
|
|
399
|
+
if (!SESSION_FIELDS.has(field) && value !== undefined)
|
|
400
|
+
refusals.push({ field: `browser.${field}`, message: `a browser takes no ${field}` });
|
|
401
|
+
}
|
|
402
|
+
const { viewport, profile } = given;
|
|
403
|
+
if (viewport !== undefined) {
|
|
404
|
+
const side = (n) => Number.isInteger(n) && n >= 1 && n <= MAX_VIEWPORT;
|
|
405
|
+
const v = viewport;
|
|
406
|
+
if (typeof v !== "object" || v === null || !only(v, ["width", "height"]) || !side(v.width) || !side(v.height)) {
|
|
407
|
+
refusals.push({ field: "browser.viewport", message: `a viewport is { width, height }, each a whole number of pixels from 1 to ${MAX_VIEWPORT}` });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const flags = [
|
|
411
|
+
["stealth", "stealth mode"],
|
|
412
|
+
["headless", "headless mode"],
|
|
413
|
+
];
|
|
414
|
+
for (const [field, what] of flags) {
|
|
415
|
+
const value = given[field];
|
|
416
|
+
if (value === undefined)
|
|
417
|
+
continue;
|
|
418
|
+
if (typeof value !== "boolean")
|
|
419
|
+
refusals.push({ field: `browser.${field}`, message: `${field} is true or false` });
|
|
420
|
+
else if (value && features[field] !== true)
|
|
421
|
+
refusals.push({ field: `browser.${field}`, message: `a ${vendor} browser has no ${what}, so ${field} is refused` });
|
|
422
|
+
}
|
|
423
|
+
if (profile !== undefined) {
|
|
424
|
+
const p = profile;
|
|
425
|
+
if (features.profiles === undefined)
|
|
426
|
+
refusals.push({ field: "browser.profile", message: `a ${vendor} browser keeps no profile` });
|
|
427
|
+
else if (typeof p !== "object" || p === null || !only(p, ["pointer", "save"]) || !pointerOk(p.pointer) || typeof p.save !== "boolean") {
|
|
428
|
+
refusals.push({ field: "browser.profile", message: "a profile is { pointer, save }: a plain token profiles.create gave, and true or false" });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return refusals;
|
|
432
|
+
}
|
package/dist/browserbase.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BrowserComputerProvider, type BrowserDownloads, type BrowserProfiles, type BrowserStream, type ReleaseConfirm } from "./browser.js";
|
|
2
2
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
3
|
import type { MountKind } from "./mount.js";
|
|
4
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";
|
|
@@ -40,10 +40,18 @@ export interface BrowserbaseDebug {
|
|
|
40
40
|
debuggerFullscreenUrl?: string;
|
|
41
41
|
}>;
|
|
42
42
|
}
|
|
43
|
+
/** One row of a session's downloads, as GET /v1/downloads answers it; only what the provider reads. */
|
|
44
|
+
export interface BrowserbaseDownload {
|
|
45
|
+
id: string;
|
|
46
|
+
filename: string;
|
|
47
|
+
size: number;
|
|
48
|
+
createdAt?: string;
|
|
49
|
+
}
|
|
43
50
|
/**
|
|
44
51
|
* The calls the provider makes, one Browserbase request each, never retried where a retry could open a second paid
|
|
45
52
|
* browser. A failure throws, with the HTTP status as `status` when one came back; the provider returns it as a result
|
|
46
|
-
* whose hidden cause is the thrown error
|
|
53
|
+
* whose hidden cause is the thrown error. The context calls back the profiles member, the download calls the downloads
|
|
54
|
+
* member.
|
|
47
55
|
*/
|
|
48
56
|
export interface BrowserbaseApi {
|
|
49
57
|
create(body: Record<string, unknown>, signal?: AbortSignal): Promise<BrowserbaseSession>;
|
|
@@ -56,6 +64,17 @@ export interface BrowserbaseApi {
|
|
|
56
64
|
/** "gone" when Browserbase does not know the session (404). */
|
|
57
65
|
release(id: string, signal?: AbortSignal): Promise<"gone" | "asked">;
|
|
58
66
|
debug(id: string, signal?: AbortSignal): Promise<BrowserbaseDebug>;
|
|
67
|
+
/** Makes a context (POST /v1/contexts): its id. */
|
|
68
|
+
createContext(signal?: AbortSignal): Promise<string>;
|
|
69
|
+
/** "gone" when Browserbase does not know the context (404). */
|
|
70
|
+
deleteContext(id: string, signal?: AbortSignal): Promise<"gone" | "deleted">;
|
|
71
|
+
/** One page of a session's downloads, from offset, and how many there are in all. */
|
|
72
|
+
listDownloads(sessionId: string, offset: number, signal?: AbortSignal): Promise<{
|
|
73
|
+
downloads: BrowserbaseDownload[];
|
|
74
|
+
total: number;
|
|
75
|
+
}>;
|
|
76
|
+
/** A download's bytes, streamed; undefined when Browserbase does not know it (404). */
|
|
77
|
+
readDownload(id: string, signal?: AbortSignal): Promise<AsyncIterable<Uint8Array> | undefined>;
|
|
59
78
|
}
|
|
60
79
|
/** Browserbase's v1 REST API over fetch: the default api. */
|
|
61
80
|
export declare function browserbaseRest({ apiKey, apiUrl, projectId, fetch: fetcher }: {
|
|
@@ -64,43 +83,50 @@ export declare function browserbaseRest({ apiKey, apiUrl, projectId, fetch: fetc
|
|
|
64
83
|
projectId?: string;
|
|
65
84
|
fetch?: typeof fetch;
|
|
66
85
|
}): BrowserbaseApi;
|
|
86
|
+
/** How long after a saving session ends Browserbase may still be writing its context back. */
|
|
87
|
+
export declare const BROWSERBASE_PROFILE_SETTLE_MS = 5000;
|
|
88
|
+
/** The directory Browserbase syncs a session's downloads from: a driver sets the download behaviour into it. */
|
|
89
|
+
export declare const BROWSERBASE_DOWNLOADS_PATH = "downloads";
|
|
67
90
|
export interface BrowserbaseProviderOptions {
|
|
68
|
-
/** With apiUrl and fetch, the REST api is built from it
|
|
91
|
+
/** With apiUrl and fetch, the REST api is built from it. */
|
|
69
92
|
apiKey?: string;
|
|
70
|
-
/** Named in every create and release;
|
|
93
|
+
/** Named in every create and release; none behind a gateway (env), whose key names the project. */
|
|
71
94
|
projectId?: string;
|
|
95
|
+
/** Browserbase's API; default BROWSERBASE_BASE_URL in env (a gateway that fronts it), else Browserbase's own. */
|
|
72
96
|
apiUrl?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The host's own variables its descriptor declares (hostEnv): BROWSERBASE_BASE_URL, a gateway that fronts the API, and
|
|
99
|
+
* BROWSERBASE_CONNECT_BASE_URL, one that fronts the sessions' sockets. Behind either, the gateway's key names the
|
|
100
|
+
* project, so no projectId is sent.
|
|
101
|
+
*/
|
|
102
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
73
103
|
fetch?: typeof fetch;
|
|
74
|
-
/** The calls, a host's own (pi-browser's SDK client); default the REST api. */
|
|
75
|
-
api?: BrowserbaseApi;
|
|
76
|
-
/** Where the signed connect URLs are held; default a Map of this provider's own. */
|
|
77
|
-
urls?: UrlStore;
|
|
78
104
|
confirm?: ReleaseConfirm;
|
|
79
105
|
sleep?: (ms: number) => Promise<void>;
|
|
80
106
|
}
|
|
81
|
-
/** What a host may add to a session's create body: Browserbase's own settings (proxies, browserSettings, region, extensionId, a context). */
|
|
82
|
-
export type BrowserbaseSessionSettings = Record<string, unknown>;
|
|
83
107
|
/** Computers that are Browserbase sessions. */
|
|
84
|
-
export declare class BrowserbaseProvider implements ComputerProvider {
|
|
108
|
+
export declare class BrowserbaseProvider implements ComputerProvider, BrowserComputerProvider {
|
|
85
109
|
#private;
|
|
86
110
|
readonly id = "browserbase";
|
|
87
111
|
readonly version: string;
|
|
88
|
-
|
|
112
|
+
readonly profiles: BrowserProfiles;
|
|
113
|
+
readonly downloads: BrowserDownloads;
|
|
114
|
+
constructor({ apiKey, projectId, apiUrl, env, fetch: fetcher, confirm, sleep }: BrowserbaseProviderOptions);
|
|
89
115
|
/**
|
|
90
116
|
* A browser: Browserbase ends a session at its timeout (lifetime vendor), at most 6 h; it reaches the open web; each
|
|
91
|
-
* session is its own VM.
|
|
92
|
-
*
|
|
117
|
+
* session is its own VM. browser is what its sessions offer beyond the protocol. Its downloads are read through the
|
|
118
|
+
* downloads member (browser.downloads); the group stays undeclared until the kind registry's entry (kinds.ts)
|
|
119
|
+
* declares it too.
|
|
93
120
|
*/
|
|
94
121
|
capabilities(): ComputerCapabilities;
|
|
95
122
|
check(spec: ComputerSpec): Refusal[];
|
|
96
123
|
/**
|
|
97
124
|
* Makes a session at most once: with keepAlive, so a dropped CDP client never ends it, the lifetime as its timeout in
|
|
98
|
-
* whole seconds, and the labels as its userMetadata.
|
|
99
|
-
*
|
|
125
|
+
* whole seconds, and the labels as its userMetadata. spec.browser is the session's own options, each refused by check()
|
|
126
|
+
* unless declared.
|
|
100
127
|
*/
|
|
101
|
-
create(spec: ComputerSpec, { signal
|
|
128
|
+
create(spec: ComputerSpec, { signal }?: {
|
|
102
129
|
signal?: AbortSignal;
|
|
103
|
-
settings?: BrowserbaseSessionSettings;
|
|
104
130
|
}): Promise<Result<CreatedComputer>>;
|
|
105
131
|
/**
|
|
106
132
|
* Settings' test: one read of the project's running sessions (GET /v1/sessions?status=RUNNING), which makes nothing.
|
|
@@ -131,8 +157,7 @@ export declare class BrowserbaseProvider implements ComputerProvider {
|
|
|
131
157
|
}, { signal }?: CallContext): Promise<Result<BrowserStream>>;
|
|
132
158
|
}
|
|
133
159
|
/**
|
|
134
|
-
* The provider, built from its options alone, the key included (options.apiKey,
|
|
135
|
-
* host's own transport); it reads no environment, and throws in words when the key is missing, never echoing one.
|
|
160
|
+
* The provider, built from its options alone, the key included (options.apiKey); it reads no environment, and throws in words when the key is missing, never echoing one.
|
|
136
161
|
*/
|
|
137
162
|
export declare function create(options: BrowserbaseProviderOptions): BrowserbaseProvider;
|
|
138
163
|
/** The conformance CLI's module for Browserbase: its live switch, its image and its notes. */
|
package/dist/browserbase.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Browserbase as a computer of kind browser: each computer is a Browserbase session, over Browserbase's v1 REST API with
|
|
2
|
-
// fetch (no SDK)
|
|
3
|
-
// userMetadata; attach and list find a session by them; connect hands over the session's signed connectUrl, which a
|
|
2
|
+
// fetch (no SDK). Labels ride the session's own userMetadata; attach and list find a session by them; connect hands over the session's signed connectUrl, which a
|
|
4
3
|
// driver dials; stream is its live view (the debugger's fullscreen URL). Both URLs are secrets: they stay in memory and
|
|
5
4
|
// never reach a ref, a list, an error's words or a report.
|
|
6
5
|
//
|
|
@@ -9,6 +8,11 @@
|
|
|
9
8
|
// Browserbase answer 504 after 75 s), POST /v1/sessions/{id} with status REQUEST_RELEASE (release), and
|
|
10
9
|
// GET /v1/sessions/{id}/debug (the live view). The key is the X-BB-API-Key header.
|
|
11
10
|
//
|
|
11
|
+
// A session's own options (spec.browser): viewport and a profile ride browserSettings (a profile is a context,
|
|
12
|
+
// { id: pointer, persist: save }); stealth is Browserbase's Verified browser with its CAPTCHA solver (verified and
|
|
13
|
+
// solveCaptchas; the solver is off otherwise, as Browserbase's default is on). Profiles are contexts: POST /v1/contexts ({ projectId } when the provider has one) and DELETE /v1/contexts/{id}. Downloads are the session's
|
|
14
|
+
// synced files: GET /v1/downloads?sessionId=&limit=&offset= (paged by total) and GET /v1/downloads/{id}, the bytes.
|
|
15
|
+
//
|
|
12
16
|
// A label's key is not its metadata key: Browserbase refuses a dot in a userMetadata key (POST /v1/sessions answered 400
|
|
13
17
|
// "Key is not a valid metadata key: agentrun.conformance", found live on 11-08), and the protocol's labels are dotted
|
|
14
18
|
// (agentrun.run, agentrun.epoch). metadataKey() writes each "." as "_", and labelKey() reads it back. check() takes a
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
import { readFileSync } from "node:fs";
|
|
18
22
|
import { BROWSERBASE } from "./descriptors/browserbase.js";
|
|
19
23
|
import { BROWSER_IMAGE } from "./descriptors/shared.js";
|
|
20
|
-
import { cdpUrlProblem, browserClient, browserHello, BrowserVendorError, CREATE_LABEL, carries, causeOf, checkBrowser, createLabelValue, createUncertain, DEFAULT_CONFIRM, defaultSleep, httpsBase, idProblem, labelsOf, labelsProblem, memoryUrls, queryable, recoverCreate, releaseConfirmed, restCall, causedFail, vendorFailure, withoutCreateLabel, } from "./browser.js";
|
|
24
|
+
import { cdpUrlProblem, browserClient, browserHello, BrowserVendorError, CREATE_LABEL, carries, causeOf, checkBrowser, createLabelValue, createUncertain, DEFAULT_CONFIRM, defaultSleep, httpsBase, idProblem, labelsOf, labelsProblem, limitedBytes, memoryUrls, pointerOk, queryable, recoverCreate, releaseConfirmed, restBytes, restCall, causedFail, vendorFailure, withoutCreateLabel, } from "./browser.js";
|
|
21
25
|
import { runLifetimeMs, } from "./provider.js";
|
|
22
26
|
import { failFor, ok, vendorFail } from "./result.js";
|
|
23
27
|
import { connectionError } from "./test-connection.js";
|
|
@@ -64,6 +68,8 @@ export function browserbaseLabelsProblem(labels) {
|
|
|
64
68
|
export const MOUNT = BROWSERBASE.mounts;
|
|
65
69
|
/** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
|
|
66
70
|
export const CAPABILITIES = BROWSERBASE.capabilities;
|
|
71
|
+
/** A plain id as Browserbase answers one (a context's, a download's): a token, never a path. */
|
|
72
|
+
const plainId = (id) => typeof id === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(id);
|
|
67
73
|
/** Browserbase's v1 REST API over fetch: the default api. */
|
|
68
74
|
export function browserbaseRest({ apiKey, apiUrl = BROWSERBASE_API_URL, projectId, fetch: fetcher = fetch }) {
|
|
69
75
|
const o = { vendor: NAME, fetch: fetcher, base: httpsBase(apiUrl, "the Browserbase API URL"), headers: { "X-BB-API-Key": apiKey } };
|
|
@@ -109,8 +115,42 @@ export function browserbaseRest({ apiKey, apiUrl = BROWSERBASE_API_URL, projectI
|
|
|
109
115
|
throw new BrowserVendorError(NAME, call, 404);
|
|
110
116
|
return (answer.json ?? {});
|
|
111
117
|
},
|
|
118
|
+
async createContext(signal) {
|
|
119
|
+
const call = "POST /v1/contexts";
|
|
120
|
+
const answer = await restCall(o, "POST", "/v1/contexts", call, { body: projectId ? { projectId } : {}, ...(signal ? { signal } : {}) });
|
|
121
|
+
const id = answer.json?.id;
|
|
122
|
+
if (answer.status === 404 || !plainId(id))
|
|
123
|
+
throw new BrowserVendorError(NAME, call, answer.status, "no_context_id");
|
|
124
|
+
return id;
|
|
125
|
+
},
|
|
126
|
+
async deleteContext(id, signal) {
|
|
127
|
+
const answer = await restCall(o, "DELETE", `/v1/contexts/${encodeURIComponent(id)}`, "DELETE /v1/contexts/{id}", signal ? { signal } : {});
|
|
128
|
+
return answer.status === 404 ? "gone" : "deleted";
|
|
129
|
+
},
|
|
130
|
+
async listDownloads(sessionId, offset, signal) {
|
|
131
|
+
const call = "GET /v1/downloads";
|
|
132
|
+
const query = new URLSearchParams({ sessionId, limit: String(DOWNLOADS_PAGE), offset: String(offset) });
|
|
133
|
+
const answer = await restCall(o, "GET", "/v1/downloads", call, { query, ...(signal ? { signal } : {}) });
|
|
134
|
+
// A list is never "not found": a 404 is a wrong base URL, and an empty answer would hide every file.
|
|
135
|
+
if (answer.status === 404)
|
|
136
|
+
throw new BrowserVendorError(NAME, call, 404);
|
|
137
|
+
const page = answer.json;
|
|
138
|
+
if (!Array.isArray(page?.downloads) || !Number.isInteger(page.total))
|
|
139
|
+
throw new BrowserVendorError(NAME, call, answer.status, "not_a_list");
|
|
140
|
+
return { downloads: page.downloads, total: page.total };
|
|
141
|
+
},
|
|
142
|
+
async readDownload(id, signal) {
|
|
143
|
+
return restBytes(o, `/v1/downloads/${encodeURIComponent(id)}`, "GET /v1/downloads/{id}", signal);
|
|
144
|
+
},
|
|
112
145
|
};
|
|
113
146
|
}
|
|
147
|
+
/** Rows per downloads page, and the most pages a list reads before it fails rather than run on. */
|
|
148
|
+
const DOWNLOADS_PAGE = 100;
|
|
149
|
+
const MAX_PAGES = 100;
|
|
150
|
+
/** How long after a saving session ends Browserbase may still be writing its context back. */
|
|
151
|
+
export const BROWSERBASE_PROFILE_SETTLE_MS = 5_000;
|
|
152
|
+
/** The directory Browserbase syncs a session's downloads from: a driver sets the download behaviour into it. */
|
|
153
|
+
export const BROWSERBASE_DOWNLOADS_PATH = "downloads";
|
|
114
154
|
const refOf = (s) => ({ id: s.id, name: s.id });
|
|
115
155
|
const deadlineOf = (s) => {
|
|
116
156
|
const at = typeof s.expiresAt === "string" ? new Date(s.expiresAt) : undefined;
|
|
@@ -120,24 +160,44 @@ const deadlineOf = (s) => {
|
|
|
120
160
|
export class BrowserbaseProvider {
|
|
121
161
|
id = "browserbase";
|
|
122
162
|
version = VERSION;
|
|
163
|
+
/**
|
|
164
|
+
* A session ends at its timeout, a wall clock; it may be stealth (Verified, with the CAPTCHA solver); it opens a
|
|
165
|
+
* context as a profile (written back about 5 s after a saving session ends) and keeps what is saved into downloads/.
|
|
166
|
+
* capabilities().browser gives it.
|
|
167
|
+
*/
|
|
168
|
+
#browser;
|
|
169
|
+
profiles;
|
|
170
|
+
downloads;
|
|
123
171
|
#api;
|
|
124
172
|
#projectId;
|
|
125
173
|
#urls;
|
|
126
174
|
#confirm;
|
|
127
175
|
#sleep;
|
|
128
|
-
constructor({ apiKey, projectId, apiUrl, fetch: fetcher,
|
|
129
|
-
if (
|
|
130
|
-
throw new Error("set options.apiKey to a Browserbase API key
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.#
|
|
176
|
+
constructor({ apiKey, projectId, apiUrl, env = {}, fetch: fetcher, confirm = DEFAULT_CONFIRM, sleep = defaultSleep }) {
|
|
177
|
+
if (typeof apiKey !== "string" || apiKey === "")
|
|
178
|
+
throw new Error("set options.apiKey to a Browserbase API key: the provider reads no environment");
|
|
179
|
+
const gateway = env.BROWSERBASE_BASE_URL?.trim() || undefined;
|
|
180
|
+
const behindGateway = Boolean(gateway || env.BROWSERBASE_CONNECT_BASE_URL?.trim());
|
|
181
|
+
this.#projectId = behindGateway ? undefined : projectId || undefined;
|
|
182
|
+
const base = apiUrl || gateway;
|
|
183
|
+
this.#api = browserbaseRest({ apiKey, ...(base ? { apiUrl: base } : {}), ...(this.#projectId ? { projectId: this.#projectId } : {}), ...(fetcher ? { fetch: fetcher } : {}) });
|
|
184
|
+
this.#urls = memoryUrls();
|
|
134
185
|
this.#confirm = confirm;
|
|
135
186
|
this.#sleep = sleep;
|
|
187
|
+
this.#browser = {
|
|
188
|
+
timeout: "wall-clock",
|
|
189
|
+
stealth: true,
|
|
190
|
+
profiles: { settleMs: BROWSERBASE_PROFILE_SETTLE_MS },
|
|
191
|
+
downloads: { path: BROWSERBASE_DOWNLOADS_PATH },
|
|
192
|
+
};
|
|
193
|
+
this.profiles = { create: (context) => this.#createProfile(context), remove: (pointer, context) => this.#removeProfile(pointer, context) };
|
|
194
|
+
this.downloads = { list: (ref, context) => this.#listDownloads(ref, context), read: (ref, name, maxBytes, context) => this.#readDownload(ref, name, maxBytes, context) };
|
|
136
195
|
}
|
|
137
196
|
/**
|
|
138
197
|
* A browser: Browserbase ends a session at its timeout (lifetime vendor), at most 6 h; it reaches the open web; each
|
|
139
|
-
* session is its own VM.
|
|
140
|
-
*
|
|
198
|
+
* session is its own VM. browser is what its sessions offer beyond the protocol. Its downloads are read through the
|
|
199
|
+
* downloads member (browser.downloads); the group stays undeclared until the kind registry's entry (kinds.ts)
|
|
200
|
+
* declares it too.
|
|
141
201
|
*/
|
|
142
202
|
capabilities() {
|
|
143
203
|
return {
|
|
@@ -150,6 +210,7 @@ export class BrowserbaseProvider {
|
|
|
150
210
|
groups: [...CAPABILITIES[0].groups],
|
|
151
211
|
maxLifetimeMs: BROWSERBASE_MAX_LIFETIME_MS,
|
|
152
212
|
release: ["delete"],
|
|
213
|
+
browser: structuredClone(this.#browser),
|
|
153
214
|
};
|
|
154
215
|
}
|
|
155
216
|
check(spec) {
|
|
@@ -164,18 +225,26 @@ export class BrowserbaseProvider {
|
|
|
164
225
|
}
|
|
165
226
|
/**
|
|
166
227
|
* Makes a session at most once: with keepAlive, so a dropped CDP client never ends it, the lifetime as its timeout in
|
|
167
|
-
* whole seconds, and the labels as its userMetadata.
|
|
168
|
-
*
|
|
228
|
+
* whole seconds, and the labels as its userMetadata. spec.browser is the session's own options, each refused by check()
|
|
229
|
+
* unless declared.
|
|
169
230
|
*/
|
|
170
|
-
async create(spec, { signal
|
|
231
|
+
async create(spec, { signal } = {}) {
|
|
171
232
|
const refusals = this.check(spec);
|
|
172
233
|
if (refusals.length > 0)
|
|
173
234
|
return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
|
|
174
235
|
if (signal?.aborted)
|
|
175
236
|
return fail("aborted", "create was aborted before Browserbase was called");
|
|
237
|
+
const browser = spec.browser;
|
|
176
238
|
const written = { [CREATE_LABEL]: createLabelValue(), ...spec.labels };
|
|
239
|
+
// Browserbase solves CAPTCHAs unless told not to: a browser's options say so either way, the solver only with stealth.
|
|
240
|
+
const browserSettings = {
|
|
241
|
+
...(browser?.viewport ? { viewport: { width: browser.viewport.width, height: browser.viewport.height } } : {}),
|
|
242
|
+
...(browser !== undefined ? { solveCaptchas: browser.stealth === true } : {}),
|
|
243
|
+
...(browser?.stealth ? { verified: true } : {}),
|
|
244
|
+
...(browser?.profile ? { context: { id: browser.profile.pointer, persist: browser.profile.save } } : {}),
|
|
245
|
+
};
|
|
177
246
|
const body = {
|
|
178
|
-
...
|
|
247
|
+
...(Object.keys(browserSettings).length > 0 ? { browserSettings } : {}),
|
|
179
248
|
timeout: Math.ceil(runLifetimeMs(spec) / 1000),
|
|
180
249
|
keepAlive: true,
|
|
181
250
|
userMetadata: toMetadata(written),
|
|
@@ -204,6 +273,82 @@ export class BrowserbaseProvider {
|
|
|
204
273
|
this.#urls.set(made.id, made.connectUrl);
|
|
205
274
|
return ok(refOf(made));
|
|
206
275
|
}
|
|
276
|
+
/** A new context, a profile's pointer: one POST /v1/contexts, never retried. */
|
|
277
|
+
async #createProfile({ signal } = {}) {
|
|
278
|
+
try {
|
|
279
|
+
return ok(await this.#api.createContext(signal));
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
return vendorFailure("browserbase", NAME, "POST /v1/contexts", error);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** Deletes the context; one Browserbase no longer knows is removed. The words never carry the pointer. */
|
|
286
|
+
async #removeProfile(pointer, { signal } = {}) {
|
|
287
|
+
if (!pointerOk(pointer))
|
|
288
|
+
return fail("invalid", "a profile's pointer is a plain token, as profiles.create gave it");
|
|
289
|
+
try {
|
|
290
|
+
await this.#api.deleteContext(pointer, signal);
|
|
291
|
+
return ok(undefined);
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
return vendorFailure("browserbase", NAME, "DELETE /v1/contexts/{id}", error);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** Every row of a session's downloads, page by page until total; a page that cannot be read fails the whole list. */
|
|
298
|
+
async #downloadRows(id, signal) {
|
|
299
|
+
const problem = idProblem(id, NAME);
|
|
300
|
+
if (problem)
|
|
301
|
+
return fail("invalid", problem);
|
|
302
|
+
const rows = [];
|
|
303
|
+
for (let pages = 0; pages < MAX_PAGES; pages++) {
|
|
304
|
+
let got;
|
|
305
|
+
try {
|
|
306
|
+
got = await this.#api.listDownloads(id, rows.length, signal);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
return vendorFailure("browserbase", NAME, "GET /v1/downloads", error);
|
|
310
|
+
}
|
|
311
|
+
for (const row of got.downloads) {
|
|
312
|
+
if (!plainId(row?.id) || typeof row.filename !== "string" || row.filename === "" || !Number.isFinite(row.size) || row.size < 0) {
|
|
313
|
+
return vendorFail("browserbase", "Browserbase GET /v1/downloads answered a row that is not a download");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
rows.push(...got.downloads);
|
|
317
|
+
if (got.downloads.length === 0 || rows.length >= got.total)
|
|
318
|
+
return ok(rows);
|
|
319
|
+
}
|
|
320
|
+
return vendorFail("browserbase", `Browserbase kept answering more pages of downloads past ${MAX_PAGES}`);
|
|
321
|
+
}
|
|
322
|
+
async #listDownloads(ref, { signal } = {}) {
|
|
323
|
+
const rows = await this.#downloadRows(ref?.id, signal);
|
|
324
|
+
if (!rows.ok)
|
|
325
|
+
return rows;
|
|
326
|
+
// Browserbase suffixes each name with a timestamp, so a name is one file in a session.
|
|
327
|
+
return ok(rows.value.map((d) => ({ name: d.filename, sizeBytes: d.size, modifiedAt: typeof d.createdAt === "string" ? d.createdAt : null })));
|
|
328
|
+
}
|
|
329
|
+
/** A download's bytes by its name: refused past maxBytes before it is fetched when its size says so, and cut once the stream passes it. */
|
|
330
|
+
async #readDownload(ref, name, maxBytes, { signal } = {}) {
|
|
331
|
+
if (!Number.isInteger(maxBytes) || maxBytes < 0)
|
|
332
|
+
return fail("invalid", "maxBytes is a whole number of bytes");
|
|
333
|
+
const rows = await this.#downloadRows(ref?.id, signal);
|
|
334
|
+
if (!rows.ok)
|
|
335
|
+
return rows;
|
|
336
|
+
const row = rows.value.find((d) => d.filename === name);
|
|
337
|
+
if (row === undefined)
|
|
338
|
+
return fail("not_found", `the Browserbase session ${ref.id} downloaded no file named ${JSON.stringify(name)}`);
|
|
339
|
+
if (row.size > maxBytes)
|
|
340
|
+
return fail("limit", `the download ${JSON.stringify(name)} is ${row.size} bytes, larger than the ${maxBytes}-byte limit`);
|
|
341
|
+
let body;
|
|
342
|
+
try {
|
|
343
|
+
body = await this.#api.readDownload(row.id, signal);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
return vendorFailure("browserbase", NAME, "GET /v1/downloads/{id}", error);
|
|
347
|
+
}
|
|
348
|
+
if (body === undefined)
|
|
349
|
+
return fail("not_found", `Browserbase no longer holds the download ${JSON.stringify(name)}`);
|
|
350
|
+
return ok(limitedBytes(body, maxBytes, `the download ${JSON.stringify(name)}`));
|
|
351
|
+
}
|
|
207
352
|
/**
|
|
208
353
|
* The sessions a lost create made, released: what recoverCreate says of them. They are found as list finds any, by
|
|
209
354
|
* the labels the create wrote (its create label first, so the query names it, then the run's), through #sessions and
|
|
@@ -403,8 +548,7 @@ export class BrowserbaseProvider {
|
|
|
403
548
|
}
|
|
404
549
|
}
|
|
405
550
|
/**
|
|
406
|
-
* The provider, built from its options alone, the key included (options.apiKey,
|
|
407
|
-
* host's own transport); it reads no environment, and throws in words when the key is missing, never echoing one.
|
|
551
|
+
* The provider, built from its options alone, the key included (options.apiKey); it reads no environment, and throws in words when the key is missing, never echoing one.
|
|
408
552
|
*/
|
|
409
553
|
export function create(options) {
|
|
410
554
|
return new BrowserbaseProvider(options ?? {});
|
package/dist/chrome.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Result } from "./result.js";
|
|
2
|
-
/** The environment names a Chrome is found by:
|
|
2
|
+
/** The environment names a Chrome is found by: PI_BROWSER_CHROME, then the common CHROME_PATH. */
|
|
3
3
|
export declare const CHROME_ENV: readonly ["PI_BROWSER_CHROME", "CHROME_PATH"];
|
|
4
4
|
/**
|
|
5
5
|
* The Chrome or Chromium on this machine: the one PI_BROWSER_CHROME or CHROME_PATH names in `env`, else the first on
|
|
@@ -22,9 +22,8 @@ export declare const CHROME_FLAGS: readonly string[];
|
|
|
22
22
|
* each refused by the proxy after its lookup; no name or address resolved by Chrome itself but the proxy's, so a request
|
|
23
23
|
* a page sends around the proxy reaches nothing; no QUIC, which goes around an HTTP proxy; and WebRTC on no UDP but the
|
|
24
24
|
* proxy's, which carries none, so no ICE candidate is gathered and no STUN packet leaves. That last is
|
|
25
|
-
* `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (
|
|
26
|
-
*
|
|
27
|
-
* Stagehand's extension dialled: nothing in this browser reaches its own DevTools socket.
|
|
25
|
+
* `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (a STUN server on loopback
|
|
26
|
+
* was sent binding requests under it). Nothing in this browser reaches its own DevTools socket.
|
|
28
27
|
*/
|
|
29
28
|
export declare function chromeFence(proxy: string): string[];
|
|
30
29
|
/** Signal 0 only asks; EPERM means the process exists under another user. */
|
package/dist/chrome.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
// Launching a Chrome on this machine, the pieces the local browser (local-chrome.ts, local-supervisor.ts) is made of
|
|
2
|
-
//
|
|
3
|
-
// src/providers/cdp.ts alive, leadsOwnGroup, killTree, ownDebugger and singletonDir), so pi-browser can import them back
|
|
4
|
-
// once it depends on this package; and the fence and sandbox check of PR #1718's local Chrome for serve
|
|
5
|
-
// (packages/serve/src/local-chrome.ts chromeFence and checkChrome), less what was there for Stagehand's extension.
|
|
1
|
+
// Launching a Chrome on this machine, the pieces the local browser (local-chrome.ts, local-supervisor.ts) is made of: finding
|
|
2
|
+
// a Chrome, its process-group and singleton-lock handling, and the fence and sandbox check of a local Chrome.
|
|
6
3
|
//
|
|
7
|
-
// The library reads no environment:
|
|
8
|
-
// environment it is given.
|
|
4
|
+
// The library reads no environment: findChrome takes the environment it is given.
|
|
9
5
|
import { spawn } from "node:child_process";
|
|
10
6
|
import { constants, existsSync, readFileSync } from "node:fs";
|
|
11
7
|
import { access, mkdtemp, readFile, readlink, rm, stat } from "node:fs/promises";
|
|
@@ -23,7 +19,7 @@ const FIXED = [
|
|
|
23
19
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
24
20
|
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
25
21
|
];
|
|
26
|
-
/** The environment names a Chrome is found by:
|
|
22
|
+
/** The environment names a Chrome is found by: PI_BROWSER_CHROME, then the common CHROME_PATH. */
|
|
27
23
|
export const CHROME_ENV = ["PI_BROWSER_CHROME", "CHROME_PATH"];
|
|
28
24
|
/**
|
|
29
25
|
* The Chrome or Chromium on this machine: the one PI_BROWSER_CHROME or CHROME_PATH names in `env`, else the first on
|
|
@@ -71,9 +67,8 @@ export const CHROME_FLAGS = [
|
|
|
71
67
|
* each refused by the proxy after its lookup; no name or address resolved by Chrome itself but the proxy's, so a request
|
|
72
68
|
* a page sends around the proxy reaches nothing; no QUIC, which goes around an HTTP proxy; and WebRTC on no UDP but the
|
|
73
69
|
* proxy's, which carries none, so no ICE candidate is gathered and no STUN packet leaves. That last is
|
|
74
|
-
* `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (
|
|
75
|
-
*
|
|
76
|
-
* Stagehand's extension dialled: nothing in this browser reaches its own DevTools socket.
|
|
70
|
+
* `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (a STUN server on loopback
|
|
71
|
+
* was sent binding requests under it). Nothing in this browser reaches its own DevTools socket.
|
|
77
72
|
*/
|
|
78
73
|
export function chromeFence(proxy) {
|
|
79
74
|
const { hostname, port } = new URL(proxy);
|
|
Binary file
|
|
Binary file
|
|
@@ -31,6 +31,8 @@ export declare const DAYTONA_ENV: {
|
|
|
31
31
|
readonly user: "COMPUTER_DAYTONA_USER";
|
|
32
32
|
/** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
|
|
33
33
|
readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
|
|
34
|
+
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
35
|
+
readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
|
|
34
36
|
};
|
|
35
37
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
36
38
|
export declare const ENV: {
|
|
@@ -50,6 +52,8 @@ export declare const ENV: {
|
|
|
50
52
|
readonly user: "COMPUTER_DAYTONA_USER";
|
|
51
53
|
/** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
|
|
52
54
|
readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
|
|
55
|
+
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
56
|
+
readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
|
|
53
57
|
};
|
|
54
58
|
/**
|
|
55
59
|
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
@@ -39,6 +39,8 @@ export const DAYTONA_ENV = {
|
|
|
39
39
|
user: "COMPUTER_DAYTONA_USER",
|
|
40
40
|
/** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
|
|
41
41
|
snapshot: "COMPUTER_DAYTONA_SNAPSHOT",
|
|
42
|
+
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
43
|
+
gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT",
|
|
42
44
|
};
|
|
43
45
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
44
46
|
export const ENV = DAYTONA_ENV;
|
|
@@ -57,6 +59,7 @@ export function settingsFromEnv(env = process.env) {
|
|
|
57
59
|
const arch = named(DAYTONA_ENV.arch);
|
|
58
60
|
const sandboxClass = named(DAYTONA_ENV.sandboxClass);
|
|
59
61
|
const user = named(DAYTONA_ENV.user);
|
|
62
|
+
const gpuSnapshot = named(DAYTONA_ENV.gpuSnapshot);
|
|
60
63
|
return {
|
|
61
64
|
apiKey,
|
|
62
65
|
...(url ? { apiUrl: url.value } : {}),
|
|
@@ -66,6 +69,8 @@ export function settingsFromEnv(env = process.env) {
|
|
|
66
69
|
// create() refuses any other class in words.
|
|
67
70
|
...(sandboxClass ? { sandboxClass: sandboxClass.value } : {}),
|
|
68
71
|
...(user ? { daemonUser: user.value } : {}),
|
|
72
|
+
// create() refuses a name that is not one of ours in words.
|
|
73
|
+
...(gpuSnapshot ? { gpuSnapshot: gpuSnapshot.value } : {}),
|
|
69
74
|
};
|
|
70
75
|
}
|
|
71
76
|
/** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
|