@parcha/agentrun-computer 0.1.0-beta.60 → 0.1.0-beta.62
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 +54 -10
- package/dist/browser.d.ts +30 -3
- package/dist/browser.js +126 -6
- package/dist/browserbase.d.ts +4 -1
- package/dist/browserbase.js +45 -31
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +1 -1
- package/dist/conformance/render.d.ts +50 -0
- package/dist/conformance/render.js +55 -0
- package/dist/descriptors/index.d.ts +21 -1
- package/dist/descriptors/index.js +3 -2
- package/dist/descriptors/render.d.ts +20 -0
- package/dist/descriptors/render.js +31 -0
- package/dist/host.d.ts +4 -1
- package/dist/hosted/provider.d.ts +3 -1
- package/dist/hosted/provider.js +30 -7
- package/dist/hosted/rest.d.ts +6 -0
- package/dist/hosted/rest.js +11 -2
- package/dist/hosted/values.d.ts +2 -0
- package/dist/hosted/values.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/kernel.js +28 -16
- package/dist/modal.js +3 -1
- package/dist/orgo-workspaces.d.ts +2 -1
- package/dist/orgo-workspaces.js +5 -2
- package/dist/render.d.ts +34 -0
- package/dist/render.js +509 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1322,12 +1322,24 @@ runs on the VM runtime, or on gVisor for a GPU computer (below). Its unit tests
|
|
|
1322
1322
|
- **Sizes are limits**, as in Docker: `cpus` (at least 0.25) becomes `cpuLimit` in physical cores (2 CPUs each) and
|
|
1323
1323
|
`memoryMb` becomes `memoryLimitMiB`, each with Modal's default request (0.125 cores, 128 MiB) or less. `pids` and
|
|
1324
1324
|
`workdir` are refused: Modal has no pids limit, and a computer works in `/work`, its home.
|
|
1325
|
-
- **Tags.** A sandbox's
|
|
1326
|
-
computer's GPUs; no max-deadline, which only `extend` reads) and the caller's. Modal takes 10 tags, 512 bytes of them,
|
|
1327
|
-
values together
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1325
|
+
- **Tags.** A sandbox's labels are the adapter's (`agentrun.computer`, its name, deadline and image, and a GPU
|
|
1326
|
+
computer's GPUs; no max-deadline, which only `extend` reads) and the caller's. Modal takes 10 tags, 512 bytes of them,
|
|
1327
|
+
names and values together, and a computer with a mount, a network list and a run's labels passes 512 bytes as they
|
|
1328
|
+
are, so the adapter keeps them packed (the host's `labels.packed`): two tags, `agentrun` with the computer's name and
|
|
1329
|
+
`agentrun-0` with the labels deflated, and get and list answer them unpacked. `check()` packs them as create gives
|
|
1330
|
+
them, its own at their longest, and refuses in words with no call where the packed tags pass either bound; create
|
|
1331
|
+
refuses the same words first. A sandbox made before the tags were packed carries its labels as tags, and reads as
|
|
1332
|
+
them (`labels.packed.unpacked`): a listing by name asks for the labels as given beside the packed name, within the
|
|
1333
|
+
one bound, so a request that made one sandbox of each form across an upgrade has both seen. The upgrade is one-way: a
|
|
1334
|
+
server from before the change asks for the labels as given alone, so its retry of a create can make a second sandbox
|
|
1335
|
+
beside a packed one. A newer server's create of that request keeps the older of the two only while the two creates
|
|
1336
|
+
race, its own reads of the name after its sandbox is made seeing both; a later create of that request that finds both
|
|
1337
|
+
already there refuses as `exists`, naming both ids, and keeps both. The extra sandbox then lasts until it is deleted
|
|
1338
|
+
or Modal ends it at its lifetime. Upgrade every server that shares a Modal app together to avoid it. A caller's label
|
|
1339
|
+
named `agentrun` or `agentrun-<n>` is refused in words, on every hosted computer: those names hold the packed labels.
|
|
1340
|
+
An Archil computer's mount label records the folder's agent alone, as on every host: the folder's run is the
|
|
1341
|
+
`agentrun.run` label's. `list` is `sandboxes.list({ appId, tags })` over the provider's app: running sandboxes only,
|
|
1342
|
+
and one Modal still lists after its terminate is polled and left out once `poll()` reads it finished.
|
|
1331
1343
|
- **release** `delete` is `terminate()`, and the adapter waits until get answers none (`poll()` reads it finished).
|
|
1332
1344
|
`stop` is refused as `unsupported`: terminate is a sandbox's only end.
|
|
1333
1345
|
- **GPU.** `capabilities().gpu` declares Modal's GPU types by its own names (guide/gpu): `T4`, `L4`, `A10`, `L40S`,
|
|
@@ -2474,7 +2486,9 @@ both find nothing make two computers, so after Orgo's answer, and again once its
|
|
|
2474
2486
|
workspace once more: where an older computer of the request is there (by `created_at`, then id), it deletes its own
|
|
2475
2487
|
and answers the older, and the oldest keeps its own. A caller's signal that aborts one of those reads deletes the
|
|
2476
2488
|
create's own computer (not under that signal) and the create is `aborted`. A name Orgo already holds (two creates in the same second) is
|
|
2477
|
-
answered the same way.
|
|
2489
|
+
answered the same way. A create whose POST got no answer deletes the computer by that exact name, which can be the
|
|
2490
|
+
computer another process's create answered through that 409: not covered, and tracked separately (see the browser
|
|
2491
|
+
providers' gaps below). The parked desktops name each computer at random, so a create retried there makes a second
|
|
2478
2492
|
computer.
|
|
2479
2493
|
|
|
2480
2494
|
- **What each offers.** The protocol groups, by Orgo's calls:
|
|
@@ -2641,12 +2655,42 @@ has ended on its own (its timeout), leaves its request refused `exists`: the pro
|
|
|
2641
2655
|
aborted it) never sends a second create: each POST also writes `agentrun.attempt` (`ATTEMPT_LABEL`), a random value of
|
|
2642
2656
|
its own, and a lost create finds the browsers carrying its attempt label as list does, in every state not ended, under
|
|
2643
2657
|
a signal of its own, releases each under it, and its failure says so; that request is then refused `exists`. Every
|
|
2644
|
-
release a create runs for itself (this one, the newer browser's,
|
|
2658
|
+
release a create runs for itself (this one, the newer browser's, the one after an abort, and that of a browser the
|
|
2659
|
+
vendor made with no usable CDP URL) is bounded by the
|
|
2645
2660
|
provider's `cleanupMs` option (default `RECOVER_MS`, 30 s), never by the caller's signal: one that does not finish in
|
|
2646
2661
|
time fails the create in words that say the browser may still be running, and a retry is answered as above, never
|
|
2647
2662
|
stuck behind it. Another create's browser of the same request, even one another process answered, carries another attempt
|
|
2648
|
-
label and is left running. A
|
|
2649
|
-
|
|
2663
|
+
label and is left running. A lost create's own browser is left for another create's converge when it is the oldest of
|
|
2664
|
+
the request's that runs and the request's browsers, ended ones included, hold a newer one: only another create made
|
|
2665
|
+
that one, and its converge may answer the older. A converge that answers the older releases its own first, so once a
|
|
2666
|
+
newer browser has ended, the lost create's is left running for that create, at once when the first read shows it.
|
|
2667
|
+
Otherwise the request's browsers are read again, every 2 s for up to half of `cleanupMs` (once at least, and sooner
|
|
2668
|
+
when that half is under 2 s). While every newer one still runs, no converge has answered it (each such create kept its
|
|
2669
|
+
own), and at the end it is released. On the first read as on every later one, a newer one that has ended counts before
|
|
2670
|
+
an older one that runs, since a converge whose list missed the older may have answered it. A read that fails, or a read again that misses the lost create's
|
|
2671
|
+
browser or every newer one, says nothing of who holds it and leaves it running; a first read that fails is tried again
|
|
2672
|
+
within the same half before that. The search's own retries, for a vendor that lists a browser late, wait within that
|
|
2673
|
+
half too, so the release keeps the other half.
|
|
2674
|
+
Browserbase is asked status by status in a session's own order (pending, then running, then the ended ones), so a
|
|
2675
|
+
session that moves on while a list runs is found in a later answer, never missed, and one found in two answers reads as
|
|
2676
|
+
the later one says; Kernel answers every state in one paged list, and a browser listed twice reads as deleted once
|
|
2677
|
+
either row says so. A newer browser that ended for another reason reads the same as one a converge released: its create was aborted
|
|
2678
|
+
while it listed the request, or released its own and then failed (its release reported a failure, or its read of the
|
|
2679
|
+
older failed), or its own reply was lost too and its recovery released it. Nothing on the vendor tells those apart, so
|
|
2680
|
+
there the lost create's browser runs to the vendor's lifetime: on Browserbase its `timeout`, up to the run's lifetime
|
|
2681
|
+
and at most 6 h; on Kernel its idle timeout, at most 72 h. One kept because the request could not be read runs as long.
|
|
2682
|
+
The create's failure says so, and its labels let a sweep find it. This bound is not covered, and is tracked separately.
|
|
2683
|
+
Where a read shows the lost create's browser is the request's only one, it is released. A 4xx refusal made nothing, so nothing is looked for. Both labels are the provider's own: `check()` refuses
|
|
2684
|
+
them in a spec, and no list or attach shows them.
|
|
2685
|
+
|
|
2686
|
+
Two gaps are not covered, and are tracked separately. A lost create whose browser is the request's only one releases
|
|
2687
|
+
it even when another process's create answered it by its lookup, or when the lost create read the request before the
|
|
2688
|
+
other create's POST landed and that create's converge answered it: nothing on the vendor says so, and that create
|
|
2689
|
+
holds a browser that has ended. The same holds when a converge lists the lost create's browser running just before the
|
|
2690
|
+
lost create's last read again and ends its own just after: the lost create releases it, and that create's read of it
|
|
2691
|
+
most often finds it ended and fails the request. On Orgo, a create whose POST got no answer deletes the computer by its exact name; that
|
|
2692
|
+
name can be the computer another process's create answered through Orgo's 409 (name in use), which then holds a
|
|
2693
|
+
deleted computer.
|
|
2650
2694
|
|
|
2651
2695
|
The conformance CLI runs the browser case set for a provider of kind browser: the health cases, then `browser.*`
|
|
2652
2696
|
(check past the cap, attach by id and by labels, list, CDP `Browser.getVersion` and `Runtime.evaluate` on a `data:`
|
package/dist/browser.d.ts
CHANGED
|
@@ -96,6 +96,25 @@ export declare function heldBrowser(asked: Record<string, string>, found: Readon
|
|
|
96
96
|
* answers in place of its own once it has released its own. Every process picks the same one from the same listing.
|
|
97
97
|
*/
|
|
98
98
|
export declare function convergedBrowser(listed: ReadonlyArray<HeldBrowser>, mine: HeldBrowser): "mine" | HeldBrowser;
|
|
99
|
+
/** A browser of a request as a lost create's recovery reads it, ended ones included: whether it still runs. */
|
|
100
|
+
export type MadeBrowser = HeldBrowser & {
|
|
101
|
+
live: boolean;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Whether a lost create's browser (`mine`) is left to another create of its request rather than released: it still runs,
|
|
105
|
+
* no older browser of the request runs (so every converge keeps it), and the request's browsers, ended ones included,
|
|
106
|
+
* hold a newer one, which only another create made: that create's converge may answer mine. A lost create whose browser
|
|
107
|
+
* is the request's only one releases it.
|
|
108
|
+
*/
|
|
109
|
+
export declare function leftToConverge(mine: string, made: ReadonlyArray<MadeBrowser>): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Where a lost create's browser left to a converge (leftToConverge) stands when the request's browsers are read again:
|
|
112
|
+
* "unread" when the read lists neither mine nor any newer one (the first read did, so it says nothing); "release" once
|
|
113
|
+
* mine has ended; "answered" when a newer one has ended, since a converge that answers the older ends its own first, and
|
|
114
|
+
* one whose list missed an older browser may have answered mine; "release" when an older one runs and every newer one
|
|
115
|
+
* runs too; "running" while every newer one still runs, so no converge has answered mine yet.
|
|
116
|
+
*/
|
|
117
|
+
export declare function convergeSettled(mine: string, made: ReadonlyArray<MadeBrowser>): "answered" | "running" | "release" | "unread";
|
|
99
118
|
/**
|
|
100
119
|
* Whether a create that threw may still have made a browser: anything but the vendor's own 4xx answer (a refusal, which
|
|
101
120
|
* makes nothing). A request not answered, aborted, cut short, or answered 5xx or with a body that is no browser may
|
|
@@ -109,10 +128,18 @@ export declare function createUncertain(error: unknown): boolean;
|
|
|
109
128
|
export declare const RECOVER_MS = 30000;
|
|
110
129
|
/**
|
|
111
130
|
* After a create whose outcome is unknown: the browsers carrying its create label, found and released under a signal
|
|
112
|
-
* of the recovery's own, `ms` in all (the caller's may be what ended the create). The
|
|
113
|
-
* the
|
|
131
|
+
* of the recovery's own, `ms` in all (the caller's may be what ended the create). The search, its retries for a vendor
|
|
132
|
+
* that lists late and the reads below wait at most until half of `ms` has passed, each wait RECOVER_GAP_MS or what is
|
|
133
|
+
* left of that half, so the release keeps the other half. Where `made` reads the request's browsers (ended ones
|
|
134
|
+
* included), each found browser's request is read, again after a failed read, and one that cannot be read is kept: a
|
|
135
|
+
* failed read says nothing of who holds it. One older than a browser of its request that has ended (convergeSettled) is
|
|
136
|
+
* kept at once, even when an older one runs, as a converge that answers it ends its own first and one whose list missed
|
|
137
|
+
* the older may have answered it. One left to another create's converge (leftToConverge) is otherwise read again,
|
|
138
|
+
* every RECOVER_GAP_MS within that half (once at least), and kept once a newer one has ended or a read fails or misses
|
|
139
|
+
* a browser the first read listed. One whose newer browsers all still run at the end was answered by no converge (each
|
|
140
|
+
* kept its own) and is released. The words say what became of them, for the create's failure; they never carry a URL.
|
|
114
141
|
*/
|
|
115
|
-
export declare function recoverCreate(what: string, find: (signal: AbortSignal) => Promise<Result<string[]>>, release: (id: string, signal: AbortSignal) => Promise<Result<void>>, sleep: (ms: number) => Promise<void>, ms?: number): Promise<string>;
|
|
142
|
+
export declare function recoverCreate(what: string, find: (signal: AbortSignal) => Promise<Result<string[]>>, release: (id: string, signal: AbortSignal) => Promise<Result<void>>, sleep: (ms: number) => Promise<void>, ms?: number, made?: (signal: AbortSignal) => Promise<Result<MadeBrowser[]>>): Promise<string>;
|
|
116
143
|
/**
|
|
117
144
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
|
118
145
|
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds, the session's
|
package/dist/browser.js
CHANGED
|
@@ -105,6 +105,40 @@ export function convergedBrowser(listed, mine) {
|
|
|
105
105
|
const kept = holders.sort(oldestBrowserFirst)[0];
|
|
106
106
|
return kept.id === mine.id ? "mine" : kept;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Whether a lost create's browser (`mine`) is left to another create of its request rather than released: it still runs,
|
|
110
|
+
* no older browser of the request runs (so every converge keeps it), and the request's browsers, ended ones included,
|
|
111
|
+
* hold a newer one, which only another create made: that create's converge may answer mine. A lost create whose browser
|
|
112
|
+
* is the request's only one releases it.
|
|
113
|
+
*/
|
|
114
|
+
export function leftToConverge(mine, made) {
|
|
115
|
+
const own = made.find((one) => one.id === mine);
|
|
116
|
+
if (own === undefined || !own.live)
|
|
117
|
+
return false;
|
|
118
|
+
if (made.some((one) => one.id !== mine && one.live && oldestBrowserFirst(one, own) < 0))
|
|
119
|
+
return false;
|
|
120
|
+
return made.some((one) => one.id !== mine && oldestBrowserFirst(own, one) < 0);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Where a lost create's browser left to a converge (leftToConverge) stands when the request's browsers are read again:
|
|
124
|
+
* "unread" when the read lists neither mine nor any newer one (the first read did, so it says nothing); "release" once
|
|
125
|
+
* mine has ended; "answered" when a newer one has ended, since a converge that answers the older ends its own first, and
|
|
126
|
+
* one whose list missed an older browser may have answered mine; "release" when an older one runs and every newer one
|
|
127
|
+
* runs too; "running" while every newer one still runs, so no converge has answered mine yet.
|
|
128
|
+
*/
|
|
129
|
+
export function convergeSettled(mine, made) {
|
|
130
|
+
const own = made.find((one) => one.id === mine);
|
|
131
|
+
if (own === undefined)
|
|
132
|
+
return "unread";
|
|
133
|
+
if (!own.live)
|
|
134
|
+
return "release";
|
|
135
|
+
const newer = made.filter((one) => one.id !== mine && oldestBrowserFirst(own, one) < 0);
|
|
136
|
+
if (newer.length === 0)
|
|
137
|
+
return "unread";
|
|
138
|
+
if (newer.some((one) => !one.live))
|
|
139
|
+
return "answered";
|
|
140
|
+
return made.some((one) => one.id !== mine && one.live && oldestBrowserFirst(one, own) < 0) ? "release" : "running";
|
|
141
|
+
}
|
|
108
142
|
/**
|
|
109
143
|
* Whether a create that threw may still have made a browser: anything but the vendor's own 4xx answer (a refusal, which
|
|
110
144
|
* makes nothing). A request not answered, aborted, cut short, or answered 5xx or with a body that is no browser may
|
|
@@ -123,15 +157,25 @@ const RECOVER_TRIES = 3;
|
|
|
123
157
|
const RECOVER_GAP_MS = 2_000;
|
|
124
158
|
/**
|
|
125
159
|
* After a create whose outcome is unknown: the browsers carrying its create label, found and released under a signal
|
|
126
|
-
* of the recovery's own, `ms` in all (the caller's may be what ended the create). The
|
|
127
|
-
* the
|
|
160
|
+
* of the recovery's own, `ms` in all (the caller's may be what ended the create). The search, its retries for a vendor
|
|
161
|
+
* that lists late and the reads below wait at most until half of `ms` has passed, each wait RECOVER_GAP_MS or what is
|
|
162
|
+
* left of that half, so the release keeps the other half. Where `made` reads the request's browsers (ended ones
|
|
163
|
+
* included), each found browser's request is read, again after a failed read, and one that cannot be read is kept: a
|
|
164
|
+
* failed read says nothing of who holds it. One older than a browser of its request that has ended (convergeSettled) is
|
|
165
|
+
* kept at once, even when an older one runs, as a converge that answers it ends its own first and one whose list missed
|
|
166
|
+
* the older may have answered it. One left to another create's converge (leftToConverge) is otherwise read again,
|
|
167
|
+
* every RECOVER_GAP_MS within that half (once at least), and kept once a newer one has ended or a read fails or misses
|
|
168
|
+
* a browser the first read listed. One whose newer browsers all still run at the end was answered by no converge (each
|
|
169
|
+
* kept its own) and is released. The words say what became of them, for the create's failure; they never carry a URL.
|
|
128
170
|
*/
|
|
129
|
-
export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS) {
|
|
171
|
+
export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS, made) {
|
|
130
172
|
const signal = AbortSignal.timeout(ms);
|
|
173
|
+
const settleBy = Date.now() + ms / 2;
|
|
174
|
+
const reads = Math.max(1, Math.floor(ms / 2 / RECOVER_GAP_MS));
|
|
131
175
|
let found = ok([]);
|
|
132
176
|
for (let tries = 0; tries < RECOVER_TRIES; tries++) {
|
|
133
|
-
if (tries > 0)
|
|
134
|
-
|
|
177
|
+
if (tries > 0 && !(await waitWithin(sleep, settleBy, signal)))
|
|
178
|
+
break;
|
|
135
179
|
found = await find(signal);
|
|
136
180
|
if (!found.ok || found.value.length > 0 || signal.aborted)
|
|
137
181
|
break;
|
|
@@ -142,9 +186,31 @@ export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS)
|
|
|
142
186
|
return `no ${what} carries its create label, so none was made or the vendor does not list it yet; its labels let a sweep find it`;
|
|
143
187
|
const words = [];
|
|
144
188
|
for (const id of found.value) {
|
|
189
|
+
let unanswered = false;
|
|
190
|
+
if (made !== undefined) {
|
|
191
|
+
const read = await firstRead(made, signal, sleep, settleBy, Math.max(1, Math.ceil(ms / 2 / RECOVER_GAP_MS)));
|
|
192
|
+
if (read === undefined) {
|
|
193
|
+
words.push(`the ${what} it made (${id}) may be one another create of its request answered, and the request's browsers could not be read, so nothing says who holds it: it is left running, at most to its lifetime, and its labels let a sweep find it`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const answered = convergeSettled(id, read) === "answered";
|
|
197
|
+
if (answered || leftToConverge(id, read)) {
|
|
198
|
+
const settled = answered ? "answered" : await settle(id, made, signal, sleep, settleBy, reads);
|
|
199
|
+
if (settled === "answered") {
|
|
200
|
+
words.push(`the ${what} it made (${id}) is older than one of its request that has ended, as a create's converge ends its own when it answers an older one: it is left running for that create, and if that create did not answer it (aborted, or failed once its own had ended, or its reply lost too) it runs to its lifetime, and its labels let a sweep find it`);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (settled === "unread") {
|
|
204
|
+
words.push(`the ${what} it made (${id}) is its request's oldest, which another create of the request may answer, and the request's browsers could not be read again: it is left running, at most to its lifetime, and its labels let a sweep find it`);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
unanswered = settled === "running";
|
|
208
|
+
}
|
|
209
|
+
}
|
|
145
210
|
const released = await release(id, signal);
|
|
211
|
+
const why = unanswered ? `, since every newer ${what} of its request still runs and so no other create answered it` : "";
|
|
146
212
|
if (released.ok)
|
|
147
|
-
words.push(`the ${what} it made (${id}) was released`);
|
|
213
|
+
words.push(`the ${what} it made (${id}) was released${why}`);
|
|
148
214
|
else if (signal.aborted)
|
|
149
215
|
words.push(`the ${what} it made (${id}) may still be running: the search and its release did not finish within ${ms / 1000} s, and its labels let a sweep find it`);
|
|
150
216
|
else
|
|
@@ -152,6 +218,60 @@ export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS)
|
|
|
152
218
|
}
|
|
153
219
|
return words.join("; ");
|
|
154
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* One wait before a search or a read is tried again: RECOVER_GAP_MS, or what is left until `by` when that is less.
|
|
223
|
+
* False, with no wait, once nothing is left or the recovery's signal has ended.
|
|
224
|
+
*/
|
|
225
|
+
async function waitWithin(sleep, by, signal) {
|
|
226
|
+
const left = by - Date.now();
|
|
227
|
+
if (left <= 0 || signal.aborted)
|
|
228
|
+
return false;
|
|
229
|
+
await sleep(Math.min(RECOVER_GAP_MS, left));
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The request's browsers, read at once and then again after each failed read, `retries` times at most, each after a
|
|
234
|
+
* wait that ends no later than `by` (waitWithin): so a window shorter than two gaps still tries again while time is left.
|
|
235
|
+
* Undefined when no read answered.
|
|
236
|
+
*/
|
|
237
|
+
async function firstRead(made, signal, sleep, by, retries) {
|
|
238
|
+
for (let read = 0; read <= retries; read++) {
|
|
239
|
+
if (read > 0 && !(await waitWithin(sleep, by, signal)))
|
|
240
|
+
break;
|
|
241
|
+
const got = await made(signal);
|
|
242
|
+
if (got.ok)
|
|
243
|
+
return got.value;
|
|
244
|
+
}
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A left browser's request read again (convergeSettled) after each RECOVER_GAP_MS, until it is answered or released,
|
|
249
|
+
* `reads` times at most and not past `by` (one read at least): "running" when the last read still found every newer
|
|
250
|
+
* browser running, "unread" when the last read failed or missed a browser the first read listed. No wait runs past
|
|
251
|
+
* `by`, so a bound shorter than the gap still reads once within it, and the read and the release keep the time after
|
|
252
|
+
* `by`.
|
|
253
|
+
*/
|
|
254
|
+
async function settle(mine, made, signal, sleep, by, reads) {
|
|
255
|
+
let last = "unread";
|
|
256
|
+
for (let read = 0; read < reads; read++) {
|
|
257
|
+
const left = by - Date.now();
|
|
258
|
+
if ((read > 0 && left < RECOVER_GAP_MS) || signal.aborted)
|
|
259
|
+
break;
|
|
260
|
+
await sleep(Math.max(0, Math.min(RECOVER_GAP_MS, left)));
|
|
261
|
+
const again = await made(signal);
|
|
262
|
+
if (!again.ok) {
|
|
263
|
+
last = "unread";
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const now = convergeSettled(mine, again.value);
|
|
267
|
+
if (now === "unread" || now === "running") {
|
|
268
|
+
last = now;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
return now;
|
|
272
|
+
}
|
|
273
|
+
return last;
|
|
274
|
+
}
|
|
155
275
|
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "gpu", "browser"]);
|
|
156
276
|
/**
|
|
157
277
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
package/dist/browserbase.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare const BROWSERBASE_CDP_DOMAIN = "browserbase.com";
|
|
|
8
8
|
export declare const BROWSERBASE_MAX_LIFETIME_MS: number;
|
|
9
9
|
/** Browserbase's shortest session timeout: 60 s. */
|
|
10
10
|
export declare const BROWSERBASE_MIN_LIFETIME_MS = 60000;
|
|
11
|
+
/** The statuses of a session that runs (PENDING bills once it starts); any other has ended. */
|
|
12
|
+
type SessionStatus = "RUNNING" | "PENDING" | "COMPLETED" | "ERROR" | "TIMED_OUT";
|
|
11
13
|
/** The userMetadata key a label key is written under: each "." as "_", since Browserbase refuses a dot there. */
|
|
12
14
|
export declare const metadataKey: (labelKey: string) => string;
|
|
13
15
|
/** The label key a userMetadata key reads back as: each "_" as ".". */
|
|
@@ -59,7 +61,7 @@ export interface BrowserbaseApi {
|
|
|
59
61
|
/** undefined when Browserbase does not know the session (404). */
|
|
60
62
|
retrieve(id: string, signal?: AbortSignal): Promise<BrowserbaseSession | undefined>;
|
|
61
63
|
list(query: {
|
|
62
|
-
status:
|
|
64
|
+
status: SessionStatus;
|
|
63
65
|
q?: string;
|
|
64
66
|
}, signal?: AbortSignal): Promise<BrowserbaseSession[]>;
|
|
65
67
|
/** "gone" when Browserbase does not know the session (404). */
|
|
@@ -179,3 +181,4 @@ export declare class BrowserbaseProvider implements ComputerProvider, BrowserCom
|
|
|
179
181
|
export declare function create(options: BrowserbaseProviderOptions): BrowserbaseProvider;
|
|
180
182
|
/** The conformance CLI's module for Browserbase: its live switch, its image and its notes. */
|
|
181
183
|
export declare const conformance: () => Promise<typeof import("./conformance/browserbase.js")>;
|
|
184
|
+
export {};
|
package/dist/browserbase.js
CHANGED
|
@@ -23,7 +23,7 @@ import { BROWSERBASE } from "./descriptors/browserbase.js";
|
|
|
23
23
|
import { BROWSER_IMAGE } from "./descriptors/shared.js";
|
|
24
24
|
import { cdpUrlProblem, browserClient, browserHello, BrowserVendorError, CREATE_LABEL, carries, causeOf, checkBrowser, createUncertain, DEFAULT_CONFIRM, ATTEMPT_LABEL, convergedBrowser, heldBrowser, newAttempt, defaultSleep, idProblem, labelsOf, labelsProblem, limitedBytes, memoryUrls, pointerOk, queryable, RECOVER_MS, recoverCreate, releaseConfirmed, boundedRelease, restBytes, restCall, causedFail, vendorFailure, withoutCreateLabel, } from "./browser.js";
|
|
25
25
|
import { CreateRequests, endedWords, labelsDiffer, otherSpecWords } from "./create-requests.js";
|
|
26
|
-
import { httpsBase } from "./hosted/rest.js";
|
|
26
|
+
import { httpsBase, keyBase } from "./hosted/rest.js";
|
|
27
27
|
import { runLifetimeMs, } from "./provider.js";
|
|
28
28
|
import { failFor, ok, vendorFail } from "./result.js";
|
|
29
29
|
import { connectionError } from "./test-connection.js";
|
|
@@ -39,8 +39,16 @@ const CDP_DOMAIN = BROWSERBASE_CDP_DOMAIN;
|
|
|
39
39
|
export const BROWSERBASE_MAX_LIFETIME_MS = 6 * 60 * 60_000;
|
|
40
40
|
/** Browserbase's shortest session timeout: 60 s. */
|
|
41
41
|
export const BROWSERBASE_MIN_LIFETIME_MS = 60_000;
|
|
42
|
-
/** The statuses of a session that runs (PENDING bills once it starts); any other has ended. */
|
|
43
42
|
const LIVE = new Set(["RUNNING", "PENDING"]);
|
|
43
|
+
/** Every status a session reads as, ended ones included: a request's whole record (#requestBrowsers). */
|
|
44
|
+
const EVER = new Set([...LIVE, "COMPLETED", "ERROR", "TIMED_OUT"]);
|
|
45
|
+
/**
|
|
46
|
+
* The order #sessions asks for the statuses, a session's own: it is PENDING, then RUNNING, then ended, and never goes
|
|
47
|
+
* back. Each group is asked once the one before has answered, so a session that moves on while the read runs is found
|
|
48
|
+
* by a later group, never missed between two (asked side by side, a session could leave RUNNING after the COMPLETED
|
|
49
|
+
* answer and before the RUNNING one, and be in neither). The ended statuses are asked together: none moves to another.
|
|
50
|
+
*/
|
|
51
|
+
const LIFECYCLE = [["PENDING"], ["RUNNING"], ["COMPLETED", "ERROR", "TIMED_OUT"]];
|
|
44
52
|
/** A label key Browserbase's metadata can carry once its dots are underscores: letters, digits and dots, so the mapping is one to one. */
|
|
45
53
|
const LABEL_KEY = /^[A-Za-z0-9.]+$/;
|
|
46
54
|
/** The userMetadata key a label key is written under: each "." as "_", since Browserbase refuses a dot there. */
|
|
@@ -173,23 +181,12 @@ export function throughGateway(connectUrl, connectBase) {
|
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
/**
|
|
176
|
-
* The gateway that fronts the sessions' sockets (BROWSERBASE_CONNECT_BASE_URL), held to
|
|
177
|
-
*
|
|
178
|
-
*
|
|
184
|
+
* The gateway that fronts the sessions' sockets (BROWSERBASE_CONNECT_BASE_URL), held to the rule of a URL a key goes to
|
|
185
|
+
* over wss: or https: (keyBase), since every session's signed CDP URL rides it: another scheme, loopback included, a user
|
|
186
|
+
* or password, a query or a fragment throws in keyBase's words, which name the origin at most.
|
|
179
187
|
*/
|
|
180
188
|
function connectBaseOf(url) {
|
|
181
|
-
|
|
182
|
-
return undefined;
|
|
183
|
-
let parsed;
|
|
184
|
-
try {
|
|
185
|
-
parsed = new URL(url);
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
throw new Error("BROWSERBASE_CONNECT_BASE_URL is not a URL");
|
|
189
|
-
}
|
|
190
|
-
if (parsed.protocol !== "wss:" && parsed.protocol !== "https:")
|
|
191
|
-
throw new Error(`BROWSERBASE_CONNECT_BASE_URL must be wss or https, so a session's signed URL never crosses in the clear: ${parsed.protocol}`);
|
|
192
|
-
return url;
|
|
189
|
+
return url === undefined ? undefined : keyBase(url, "BROWSERBASE_CONNECT_BASE_URL", ["wss:", "https:"]);
|
|
193
190
|
}
|
|
194
191
|
const refOf = (s) => ({ id: s.id, name: s.id });
|
|
195
192
|
const deadlineOf = (s) => {
|
|
@@ -345,11 +342,11 @@ export class BrowserbaseProvider {
|
|
|
345
342
|
// The session may have been made though its answer never came: found by this POST's attempt label and
|
|
346
343
|
// released, and the request is ended, so it is never made again.
|
|
347
344
|
this.#requests.end(request);
|
|
348
|
-
return causedFail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt)}`, causeOf(failed), "browserbase");
|
|
345
|
+
return causedFail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt, request)}`, causeOf(failed), "browserbase");
|
|
349
346
|
}
|
|
350
347
|
if (idProblem(made?.id, NAME) !== undefined) {
|
|
351
348
|
this.#requests.end(request);
|
|
352
|
-
return vendorFail("browserbase", `Browserbase POST /v1/sessions answered with no session id, so there is no session to connect to; ${await this.#recover(attempt)}`);
|
|
349
|
+
return vendorFail("browserbase", `Browserbase POST /v1/sessions answered with no session id, so there is no session to connect to; ${await this.#recover(attempt, request)}`);
|
|
353
350
|
}
|
|
354
351
|
this.#requests.made(request);
|
|
355
352
|
// Another process's create of this request may have made one too (#converge): the older is answered.
|
|
@@ -359,9 +356,9 @@ export class BrowserbaseProvider {
|
|
|
359
356
|
this.#requestOf.set(made.id, request);
|
|
360
357
|
const unusable = cdpUrlProblem(made.connectUrl, NAME, CDP_DOMAIN);
|
|
361
358
|
if (unusable !== undefined) {
|
|
362
|
-
// The session is made and billed (keepAlive, up to its timeout): released here,
|
|
363
|
-
const released = await this.release(refOf(made), "delete");
|
|
364
|
-
return vendorFail("browserbase", `Browserbase POST /v1/sessions made a session with no CDP URL to hand over: ${unusable}; ${released.ok ? "the session was released" : `the session was not released (${released.error.
|
|
359
|
+
// The session is made and billed (keepAlive, up to its timeout): released here, under the cleanup's own bound.
|
|
360
|
+
const released = await boundedRelease("session", made.id, this.#cleanupMs, (bound) => this.release(refOf(made), "delete", { signal: bound }));
|
|
361
|
+
return vendorFail("browserbase", `Browserbase POST /v1/sessions made a session with no CDP URL to hand over: ${unusable}; ${released.ok ? "the session was released" : `the session was not released (${released.error.message}), and its labels let a sweep find it`}`);
|
|
365
362
|
}
|
|
366
363
|
this.#urls.set(made.id, made.connectUrl);
|
|
367
364
|
return ok(refOf(made));
|
|
@@ -527,12 +524,18 @@ export class BrowserbaseProvider {
|
|
|
527
524
|
* session, of this request or another, carries an attempt label of its own and is left alone, even one another
|
|
528
525
|
* instance has answered.
|
|
529
526
|
*/
|
|
530
|
-
#recover(labels) {
|
|
527
|
+
#recover(labels, request) {
|
|
531
528
|
const find = async (signal) => {
|
|
532
529
|
const found = await this.#sessions(labels, signal);
|
|
533
530
|
return found.ok ? ok(found.value.map((s) => s.id)) : found;
|
|
534
531
|
};
|
|
535
|
-
|
|
532
|
+
const made = (signal) => this.#requestBrowsers(request, signal);
|
|
533
|
+
return recoverCreate("session", find, (id, signal) => this.release({ id, name: id }, "delete", { signal }), this.#sleep, this.#cleanupMs, made);
|
|
534
|
+
}
|
|
535
|
+
/** The request's sessions, ended ones included, for a lost create's recovery (recoverCreate, leftToConverge). */
|
|
536
|
+
async #requestBrowsers(request, signal) {
|
|
537
|
+
const made = await this.#sessions({ [CREATE_LABEL]: request }, signal, EVER);
|
|
538
|
+
return made.ok ? ok(made.value.map((s) => ({ ...heldOf(s), live: LIVE.has(s.status) }))) : made;
|
|
536
539
|
}
|
|
537
540
|
/**
|
|
538
541
|
* Settings' test: one read of the project's running sessions (GET /v1/sessions?status=RUNNING), which makes nothing.
|
|
@@ -567,7 +570,7 @@ export class BrowserbaseProvider {
|
|
|
567
570
|
}
|
|
568
571
|
if (found === undefined)
|
|
569
572
|
return fail("not_found", `no Browserbase session has the id ${id}`);
|
|
570
|
-
if (!LIVE.has(found.status
|
|
573
|
+
if (!LIVE.has(found.status))
|
|
571
574
|
return fail("gone", `the Browserbase session ${id} has ended (${found.status ?? "no status"}): only a running session is attached or connected to`);
|
|
572
575
|
return ok(found);
|
|
573
576
|
}
|
|
@@ -603,9 +606,11 @@ export class BrowserbaseProvider {
|
|
|
603
606
|
/**
|
|
604
607
|
* The running and pending sessions with all of these labels. Browserbase is asked by status and by the first label a
|
|
605
608
|
* query carries as it is; the match is the provider's own, so a lane that drops the query never hands back another's.
|
|
606
|
-
* Both statuses must answer: a release trusts this list.
|
|
609
|
+
* Both statuses must answer: a release trusts this list. `statuses` widens it, to the ended ones too (EVER). The
|
|
610
|
+
* statuses are asked in a session's own order (LIFECYCLE), so every session there when the read starts is found, and a
|
|
611
|
+
* session found in two answers reads as the later one says.
|
|
607
612
|
*/
|
|
608
|
-
async #sessions(labels, signal) {
|
|
613
|
+
async #sessions(labels, signal, statuses = LIVE) {
|
|
609
614
|
const problem = browserbaseLabelsProblem(labels);
|
|
610
615
|
if (problem)
|
|
611
616
|
return fail("invalid", problem);
|
|
@@ -613,15 +618,24 @@ export class BrowserbaseProvider {
|
|
|
613
618
|
return fail("invalid", "list and attach take at least one label: a Browserbase project holds sessions this provider did not make");
|
|
614
619
|
const first = Object.entries(labels).find(queryable);
|
|
615
620
|
const q = first === undefined ? undefined : `user_metadata['${metadataKey(first[0])}']:'${first[1]}'`;
|
|
616
|
-
|
|
621
|
+
const found = new Map();
|
|
617
622
|
try {
|
|
618
|
-
|
|
623
|
+
for (const group of LIFECYCLE) {
|
|
624
|
+
const asked = group.filter((status) => statuses.has(status));
|
|
625
|
+
if (asked.length === 0)
|
|
626
|
+
continue;
|
|
627
|
+
const pages = await Promise.all(asked.map((status) => this.#api.list({ status, ...(q === undefined ? {} : { q }) }, signal)));
|
|
628
|
+
for (const s of pages.flat()) {
|
|
629
|
+
// A later group's row wins: a session only moves forward, so one answered RUNNING and then COMPLETED has ended.
|
|
630
|
+
if (typeof s?.id === "string" && statuses.has(s.status) && carries(metadataLabels(s.userMetadata), labels))
|
|
631
|
+
found.set(s.id, s);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
619
634
|
}
|
|
620
635
|
catch (error) {
|
|
621
636
|
return vendorFailure("browserbase", NAME, "GET /v1/sessions", error);
|
|
622
637
|
}
|
|
623
|
-
|
|
624
|
-
return ok(pages.flat().filter((s) => typeof s?.id === "string" && LIVE.has(s.status ?? "") && carries(metadataLabels(s.userMetadata), labels) && !seen.has(s.id) && seen.add(s.id)));
|
|
638
|
+
return ok([...found.values()]);
|
|
625
639
|
}
|
|
626
640
|
async list(labels, { signal } = {}) {
|
|
627
641
|
const found = await this.#sessions(labels, signal);
|
|
Binary file
|
|
Binary file
|
package/dist/computerd.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MachineHost } from "../host.js";
|
|
2
|
+
import type { HostedDial } from "../hosted/provider.js";
|
|
3
|
+
import type { ProviderNote } from "../mount-archil.js";
|
|
4
|
+
import { type RenderProvider } from "../render.js";
|
|
5
|
+
import { CONFORMANCE_MAX_LIFETIME_MS, type Env } from "./module-kit.js";
|
|
6
|
+
export { CONFORMANCE_MAX_LIFETIME_MS };
|
|
7
|
+
export declare const RENDER_ENV: {
|
|
8
|
+
/** apiKey, required: a Render API key that may make sandboxes in the workspace. */
|
|
9
|
+
readonly key: "COMPUTER_RENDER_API_KEY";
|
|
10
|
+
/** ownerId, required: the workspace the run's sandboxes are made in (tea-… or usr-…). */
|
|
11
|
+
readonly workspace: "COMPUTER_RENDER_WORKSPACE_ID";
|
|
12
|
+
/** The build the run's computers start from; default the box build prepareImage() finds or imports. */
|
|
13
|
+
readonly image: "COMPUTER_RENDER_IMAGE";
|
|
14
|
+
};
|
|
15
|
+
export declare const ENV: {
|
|
16
|
+
/** apiKey, required: a Render API key that may make sandboxes in the workspace. */
|
|
17
|
+
readonly key: "COMPUTER_RENDER_API_KEY";
|
|
18
|
+
/** ownerId, required: the workspace the run's sandboxes are made in (tea-… or usr-…). */
|
|
19
|
+
readonly workspace: "COMPUTER_RENDER_WORKSPACE_ID";
|
|
20
|
+
/** The build the run's computers start from; default the box build prepareImage() finds or imports. */
|
|
21
|
+
readonly image: "COMPUTER_RENDER_IMAGE";
|
|
22
|
+
};
|
|
23
|
+
/** The provider's options this module reads from env; throws in words without the key or the workspace, never echoing one. */
|
|
24
|
+
export declare function settingsFromEnv(env?: Env): {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
ownerId: string;
|
|
27
|
+
};
|
|
28
|
+
export interface RenderModuleOptions {
|
|
29
|
+
/** The environment to read; process.env by default. */
|
|
30
|
+
env?: Record<string, string | undefined>;
|
|
31
|
+
/** The server the machines dial: dial-conformance.mjs gives its own. Without it every create is refused in words. */
|
|
32
|
+
dial?: HostedDial;
|
|
33
|
+
/** The daemon the server serves (its sha256 is what a machine checks); default this package's dist/computerd-linux-amd64. */
|
|
34
|
+
daemonPath?: string;
|
|
35
|
+
/** The fetch Render's calls go through; default the global one. */
|
|
36
|
+
fetch?: typeof fetch;
|
|
37
|
+
/** What the provider says that is no failure: the CLI gives it and puts it in the report. */
|
|
38
|
+
onNote?: ProviderNote;
|
|
39
|
+
}
|
|
40
|
+
/** The provider the run makes computers with, dialing the server options.dial names. */
|
|
41
|
+
export declare function createProvider({ env, dial, daemonPath, fetch, onNote }?: RenderModuleOptions): RenderProvider;
|
|
42
|
+
/** The run's image: COMPUTER_RENDER_IMAGE's build, else the box build the workspace has or imports (prepareImage). */
|
|
43
|
+
export declare function conformanceImage(options?: RenderModuleOptions, { signal }?: {
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
}): Promise<string>;
|
|
46
|
+
/** The server the run's machines dial, for provider.dial-token, as the CLI asks for it: refused in words (dial-only.ts). */
|
|
47
|
+
export declare const dialKit: () => import("./types.js").DialKit;
|
|
48
|
+
export declare function createHost({ env, fetch }?: Pick<RenderModuleOptions, "env" | "fetch">): MachineHost;
|
|
49
|
+
/** Where the sweep lists, in words: the workspace the settings name. */
|
|
50
|
+
export declare function sweepScope({ env }?: Pick<RenderModuleOptions, "env">): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Render Sandboxes for the conformance run. Its machines dial the server that minted their tokens (facts.connect
|
|
2
|
+
// "dial"), so a Core run has to happen inside that server's own process, behind its public address: serve's
|
|
3
|
+
// packages/serve/scripts/dial-conformance.mjs --provider render does it: it gives createProvider() its dial (the public
|
|
4
|
+
// URL, the minted tokens and the attach hub) and the run a DialKit over the same server. From a laptop's CLI there is no
|
|
5
|
+
// such server: dialKit() refuses in words, and the provider refuses every create before Render is called. The key is
|
|
6
|
+
// read from COMPUTER_RENDER_API_KEY alone (never RENDER_API_KEY, which may hold a production key).
|
|
7
|
+
import { RENDER } from "../descriptors/render.js";
|
|
8
|
+
import { create } from "../render.js";
|
|
9
|
+
import { dialOnlyFromServer } from "./dial-only.js";
|
|
10
|
+
import { CONFORMANCE_MAX_LIFETIME_MS, preparedImage } from "./module-kit.js";
|
|
11
|
+
export { CONFORMANCE_MAX_LIFETIME_MS };
|
|
12
|
+
export const RENDER_ENV = {
|
|
13
|
+
/** apiKey, required: a Render API key that may make sandboxes in the workspace. */
|
|
14
|
+
key: "COMPUTER_RENDER_API_KEY",
|
|
15
|
+
/** ownerId, required: the workspace the run's sandboxes are made in (tea-… or usr-…). */
|
|
16
|
+
workspace: "COMPUTER_RENDER_WORKSPACE_ID",
|
|
17
|
+
/** The build the run's computers start from; default the box build prepareImage() finds or imports. */
|
|
18
|
+
image: "COMPUTER_RENDER_IMAGE",
|
|
19
|
+
};
|
|
20
|
+
export const ENV = RENDER_ENV;
|
|
21
|
+
/** The provider's options this module reads from env; throws in words without the key or the workspace, never echoing one. */
|
|
22
|
+
export function settingsFromEnv(env = process.env) {
|
|
23
|
+
const apiKey = env[RENDER_ENV.key];
|
|
24
|
+
const ownerId = env[RENDER_ENV.workspace];
|
|
25
|
+
if (!apiKey || !ownerId)
|
|
26
|
+
throw new Error(`the Render conformance module needs ${RENDER_ENV.key} and ${RENDER_ENV.workspace}: it takes a key from that name only, never RENDER_API_KEY`);
|
|
27
|
+
return { apiKey, ownerId };
|
|
28
|
+
}
|
|
29
|
+
/** The provider the run makes computers with, dialing the server options.dial names. */
|
|
30
|
+
export function createProvider({ env = process.env, dial, daemonPath, fetch, onNote } = {}) {
|
|
31
|
+
return create({
|
|
32
|
+
...settingsFromEnv(env),
|
|
33
|
+
...(dial ? { dial } : {}),
|
|
34
|
+
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
35
|
+
...(fetch ? { fetch } : {}),
|
|
36
|
+
...(onNote ? { onNote } : {}),
|
|
37
|
+
maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** The run's image: COMPUTER_RENDER_IMAGE's build, else the box build the workspace has or imports (prepareImage). */
|
|
41
|
+
export async function conformanceImage(options = {}, { signal } = {}) {
|
|
42
|
+
const named = (options.env ?? process.env)[RENDER_ENV.image];
|
|
43
|
+
if (named)
|
|
44
|
+
return named;
|
|
45
|
+
return preparedImage(createProvider(options), signal);
|
|
46
|
+
}
|
|
47
|
+
/** The server the run's machines dial, for provider.dial-token, as the CLI asks for it: refused in words (dial-only.ts). */
|
|
48
|
+
export const dialKit = dialOnlyFromServer(RENDER);
|
|
49
|
+
export function createHost({ env = process.env, fetch } = {}) {
|
|
50
|
+
return create({ ...settingsFromEnv(env), ...(fetch ? { fetch } : {}) }).host;
|
|
51
|
+
}
|
|
52
|
+
/** Where the sweep lists, in words: the workspace the settings name. */
|
|
53
|
+
export function sweepScope({ env = process.env } = {}) {
|
|
54
|
+
return `the Render workspace ${settingsFromEnv(env).ownerId}`;
|
|
55
|
+
}
|