@parcha/agentrun-computer 0.1.0-beta.61 → 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 +44 -13
- package/dist/browser.d.ts +26 -9
- package/dist/browser.js +113 -12
- package/dist/browserbase.js +16 -25
- 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/hosted/provider.js +4 -1
- 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 +20 -14
- 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
|
@@ -1330,10 +1330,16 @@ runs on the VM runtime, or on gVisor for a GPU computer (below). Its unit tests
|
|
|
1330
1330
|
them, its own at their longest, and refuses in words with no call where the packed tags pass either bound; create
|
|
1331
1331
|
refuses the same words first. A sandbox made before the tags were packed carries its labels as tags, and reads as
|
|
1332
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
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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.
|
|
1337
1343
|
- **release** `delete` is `terminate()`, and the adapter waits until get answers none (`poll()` reads it finished).
|
|
1338
1344
|
`stop` is refused as `unsupported`: terminate is a sandbox's only end.
|
|
1339
1345
|
- **GPU.** `capabilities().gpu` declares Modal's GPU types by its own names (guide/gpu): `T4`, `L4`, `A10`, `L40S`,
|
|
@@ -2480,7 +2486,9 @@ both find nothing make two computers, so after Orgo's answer, and again once its
|
|
|
2480
2486
|
workspace once more: where an older computer of the request is there (by `created_at`, then id), it deletes its own
|
|
2481
2487
|
and answers the older, and the oldest keeps its own. A caller's signal that aborts one of those reads deletes the
|
|
2482
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
|
|
2483
|
-
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
|
|
2484
2492
|
computer.
|
|
2485
2493
|
|
|
2486
2494
|
- **What each offers.** The protocol groups, by Orgo's calls:
|
|
@@ -2652,14 +2660,37 @@ vendor made with no usable CDP URL) is bounded by the
|
|
|
2652
2660
|
provider's `cleanupMs` option (default `RECOVER_MS`, 30 s), never by the caller's signal: one that does not finish in
|
|
2653
2661
|
time fails the create in words that say the browser may still be running, and a retry is answered as above, never
|
|
2654
2662
|
stuck behind it. Another create's browser of the same request, even one another process answered, carries another attempt
|
|
2655
|
-
label and is left running. A lost create's own browser is left
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
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.
|
|
2663
2694
|
|
|
2664
2695
|
The conformance CLI runs the browser case set for a provider of kind browser: the health cases, then `browser.*`
|
|
2665
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,15 +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
|
+
};
|
|
99
103
|
/**
|
|
100
104
|
* Whether a lost create's browser (`mine`) is left to another create of its request rather than released: it still runs,
|
|
101
105
|
* no older browser of the request runs (so every converge keeps it), and the request's browsers, ended ones included,
|
|
102
|
-
* hold a newer one, which only another create made: that create's converge
|
|
103
|
-
* the request's only one releases it.
|
|
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.
|
|
104
108
|
*/
|
|
105
|
-
export declare function leftToConverge(mine: string, made: ReadonlyArray<
|
|
106
|
-
|
|
107
|
-
|
|
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";
|
|
108
118
|
/**
|
|
109
119
|
* Whether a create that threw may still have made a browser: anything but the vendor's own 4xx answer (a refusal, which
|
|
110
120
|
* makes nothing). A request not answered, aborted, cut short, or answered 5xx or with a body that is no browser may
|
|
@@ -118,11 +128,18 @@ export declare function createUncertain(error: unknown): boolean;
|
|
|
118
128
|
export declare const RECOVER_MS = 30000;
|
|
119
129
|
/**
|
|
120
130
|
* After a create whose outcome is unknown: the browsers carrying its create label, found and released under a signal
|
|
121
|
-
* of the recovery's own, `ms` in all (the caller's may be what ended the create),
|
|
122
|
-
*
|
|
123
|
-
*
|
|
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.
|
|
124
141
|
*/
|
|
125
|
-
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,
|
|
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>;
|
|
126
143
|
/**
|
|
127
144
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
|
128
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
|
@@ -108,8 +108,8 @@ export function convergedBrowser(listed, mine) {
|
|
|
108
108
|
/**
|
|
109
109
|
* Whether a lost create's browser (`mine`) is left to another create of its request rather than released: it still runs,
|
|
110
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
|
|
112
|
-
* the request's only one releases it.
|
|
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
113
|
*/
|
|
114
114
|
export function leftToConverge(mine, made) {
|
|
115
115
|
const own = made.find((one) => one.id === mine);
|
|
@@ -119,6 +119,26 @@ export function leftToConverge(mine, made) {
|
|
|
119
119
|
return false;
|
|
120
120
|
return made.some((one) => one.id !== mine && oldestBrowserFirst(own, one) < 0);
|
|
121
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
|
+
}
|
|
122
142
|
/**
|
|
123
143
|
* Whether a create that threw may still have made a browser: anything but the vendor's own 4xx answer (a refusal, which
|
|
124
144
|
* makes nothing). A request not answered, aborted, cut short, or answered 5xx or with a body that is no browser may
|
|
@@ -137,16 +157,25 @@ const RECOVER_TRIES = 3;
|
|
|
137
157
|
const RECOVER_GAP_MS = 2_000;
|
|
138
158
|
/**
|
|
139
159
|
* After a create whose outcome is unknown: the browsers carrying its create label, found and released under a signal
|
|
140
|
-
* of the recovery's own, `ms` in all (the caller's may be what ended the create),
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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.
|
|
143
170
|
*/
|
|
144
|
-
export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS,
|
|
171
|
+
export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS, made) {
|
|
145
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));
|
|
146
175
|
let found = ok([]);
|
|
147
176
|
for (let tries = 0; tries < RECOVER_TRIES; tries++) {
|
|
148
|
-
if (tries > 0)
|
|
149
|
-
|
|
177
|
+
if (tries > 0 && !(await waitWithin(sleep, settleBy, signal)))
|
|
178
|
+
break;
|
|
150
179
|
found = await find(signal);
|
|
151
180
|
if (!found.ok || found.value.length > 0 || signal.aborted)
|
|
152
181
|
break;
|
|
@@ -157,13 +186,31 @@ export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS,
|
|
|
157
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`;
|
|
158
187
|
const words = [];
|
|
159
188
|
for (const id of found.value) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
}
|
|
163
209
|
}
|
|
164
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` : "";
|
|
165
212
|
if (released.ok)
|
|
166
|
-
words.push(`the ${what} it made (${id}) was released`);
|
|
213
|
+
words.push(`the ${what} it made (${id}) was released${why}`);
|
|
167
214
|
else if (signal.aborted)
|
|
168
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`);
|
|
169
216
|
else
|
|
@@ -171,6 +218,60 @@ export async function recoverCreate(what, find, release, sleep, ms = RECOVER_MS,
|
|
|
171
218
|
}
|
|
172
219
|
return words.join("; ");
|
|
173
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
|
+
}
|
|
174
275
|
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "gpu", "browser"]);
|
|
175
276
|
/**
|
|
176
277
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
package/dist/browserbase.js
CHANGED
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
import { readFileSync } from "node:fs";
|
|
22
22
|
import { BROWSERBASE } from "./descriptors/browserbase.js";
|
|
23
23
|
import { BROWSER_IMAGE } from "./descriptors/shared.js";
|
|
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,
|
|
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";
|
|
@@ -40,7 +40,7 @@ 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
42
|
const LIVE = new Set(["RUNNING", "PENDING"]);
|
|
43
|
-
/** Every status a session reads as, ended ones included: a request's whole record (#
|
|
43
|
+
/** Every status a session reads as, ended ones included: a request's whole record (#requestBrowsers). */
|
|
44
44
|
const EVER = new Set([...LIVE, "COMPLETED", "ERROR", "TIMED_OUT"]);
|
|
45
45
|
/**
|
|
46
46
|
* The order #sessions asks for the statuses, a session's own: it is PENDING, then RUNNING, then ended, and never goes
|
|
@@ -181,23 +181,12 @@ export function throughGateway(connectUrl, connectBase) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
|
-
* The gateway that fronts the sessions' sockets (BROWSERBASE_CONNECT_BASE_URL), held to
|
|
185
|
-
*
|
|
186
|
-
*
|
|
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.
|
|
187
187
|
*/
|
|
188
188
|
function connectBaseOf(url) {
|
|
189
|
-
|
|
190
|
-
return undefined;
|
|
191
|
-
let parsed;
|
|
192
|
-
try {
|
|
193
|
-
parsed = new URL(url);
|
|
194
|
-
}
|
|
195
|
-
catch {
|
|
196
|
-
throw new Error("BROWSERBASE_CONNECT_BASE_URL is not a URL");
|
|
197
|
-
}
|
|
198
|
-
if (parsed.protocol !== "wss:" && parsed.protocol !== "https:")
|
|
199
|
-
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}`);
|
|
200
|
-
return url;
|
|
189
|
+
return url === undefined ? undefined : keyBase(url, "BROWSERBASE_CONNECT_BASE_URL", ["wss:", "https:"]);
|
|
201
190
|
}
|
|
202
191
|
const refOf = (s) => ({ id: s.id, name: s.id });
|
|
203
192
|
const deadlineOf = (s) => {
|
|
@@ -540,13 +529,13 @@ export class BrowserbaseProvider {
|
|
|
540
529
|
const found = await this.#sessions(labels, signal);
|
|
541
530
|
return found.ok ? ok(found.value.map((s) => s.id)) : found;
|
|
542
531
|
};
|
|
543
|
-
const
|
|
544
|
-
return recoverCreate("session", find, (id, signal) => this.release({ id, name: id }, "delete", { signal }), this.#sleep, this.#cleanupMs,
|
|
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);
|
|
545
534
|
}
|
|
546
|
-
/**
|
|
547
|
-
async #
|
|
535
|
+
/** The request's sessions, ended ones included, for a lost create's recovery (recoverCreate, leftToConverge). */
|
|
536
|
+
async #requestBrowsers(request, signal) {
|
|
548
537
|
const made = await this.#sessions({ [CREATE_LABEL]: request }, signal, EVER);
|
|
549
|
-
return made.ok
|
|
538
|
+
return made.ok ? ok(made.value.map((s) => ({ ...heldOf(s), live: LIVE.has(s.status) }))) : made;
|
|
550
539
|
}
|
|
551
540
|
/**
|
|
552
541
|
* Settings' test: one read of the project's running sessions (GET /v1/sessions?status=RUNNING), which makes nothing.
|
|
@@ -618,7 +607,8 @@ export class BrowserbaseProvider {
|
|
|
618
607
|
* The running and pending sessions with all of these labels. Browserbase is asked by status and by the first label a
|
|
619
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.
|
|
620
609
|
* Both statuses must answer: a release trusts this list. `statuses` widens it, to the ended ones too (EVER). The
|
|
621
|
-
* statuses are asked in a session's own order (LIFECYCLE), so every session there when the read starts is found
|
|
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.
|
|
622
612
|
*/
|
|
623
613
|
async #sessions(labels, signal, statuses = LIVE) {
|
|
624
614
|
const problem = browserbaseLabelsProblem(labels);
|
|
@@ -636,7 +626,8 @@ export class BrowserbaseProvider {
|
|
|
636
626
|
continue;
|
|
637
627
|
const pages = await Promise.all(asked.map((status) => this.#api.list({ status, ...(q === undefined ? {} : { q }) }, signal)));
|
|
638
628
|
for (const s of pages.flat()) {
|
|
639
|
-
|
|
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))
|
|
640
631
|
found.set(s.id, s);
|
|
641
632
|
}
|
|
642
633
|
}
|
|
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
|
+
}
|
|
@@ -13,6 +13,7 @@ import { MODAL } from "./modal.js";
|
|
|
13
13
|
import { MORPH } from "./morph.js";
|
|
14
14
|
import { ORGO } from "./orgo.js";
|
|
15
15
|
import { PHONE_HARNESS } from "./phone-harness.js";
|
|
16
|
+
import { RENDER } from "./render.js";
|
|
16
17
|
import { SMOLCLOUD } from "./smolcloud.js";
|
|
17
18
|
export declare const DESCRIPTORS: readonly [{
|
|
18
19
|
readonly id: "docker";
|
|
@@ -288,6 +289,25 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
288
289
|
}];
|
|
289
290
|
readonly prepareImage: true;
|
|
290
291
|
readonly load: () => Promise<typeof import("../fly.js")>;
|
|
292
|
+
}, {
|
|
293
|
+
readonly id: "render";
|
|
294
|
+
readonly label: "Render";
|
|
295
|
+
readonly keys: readonly [{
|
|
296
|
+
readonly name: "RENDER_API_KEY";
|
|
297
|
+
readonly option: "apiKey";
|
|
298
|
+
readonly required: true;
|
|
299
|
+
}, {
|
|
300
|
+
readonly name: "RENDER_WORKSPACE_ID";
|
|
301
|
+
readonly option: "ownerId";
|
|
302
|
+
readonly required: true;
|
|
303
|
+
}];
|
|
304
|
+
readonly metered: true;
|
|
305
|
+
readonly connect: "dial";
|
|
306
|
+
readonly mounts: readonly [];
|
|
307
|
+
readonly network: readonly ["none", "open", "allow"];
|
|
308
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
|
|
309
|
+
readonly prepareImage: true;
|
|
310
|
+
readonly load: () => Promise<typeof import("../render.js")>;
|
|
291
311
|
}, {
|
|
292
312
|
readonly id: "orgo";
|
|
293
313
|
readonly label: "Orgo";
|
|
@@ -529,7 +549,7 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
529
549
|
readonly prepareImage: true;
|
|
530
550
|
readonly load: () => Promise<typeof import("../groundbox.js")>;
|
|
531
551
|
}];
|
|
532
|
-
export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
|
|
552
|
+
export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, RENDER, SMOLCLOUD };
|
|
533
553
|
export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
|
|
534
554
|
export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
|
|
535
555
|
export { GROUNDBOX_OWN_IMAGE } from "./groundbox.js";
|
|
@@ -15,9 +15,10 @@ import { MODAL } from "./modal.js";
|
|
|
15
15
|
import { MORPH } from "./morph.js";
|
|
16
16
|
import { ORGO } from "./orgo.js";
|
|
17
17
|
import { PHONE_HARNESS } from "./phone-harness.js";
|
|
18
|
+
import { RENDER } from "./render.js";
|
|
18
19
|
import { SMOLCLOUD } from "./smolcloud.js";
|
|
19
|
-
export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD, SMOLCLOUD, GROUNDBOX];
|
|
20
|
-
export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
|
|
20
|
+
export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, RENDER, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD, SMOLCLOUD, GROUNDBOX];
|
|
21
|
+
export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, RENDER, SMOLCLOUD };
|
|
21
22
|
export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
|
|
22
23
|
export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
|
|
23
24
|
export { GROUNDBOX_OWN_IMAGE } from "./groundbox.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const RENDER: {
|
|
2
|
+
readonly id: "render";
|
|
3
|
+
readonly label: "Render";
|
|
4
|
+
readonly keys: readonly [{
|
|
5
|
+
readonly name: "RENDER_API_KEY";
|
|
6
|
+
readonly option: "apiKey";
|
|
7
|
+
readonly required: true;
|
|
8
|
+
}, {
|
|
9
|
+
readonly name: "RENDER_WORKSPACE_ID";
|
|
10
|
+
readonly option: "ownerId";
|
|
11
|
+
readonly required: true;
|
|
12
|
+
}];
|
|
13
|
+
readonly metered: true;
|
|
14
|
+
readonly connect: "dial";
|
|
15
|
+
readonly mounts: readonly [];
|
|
16
|
+
readonly network: readonly ["none", "open", "allow"];
|
|
17
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
|
|
18
|
+
readonly prepareImage: true;
|
|
19
|
+
readonly load: () => Promise<typeof import("../render.js")>;
|
|
20
|
+
};
|