@parcha/agentrun-computer 0.1.0-beta.34 → 0.1.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -26
- package/dist/browser.d.ts +12 -13
- package/dist/browser.js +16 -14
- package/dist/browserbase.d.ts +3 -5
- package/dist/browserbase.js +16 -13
- package/dist/chrome.js +1 -1
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/provider.js +78 -3
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
- package/dist/conformance/{local.js → local-chrome.js} +11 -11
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +3 -2
- package/dist/conformance/runner.js +25 -7
- package/dist/conformance/types.d.ts +21 -8
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +3 -34
- package/dist/daytona.js +34 -61
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -6
- package/dist/docker.js +46 -42
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +16 -22
- package/dist/index.d.ts +8 -11
- package/dist/index.js +13 -11
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -5
- package/dist/kernel.js +19 -16
- package/dist/kinds.d.ts +54 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +12 -0
- package/dist/labels.js +39 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
- package/dist/{local.js → local-chrome.js} +19 -16
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +3 -22
- package/dist/modal.js +15 -31
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -15
- package/dist/orgo.js +46 -107
- package/dist/phone-harness.d.ts +4 -10
- package/dist/phone-harness.js +45 -46
- package/dist/provider.d.ts +91 -10
- package/dist/provider.js +42 -0
- package/dist/providers.d.ts +23 -24
- package/dist/providers.js +14 -17
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
package/dist/phone-harness.js
CHANGED
|
@@ -14,23 +14,20 @@ import { readFileSync } from "node:fs";
|
|
|
14
14
|
import { createConnection } from "node:net";
|
|
15
15
|
import { crc32, deflateSync } from "node:zlib";
|
|
16
16
|
import { checkActions } from "./actions.js";
|
|
17
|
+
import { PHONE_GROUPS, PHONE_HARNESS } from "./descriptors/phone-harness.js";
|
|
17
18
|
import { MAX_CHUNK_BYTES, MAX_UI_NODES, PROTOCOL_VERSION, } from "./protocol.js";
|
|
18
|
-
import { checkGpu,
|
|
19
|
-
import {
|
|
19
|
+
import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
|
|
20
|
+
import { failFor, ok, vendorFail } from "./result.js";
|
|
20
21
|
import { daemonWatch, redactWords } from "./screen-watch.js";
|
|
21
22
|
import { listTested } from "./test-connection.js";
|
|
23
|
+
/** This module's failures: one with code vendor names the phone harness. */
|
|
24
|
+
const fail = failFor("phone-harness");
|
|
22
25
|
/** The phone harness's API. */
|
|
23
26
|
export const PHONE_HARNESS_URL = "https://api.phone-harness.com";
|
|
24
|
-
/** What a cloud Android offers through this provider, as its capabilities and hello declare them. */
|
|
25
|
-
export const PHONE_GROUPS = ["screen", "input.touch", "input.keys", "apps", "apps.ui_tree"];
|
|
26
27
|
/** A phone mounts no folder. */
|
|
27
|
-
export const MOUNT =
|
|
28
|
-
/** The
|
|
29
|
-
export const
|
|
30
|
-
/** The one configuration it offers, as its capabilities() declare it: the kind registry's entry holds the same. */
|
|
31
|
-
export const CAPABILITIES = [{ kind: "android", groups: [...PHONE_GROUPS] }];
|
|
32
|
-
/** The image a phone is read back by: a cloud Android has none to choose, so a setting that names none takes this. */
|
|
33
|
-
export const PHONE_IMAGE = "android";
|
|
28
|
+
export const MOUNT = PHONE_HARNESS.mounts;
|
|
29
|
+
/** The one configuration it offers, as its capabilities() declare it: its descriptor's. */
|
|
30
|
+
export const CAPABILITIES = PHONE_HARNESS.capabilities;
|
|
34
31
|
/** The longest lifetime by default: a rented phone bills by the minute. */
|
|
35
32
|
export const DEFAULT_MAX_LIFETIME_MS = 30 * 60_000;
|
|
36
33
|
/** How long create waits for a phone to be ready by default: the service's own CLI waits 240 s. */
|
|
@@ -81,7 +78,7 @@ async function ledgerSafe(fn) {
|
|
|
81
78
|
}
|
|
82
79
|
catch (error) {
|
|
83
80
|
if (error instanceof LedgerFailure)
|
|
84
|
-
return
|
|
81
|
+
return vendorFail("phone-harness", error.message);
|
|
85
82
|
throw error;
|
|
86
83
|
}
|
|
87
84
|
}
|
|
@@ -113,7 +110,7 @@ export function adbCli(path = "adb", { port = ADB_SERVER_PORT, env } = {}) {
|
|
|
113
110
|
if (error && signal?.aborted)
|
|
114
111
|
return resolve(fail("aborted", "adb was aborted"));
|
|
115
112
|
if (error && typeof error.code !== "number")
|
|
116
|
-
return resolve(
|
|
113
|
+
return resolve(vendorFail("phone-harness", `adb could not run: ${error.message.split("\n")[0]}`));
|
|
117
114
|
resolve(ok({ exitCode: typeof code === "number" ? code : error ? 1 : 0, stdout: Buffer.from(stdout), stderr: Buffer.from(stderr).toString("utf8") }));
|
|
118
115
|
});
|
|
119
116
|
// stdin always ends, so no adb waits on it; it carries the input when there is one.
|
|
@@ -127,7 +124,7 @@ export function adbCli(path = "adb", { port = ADB_SERVER_PORT, env } = {}) {
|
|
|
127
124
|
const start = await started;
|
|
128
125
|
if (!start.ok || start.value.exitCode !== 0) {
|
|
129
126
|
started = undefined;
|
|
130
|
-
return start.ok ?
|
|
127
|
+
return start.ok ? vendorFail("phone-harness", `adb start-server failed: ${start.value.stderr.trim().split("\n")[0] || `exit code ${start.value.exitCode}`}`) : start;
|
|
131
128
|
}
|
|
132
129
|
const frame = (request) => `${Buffer.byteLength(request).toString(16).padStart(4, "0")}${request}`;
|
|
133
130
|
return new Promise((resolve) => {
|
|
@@ -157,10 +154,10 @@ export function adbCli(path = "adb", { port = ADB_SERVER_PORT, env } = {}) {
|
|
|
157
154
|
bound = true;
|
|
158
155
|
socket.write(frame(service));
|
|
159
156
|
});
|
|
160
|
-
socket.on("error", (error) => done(
|
|
157
|
+
socket.on("error", (error) => done(vendorFail("phone-harness", `the adb server on 127.0.0.1:${port} could not be reached for ${what}: ${error.message}`)));
|
|
161
158
|
socket.on("close", () => {
|
|
162
159
|
if (!bound)
|
|
163
|
-
return done(
|
|
160
|
+
return done(vendorFail("phone-harness", `the adb server closed host:transport-id:${transport} before it answered`));
|
|
164
161
|
// A phone's service answers OKAY and then its output, with no length: the output is what follows.
|
|
165
162
|
if (transport !== undefined && buffer.subarray(0, 4).toString("latin1") === "OKAY")
|
|
166
163
|
return done(ok(buffer.subarray(4).toString("utf8")));
|
|
@@ -187,8 +184,8 @@ export function adbAnswer(raw, what) {
|
|
|
187
184
|
if (status === "OKAY")
|
|
188
185
|
return ok(message);
|
|
189
186
|
if (status === "FAIL")
|
|
190
|
-
return
|
|
191
|
-
return
|
|
187
|
+
return vendorFail("phone-harness", `the adb server refused ${what}: ${redactWords(message.trim())}`);
|
|
188
|
+
return vendorFail("phone-harness", `the adb server answered ${what} with ${JSON.stringify(raw.subarray(0, 40).toString("latin1"))}, not OKAY or FAIL`);
|
|
192
189
|
}
|
|
193
190
|
/** The phone-harness provider from its options alone; throws in words when one is missing or wrong. */
|
|
194
191
|
export async function create(options) {
|
|
@@ -261,7 +258,7 @@ export class PhoneHarnessProvider {
|
|
|
261
258
|
os: "android",
|
|
262
259
|
daemon: "none",
|
|
263
260
|
lifetime: "vendor",
|
|
264
|
-
network: [...
|
|
261
|
+
network: [...PHONE_HARNESS.network],
|
|
265
262
|
isolation: "vm",
|
|
266
263
|
groups: [...PHONE_GROUPS],
|
|
267
264
|
maxLifetimeMs: this.#maxLifetimeMs,
|
|
@@ -269,7 +266,7 @@ export class PhoneHarnessProvider {
|
|
|
269
266
|
};
|
|
270
267
|
}
|
|
271
268
|
check(spec) {
|
|
272
|
-
const refusals =
|
|
269
|
+
const refusals = checkTenure({ lifetimeMs: spec?.lifetimeMs, owner: spec?.owner }, this.capabilities(), "phone harness");
|
|
273
270
|
if (typeof spec?.image !== "string" || spec.image === "")
|
|
274
271
|
refusals.push({ field: "image", message: "image is required: a name the phone is read back by (a cloud Android has no image to choose)" });
|
|
275
272
|
if (spec?.network !== "open")
|
|
@@ -351,7 +348,7 @@ export class PhoneHarnessProvider {
|
|
|
351
348
|
return fail("limit", `${where}: ${said} (session_limit)`);
|
|
352
349
|
if (response.status === 404)
|
|
353
350
|
return fail("not_found", `${where}: ${said} (404)`);
|
|
354
|
-
const failed =
|
|
351
|
+
const failed = vendorFail("phone-harness", `${where}: ${said} (${response.status}${answer.code ? `, ${answer.code}` : ""})`);
|
|
355
352
|
// A 5xx is no refusal: a gateway may answer it for a request the service went on to act on.
|
|
356
353
|
return response.status >= 500 ? { ...failed, uncertain: true } : failed;
|
|
357
354
|
}
|
|
@@ -418,10 +415,10 @@ export class PhoneHarnessProvider {
|
|
|
418
415
|
return fail("aborted", "create was aborted before the phone harness was asked");
|
|
419
416
|
const from = this.#now();
|
|
420
417
|
const requestKey = randomBytes(16).toString("hex");
|
|
421
|
-
const body = { platform: "android", kind: "emulator", timeout_seconds: Math.ceil(spec
|
|
418
|
+
const body = { platform: "android", kind: "emulator", timeout_seconds: Math.ceil(runLifetimeMs(spec) / 1000) };
|
|
422
419
|
// The key goes into the ledger before the POST: whatever answers are lost, list() can find the phone by it.
|
|
423
420
|
const pending = pendingId(requestKey);
|
|
424
|
-
await this.#ledger.put({ id: pending, labels: { ...(spec.labels ?? {}) }, image: spec.image, deadline: new Date(from + spec
|
|
421
|
+
await this.#ledger.put({ id: pending, labels: { ...(spec.labels ?? {}) }, image: spec.image, deadline: new Date(from + runLifetimeMs(spec)).toISOString(), request: requestKey });
|
|
425
422
|
const posted = await this.#api("POST", "/sessions", { body, headers: { "Idempotency-Key": requestKey }, ...(signal ? { signal } : {}) });
|
|
426
423
|
const cancelled = !posted.ok && posted.error.code === "aborted";
|
|
427
424
|
let first = posted.ok ? sessionOf(posted.value.json, "POST /sessions") : undefined;
|
|
@@ -435,10 +432,10 @@ export class PhoneHarnessProvider {
|
|
|
435
432
|
const kept = "the ledger keeps the request's key, so list() finds the phone if it was made";
|
|
436
433
|
const recovered = await this.#api("GET", `/sessions/requests/${requestKey}`);
|
|
437
434
|
if (!recovered.ok)
|
|
438
|
-
return fail(cancelled ? "aborted" : "
|
|
435
|
+
return fail(cancelled ? "aborted" : "vendor", `${why}; and the service has no session for the request: ${recovered.error.message}; ${kept}`);
|
|
439
436
|
first = sessionOf(recovered.value.json, `GET /sessions/requests/${requestKey}`);
|
|
440
437
|
if (!first.ok)
|
|
441
|
-
return fail(cancelled ? "aborted" : "
|
|
438
|
+
return fail(cancelled ? "aborted" : "vendor", `${why}; and its recovery answered no session: ${first.error.message}; ${kept}`);
|
|
442
439
|
}
|
|
443
440
|
else if (!posted.ok) {
|
|
444
441
|
// The phone harness refused the request: nothing was made, and the key is forgotten.
|
|
@@ -446,7 +443,7 @@ export class PhoneHarnessProvider {
|
|
|
446
443
|
return posted;
|
|
447
444
|
}
|
|
448
445
|
if (first === undefined || !first.ok)
|
|
449
|
-
return
|
|
446
|
+
return vendorFail("phone-harness", "POST /sessions answered no session");
|
|
450
447
|
const id = first.value.id;
|
|
451
448
|
/** A ledger write about the phone, or the phone ended in words: a phone its ledger cannot record would bill unseen. */
|
|
452
449
|
const record = async (write) => {
|
|
@@ -458,11 +455,11 @@ export class PhoneHarnessProvider {
|
|
|
458
455
|
// Ended at once, by the API alone: the ledger has just failed.
|
|
459
456
|
const ended = await this.#api("DELETE", `/sessions/${encodeURIComponent(id)}`);
|
|
460
457
|
const after = ended.ok || ended.error.code === "not_found" ? "the phone was ended" : `the phone ${id} could not be ended (${ended.error.message})`;
|
|
461
|
-
return
|
|
458
|
+
return vendorFail("phone-harness", `${error instanceof Error ? error.message : String(error)}; ${after}`);
|
|
462
459
|
}
|
|
463
460
|
};
|
|
464
461
|
const named = await record(async () => {
|
|
465
|
-
await this.#ledger.put({ id, labels: { ...(spec.labels ?? {}) }, image: spec.image, deadline: this.#deadlineOf(first.value, from + spec
|
|
462
|
+
await this.#ledger.put({ id, labels: { ...(spec.labels ?? {}) }, image: spec.image, deadline: this.#deadlineOf(first.value, from + runLifetimeMs(spec)) });
|
|
466
463
|
await this.#ledger.remove(pending);
|
|
467
464
|
});
|
|
468
465
|
if (!named.ok)
|
|
@@ -491,23 +488,23 @@ export class PhoneHarnessProvider {
|
|
|
491
488
|
return ended("timeout", `the phone ${id} was not ready within ${this.#readyMs / 1000} s: ${read.error.message}`);
|
|
492
489
|
}
|
|
493
490
|
if (!read.ok)
|
|
494
|
-
return ended(read.error.code === "gone" ? "
|
|
491
|
+
return ended(read.error.code === "gone" ? "vendor" : read.error.code, `the phone ${id} did not start: ${read.error.message}`);
|
|
495
492
|
session = read.value;
|
|
496
493
|
if (session.state === "ready")
|
|
497
494
|
break;
|
|
498
495
|
if (session.state !== "provisioning")
|
|
499
|
-
return ended("
|
|
496
|
+
return ended("vendor", `the phone ${id} did not start: ${this.#clean(session.error ?? session.state)}`);
|
|
500
497
|
if (this.#now() - from >= this.#readyMs)
|
|
501
498
|
return ended("timeout", `the phone ${id} was not ready within ${this.#readyMs / 1000} s`);
|
|
502
499
|
await this.#sleep(this.#pollMs);
|
|
503
500
|
}
|
|
504
|
-
const deadline = this.#deadlineOf(session, from + spec
|
|
501
|
+
const deadline = this.#deadlineOf(session, from + runLifetimeMs(spec));
|
|
505
502
|
const kept = await record(() => this.#ledger.put({ id, labels: { ...(spec.labels ?? {}) }, image: spec.image, deadline }));
|
|
506
503
|
if (!kept.ok)
|
|
507
504
|
return kept;
|
|
508
505
|
const took = this.#now() - from;
|
|
509
506
|
if (this.#now() >= Date.parse(deadline)) {
|
|
510
|
-
return ended("timeout", `the phone ${id}'s lifetime of ${spec
|
|
507
|
+
return ended("timeout", `the phone ${id}'s lifetime of ${runLifetimeMs(spec) / 1000} s ended before it was ready (it took ${Math.round(took / 100) / 10} s)`);
|
|
511
508
|
}
|
|
512
509
|
return ok({ id, name: id });
|
|
513
510
|
}
|
|
@@ -557,7 +554,7 @@ export class PhoneHarnessProvider {
|
|
|
557
554
|
if (!got.ok)
|
|
558
555
|
return got;
|
|
559
556
|
if (!Array.isArray(got.value.json))
|
|
560
|
-
return
|
|
557
|
+
return vendorFail("phone-harness", `GET /sessions answered ${show(got.value.json).slice(0, 200)}, not a list`);
|
|
561
558
|
const live = new Map();
|
|
562
559
|
for (const one of got.value.json) {
|
|
563
560
|
const session = sessionOf(one, "GET /sessions");
|
|
@@ -635,6 +632,8 @@ export class PhoneHarnessProvider {
|
|
|
635
632
|
async #release(ref, how) {
|
|
636
633
|
if (how === "stop")
|
|
637
634
|
return fail("unsupported", "a cloud phone has no stop: release it with delete, which ends the session");
|
|
635
|
+
if (how !== "delete")
|
|
636
|
+
return fail("unsupported", `a cloud phone is kept for no agent (the phone harness declares no persistence), so release ${JSON.stringify(how)} is refused and the phone is left as it is: release it with delete`);
|
|
638
637
|
const entry = await this.#ledger.get(ref.id);
|
|
639
638
|
if (entry?.released !== undefined) {
|
|
640
639
|
// Released already, and the service may still be ending it: ok. Its own GET says whether it is gone, and then it is
|
|
@@ -677,7 +676,7 @@ export class PhoneHarnessProvider {
|
|
|
677
676
|
return ok(id);
|
|
678
677
|
last = state ?? "not listed";
|
|
679
678
|
}
|
|
680
|
-
return
|
|
679
|
+
return vendorFail("phone-harness", `adb connected to the phone, and the adb server still lists it as ${last}, not a device`);
|
|
681
680
|
}
|
|
682
681
|
async #connect(ref) {
|
|
683
682
|
const entry = await this.#ledger.get(ref.id);
|
|
@@ -701,7 +700,7 @@ export class PhoneHarnessProvider {
|
|
|
701
700
|
// The vendor's shapes (OpenAPI SessionAdb): a DNS name, a port, and a code ph_ and base32 letters. Anything outside
|
|
702
701
|
// these characters is refused rather than passed to adb.
|
|
703
702
|
if (typeof host !== "string" || !/^[A-Za-z0-9.:-]+$/.test(host) || !Number.isSafeInteger(port) || typeof code !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(code)) {
|
|
704
|
-
return
|
|
703
|
+
return vendorFail("phone-harness", `the phone harness gave ${ref.id} no adb link this provider can use (a host, a port and an unlock code)`);
|
|
705
704
|
}
|
|
706
705
|
// The endpoint and the code never reach an argv: the endpoint goes to the adb server over its socket, the unlock as
|
|
707
706
|
// a shell service on a socket the server bound to the phone, and every spawned adb names the phone by its transport id.
|
|
@@ -746,7 +745,7 @@ export class PhoneHarnessProvider {
|
|
|
746
745
|
const said = connected.value.trim();
|
|
747
746
|
// adb's answer names the endpoint, so none of it is passed on: the error is the provider's own words.
|
|
748
747
|
if (!said.includes("connected") || /cannot|failed|unable/i.test(said)) {
|
|
749
|
-
return letGo(
|
|
748
|
+
return letGo(vendorFail("phone-harness", `adb could not reach the phone of ${ref.id}: the adb server could not connect to its adb endpoint`));
|
|
750
749
|
}
|
|
751
750
|
const transport = await this.#transportOf(endpoint);
|
|
752
751
|
if (!transport.ok)
|
|
@@ -760,7 +759,7 @@ export class PhoneHarnessProvider {
|
|
|
760
759
|
return letGo(asked);
|
|
761
760
|
if (!asked.value.includes("ph-ok")) {
|
|
762
761
|
if (!/^locked\b/.test(asked.value.trim()))
|
|
763
|
-
return letGo(
|
|
762
|
+
return letGo(vendorFail("phone-harness", `the phone of ${ref.id} answered neither ph-ok nor locked`));
|
|
764
763
|
// The vendor's unlock is the shell command `unlock <code>`, once per connection (docs, guides/connect-adb): the
|
|
765
764
|
// shell service's own string, sent over the adb server's socket bound to the phone, so no argv holds the code.
|
|
766
765
|
// Probe 1 (2026-11-08) showed it live: "unlocked", and getprop answered after it.
|
|
@@ -774,7 +773,7 @@ export class PhoneHarnessProvider {
|
|
|
774
773
|
if (!probe.value.stdout.toString("utf8").includes("ph-ok")) {
|
|
775
774
|
// The vendor's answer ("wrong code") may echo the code, more than once, or an endpoint: all are taken out.
|
|
776
775
|
const words = redactWords(unlocked.value.trim().split("\n")[0].replaceAll(code, "[code]"));
|
|
777
|
-
return letGo(
|
|
776
|
+
return letGo(vendorFail("phone-harness", /\bunlocked\b/.test(unlocked.value) ? `the phone of ${ref.id} stayed locked after its unlock code` : `the phone of ${ref.id} refused its unlock code: ${words}`));
|
|
778
777
|
}
|
|
779
778
|
}
|
|
780
779
|
const client = new AdbClient(id, adb, release, this.#sleep, this.#now);
|
|
@@ -796,7 +795,7 @@ const carries = (labels, wanted) => Object.entries(wanted ?? {}).every(([key, va
|
|
|
796
795
|
function sessionOf(json, where) {
|
|
797
796
|
const s = json;
|
|
798
797
|
if (typeof s !== "object" || s === null || typeof s.id !== "string" || typeof s.state !== "string")
|
|
799
|
-
return
|
|
798
|
+
return vendorFail("phone-harness", `${where} answered ${show(json).slice(0, 200)}, not a session`);
|
|
800
799
|
return ok(s);
|
|
801
800
|
}
|
|
802
801
|
// --- the client: the protocol over adb ---------------------------------------------------------------------------
|
|
@@ -883,7 +882,7 @@ class AdbClient {
|
|
|
883
882
|
const sizes = [...size.value.matchAll(/(\d+)x(\d+)/g)];
|
|
884
883
|
const last = sizes.at(-1);
|
|
885
884
|
if (!last)
|
|
886
|
-
return
|
|
885
|
+
return vendorFail("phone-harness", `the phone (adb transport ${this.transport}) did not say its screen's size: ${size.value.trim().slice(0, 100)}`);
|
|
887
886
|
this.#size = [Number(last[1]), Number(last[2])];
|
|
888
887
|
const dpi = [...density.value.matchAll(/(\d+)/g)].at(-1);
|
|
889
888
|
this.#scale = dpi ? Number(dpi[1]) / 160 : 1;
|
|
@@ -916,7 +915,7 @@ class AdbClient {
|
|
|
916
915
|
return ran;
|
|
917
916
|
if (ran.value.exitCode !== 0) {
|
|
918
917
|
const why = (ran.value.stderr.trim() || ran.value.stdout.toString("utf8").trim()).split("\n")[0] || `exit code ${ran.value.exitCode}`;
|
|
919
|
-
return
|
|
918
|
+
return vendorFail("phone-harness", `${command.split(" ").slice(0, 2).join(" ")} on the phone failed: ${redactWords(why)}`);
|
|
920
919
|
}
|
|
921
920
|
return ok(ran.value.stdout.toString("utf8"));
|
|
922
921
|
}
|
|
@@ -925,7 +924,7 @@ class AdbClient {
|
|
|
925
924
|
if (!ran.ok)
|
|
926
925
|
return ran;
|
|
927
926
|
if (ran.value.exitCode !== 0)
|
|
928
|
-
return
|
|
927
|
+
return vendorFail("phone-harness", `${command.split(" ")[0]} on the phone failed: ${redactWords(ran.value.stderr.trim().split("\n")[0] || `exit code ${ran.value.exitCode}`)}`);
|
|
929
928
|
return ok(ran.value.stdout);
|
|
930
929
|
}
|
|
931
930
|
async call(method, params, options = {}) {
|
|
@@ -1280,7 +1279,7 @@ class AdbClient {
|
|
|
1280
1279
|
if (!started.ok)
|
|
1281
1280
|
return started;
|
|
1282
1281
|
if (/Error:|Exception/.test(started.value))
|
|
1283
|
-
return
|
|
1282
|
+
return vendorFail("phone-harness", `am start of ${component}: ${redactWords(started.value.trim().split("\n").at(-1) ?? "")}`);
|
|
1284
1283
|
return ok({});
|
|
1285
1284
|
}
|
|
1286
1285
|
async #terminate(id) {
|
|
@@ -1311,14 +1310,14 @@ function pointsOf(action) {
|
|
|
1311
1310
|
/** The frame `adb exec-out screencap` gives: a header (width, height, format, and a color space on newer Androids), then the pixels. */
|
|
1312
1311
|
export function decodeScreencap(raw) {
|
|
1313
1312
|
if (raw.length < 12)
|
|
1314
|
-
return
|
|
1313
|
+
return vendorFail("phone-harness", `screencap gave ${raw.length} bytes, not a frame`);
|
|
1315
1314
|
const width = raw.readUInt32LE(0);
|
|
1316
1315
|
const height = raw.readUInt32LE(4);
|
|
1317
1316
|
const format = raw.readUInt32LE(8);
|
|
1318
1317
|
const pixels = width * height * 4;
|
|
1319
1318
|
const header = raw.length - pixels;
|
|
1320
1319
|
if (!(width > 0 && height > 0 && (header === 12 || header === 16)))
|
|
1321
|
-
return
|
|
1320
|
+
return vendorFail("phone-harness", `screencap gave ${raw.length} bytes for a ${width}x${height} frame`);
|
|
1322
1321
|
const rgba = Buffer.from(raw.subarray(header));
|
|
1323
1322
|
// 1 is RGBA_8888, 2 RGBX_8888 (alpha unset), 5 BGRA_8888.
|
|
1324
1323
|
if (format === 2)
|
|
@@ -1416,7 +1415,7 @@ export function parseUiTree(xml, [width, height]) {
|
|
|
1416
1415
|
stack.push(node);
|
|
1417
1416
|
}
|
|
1418
1417
|
if (top.length === 0)
|
|
1419
|
-
return
|
|
1418
|
+
return vendorFail("phone-harness", "uiautomator's dump held no node");
|
|
1420
1419
|
if (top.length === 1)
|
|
1421
1420
|
return ok({ root: top[0], nodes, truncated });
|
|
1422
1421
|
return ok({ root: { role: "hierarchy", bounds: [0, 0, width, height], enabled: true, children: top }, nodes: nodes + 1, truncated });
|
package/dist/provider.d.ts
CHANGED
|
@@ -5,13 +5,33 @@ import type { ScreenWatch, ScreenWatchHandlers, WatchOptions } from "./screen-wa
|
|
|
5
5
|
export type NetworkSpec = "none" | "open" | {
|
|
6
6
|
allow: string[];
|
|
7
7
|
};
|
|
8
|
-
/** A network's form, as a provider declares the ones it makes (capabilities().network, its
|
|
9
|
-
* NetworkSpec's allowlist. */
|
|
8
|
+
/** A network's form, as a provider declares the ones it makes (capabilities().network, its descriptor's network): "allow"
|
|
9
|
+
* is NetworkSpec's allowlist. */
|
|
10
10
|
export type NetworkForm = "none" | "open" | "allow";
|
|
11
|
+
/** The agent a persistent computer belongs to (spec.owner): it outlives the agent's runs, which take it one at a time. */
|
|
12
|
+
export interface ComputerOwner {
|
|
13
|
+
/** The agent's id: a non-empty string with no NUL byte (ownerProblem). */
|
|
14
|
+
agent: string;
|
|
15
|
+
/** How long the computer may stay detached before the janitor deletes it. Absent: it stays until it is deleted. */
|
|
16
|
+
idleTtlMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The claim a run holds a computer under: the run, and the claim's epoch (labels.ts). */
|
|
19
|
+
export interface ComputerClaim {
|
|
20
|
+
run: string;
|
|
21
|
+
epoch: number;
|
|
22
|
+
}
|
|
11
23
|
export interface ComputerSpec {
|
|
12
24
|
image: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Required for a run's computer: one with no deadline is refused. An agent's computer (owner) has no run deadline and
|
|
27
|
+
* leaves it out (checkTenure).
|
|
28
|
+
*/
|
|
29
|
+
lifetimeMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Makes the computer the agent's, persistent across its runs, on a provider that declares persistence; refused in
|
|
32
|
+
* words by any other. It carries the owner's labels (ownerLabels).
|
|
33
|
+
*/
|
|
34
|
+
owner?: ComputerOwner;
|
|
15
35
|
network: NetworkSpec;
|
|
16
36
|
cpus?: number;
|
|
17
37
|
memoryMb?: number;
|
|
@@ -91,7 +111,7 @@ export interface ComputerCapabilities {
|
|
|
91
111
|
kind: ComputerKind;
|
|
92
112
|
/** Who ends a computer at its deadline: the vendor, or our janitor by label. */
|
|
93
113
|
lifetime: "vendor" | "janitor";
|
|
94
|
-
/** The network forms it makes: its
|
|
114
|
+
/** The network forms it makes: of its descriptor's network (the forms all its configurations make), its own. */
|
|
95
115
|
network: NetworkForm[];
|
|
96
116
|
/** With network "allow": what an allowlist may hold and which ports it opens. */
|
|
97
117
|
allow?: AllowCapability;
|
|
@@ -126,6 +146,16 @@ export interface ComputerCapabilities {
|
|
|
126
146
|
release: Array<"stop" | "delete">;
|
|
127
147
|
/** The kinds of spec.mount this provider takes: bind (a host folder), archil (a folder of an Archil disk). Absent: none. */
|
|
128
148
|
mount?: MountKind[];
|
|
149
|
+
/**
|
|
150
|
+
* Present when the provider keeps computers for agents (spec.owner): release(ref, "detach") stops one with its state
|
|
151
|
+
* kept, and attach with a claim brings it back. keepsState: its files survive a detach. resume: true when it comes
|
|
152
|
+
* back as it was, its processes running; false when it boots again from its kept disk. Absent: spec.owner and detach
|
|
153
|
+
* are refused in words.
|
|
154
|
+
*/
|
|
155
|
+
persistence?: {
|
|
156
|
+
keepsState: true;
|
|
157
|
+
resume: boolean;
|
|
158
|
+
};
|
|
129
159
|
/**
|
|
130
160
|
* The TCP ports the vendor's own agent listens on inside the computer (Daytona's toolbox 2280, E2B's envd 49983), each
|
|
131
161
|
* the provider's own fact: an agent that runs commands as root or with sudo for whoever reaches it. The computer's
|
|
@@ -149,6 +179,22 @@ export declare function kindRefusals({ kind, os, daemon }: Pick<ComputerCapabili
|
|
|
149
179
|
* milliseconds above 0, and at most capabilities().maxLifetimeMs.
|
|
150
180
|
*/
|
|
151
181
|
export declare function checkLifetime(lifetimeMs: unknown, { lifetime, maxLifetimeMs }: Pick<ComputerCapabilities, "lifetime" | "maxLifetimeMs">): Refusal[];
|
|
182
|
+
/**
|
|
183
|
+
* A run's computer's lifetime, in a provider's create once check() passed the spec: its lifetimeMs, which
|
|
184
|
+
* checkLifetime requires of every spec with no owner. A spec without one is a caller's mistake past check(): a throw.
|
|
185
|
+
*/
|
|
186
|
+
export declare function runLifetimeMs(spec: Pick<ComputerSpec, "lifetimeMs">): number;
|
|
187
|
+
/** Why owner is not an agent's ownership, in words, or undefined when it is one. */
|
|
188
|
+
export declare function ownerProblem(owner: unknown): string | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* The lifetime rule every provider's check() shares, with no vendor call. A run's computer (no owner) takes
|
|
191
|
+
* checkLifetime. An agent's computer (owner) needs a provider that declares persistence, an owner that is one
|
|
192
|
+
* (ownerProblem), and no lifetimeMs: it has no run deadline.
|
|
193
|
+
*/
|
|
194
|
+
export declare function checkTenure({ lifetimeMs, owner }: {
|
|
195
|
+
lifetimeMs?: unknown;
|
|
196
|
+
owner?: unknown;
|
|
197
|
+
}, capabilities: Pick<ComputerCapabilities, "lifetime" | "maxLifetimeMs" | "persistence">, provider?: string): Refusal[];
|
|
152
198
|
/**
|
|
153
199
|
* The one GPU rule every provider's check() shares, with no vendor call: no spec.gpu is no refusal; one given is an
|
|
154
200
|
* object of a declared type (capabilities().gpu.types) and a whole count from 1 to capabilities().gpu.max; a provider
|
|
@@ -188,6 +234,8 @@ export interface ReadBackSpec {
|
|
|
188
234
|
kind?: ComputerKind;
|
|
189
235
|
/** What is mounted at /workspace, never a token; absent when nothing is. */
|
|
190
236
|
mount?: MountReadBack;
|
|
237
|
+
/** An agent's computer: its owner, read back; absent for a run's computer. */
|
|
238
|
+
owner?: ComputerOwner;
|
|
191
239
|
/** The GPUs the computer was given, as the vendor reports them (Daytona) or as create recorded them (Modal); absent: none. */
|
|
192
240
|
gpu?: GpuSpec;
|
|
193
241
|
}
|
|
@@ -211,16 +259,34 @@ export interface AttachedComputer extends ComputerRef {
|
|
|
211
259
|
export interface ComputerInfo {
|
|
212
260
|
ref: ComputerRef;
|
|
213
261
|
labels: Record<string, string>;
|
|
214
|
-
/** undefined when the deadline label is missing or unreadable: the janitor deletes such a computer. */
|
|
262
|
+
/** undefined when the deadline label is missing or unreadable: the janitor deletes such a run's computer. An agent's has none. */
|
|
215
263
|
deadline: Date | undefined;
|
|
216
264
|
state: "running" | "stopped";
|
|
217
265
|
network: NetworkPolicy;
|
|
218
266
|
/** What is mounted at /workspace, read back, never a token; absent when nothing is. */
|
|
219
267
|
mount?: MountReadBack;
|
|
268
|
+
/**
|
|
269
|
+
* An agent's computer (spec.owner), as the provider knows it, owner label or not: true. The janitor never deletes one
|
|
270
|
+
* by a deadline. A provider whose listing carries the owner label need not set it.
|
|
271
|
+
*/
|
|
272
|
+
owned?: boolean;
|
|
273
|
+
/** An owned computer's owner, when the listing knows it (its labels, or the provider's own record). */
|
|
274
|
+
owner?: ComputerOwner;
|
|
275
|
+
/** An agent's computer that is detached now: when it was detached, the janitor's idle clock. Absent otherwise. */
|
|
276
|
+
detachedAt?: Date;
|
|
220
277
|
}
|
|
221
278
|
export interface CallContext {
|
|
222
279
|
signal?: AbortSignal;
|
|
223
280
|
}
|
|
281
|
+
/** attach's context: with a claim, an agent's computer is brought back and taken by that run, under that epoch. */
|
|
282
|
+
export interface AttachContext extends CallContext {
|
|
283
|
+
claim?: ComputerClaim;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* How release ends or lets go of a computer. stop: stopped and kept, until deleted. delete: gone. detach: an agent's
|
|
287
|
+
* computer stops with its state kept, still the agent's (a provider that declares persistence; refused otherwise).
|
|
288
|
+
*/
|
|
289
|
+
export type ReleaseHow = "stop" | "delete" | "detach";
|
|
224
290
|
/** A live connection to a computer's daemon. */
|
|
225
291
|
export interface ComputerConnection {
|
|
226
292
|
client: ComputerClient;
|
|
@@ -244,21 +310,27 @@ export interface ComputerProvider {
|
|
|
244
310
|
}): Promise<Result<CreatedComputer>>;
|
|
245
311
|
/**
|
|
246
312
|
* Finds one computer this provider made, by its id or by labels, with the spec read back from it; none or several is
|
|
247
|
-
* an error in words.
|
|
313
|
+
* an error in words. With context.claim (a provider that declares persistence): the agent's computer is brought back
|
|
314
|
+
* (started, when detached) and taken under the claim, so it carries the claim's run and epoch labels. A claim of the
|
|
315
|
+
* same run below the epoch the computer carries is refused as fenced, and a claim on a run's computer (no owner) is
|
|
316
|
+
* refused; neither changes anything.
|
|
248
317
|
*/
|
|
249
318
|
attach(ref: {
|
|
250
319
|
id: string;
|
|
251
320
|
} | {
|
|
252
321
|
labels: Record<string, string>;
|
|
253
|
-
}, context?:
|
|
322
|
+
}, context?: AttachContext): Promise<Result<AttachedComputer>>;
|
|
254
323
|
/** Every computer this provider made that carries all of these labels: the janitor's view. */
|
|
255
324
|
list(labels: Record<string, string>, context?: CallContext): Promise<Result<ComputerInfo[]>>;
|
|
256
325
|
/** Reads the network back; with a policy, sets it, or refuses in words when it cannot. Never wider than asked. */
|
|
257
326
|
network(ref: ComputerRef, policy?: NetworkSpec, context?: CallContext): Promise<Result<NetworkPolicy>>;
|
|
258
327
|
/** Checks hello against this provider's version, kind and groups, and refuses on a mismatch. */
|
|
259
328
|
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
|
260
|
-
/**
|
|
261
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Idempotent: a computer already gone is ok. A "stop" capabilities().release does not declare is refused in words. A
|
|
331
|
+
* "detach" is refused in words, the computer as it was, on a provider with no persistence and on a run's computer.
|
|
332
|
+
*/
|
|
333
|
+
release(ref: ComputerRef, how: ReleaseHow): Promise<Result<void>>;
|
|
262
334
|
/**
|
|
263
335
|
* Sets the deadline to now + ttlMs: never earlier than the current deadline, never past created + maxLifetimeMs. A
|
|
264
336
|
* ttlMs that would move it earlier, or past that cap, is refused in words with the deadline unchanged: an extend
|
|
@@ -302,4 +374,13 @@ export interface ComputerProvider {
|
|
|
302
374
|
testConnection?(context?: CallContext): Promise<Result<{
|
|
303
375
|
detail: string;
|
|
304
376
|
}>>;
|
|
377
|
+
/**
|
|
378
|
+
* The image its computers start from, made ready on its engine before the first create: built from its recipe, or
|
|
379
|
+
* pulled by name, when the engine lacks it; ok with the tag to put in spec.image. `onWait` is told once, before a build
|
|
380
|
+
* or a pull it waits on, never when the image is there. A provider whose descriptor declares prepareImage has it;
|
|
381
|
+
* optional for every other.
|
|
382
|
+
*/
|
|
383
|
+
prepareImage?(context?: CallContext & {
|
|
384
|
+
onWait?: (making: "build" | "pull", tag: string) => void;
|
|
385
|
+
}): Promise<Result<string>>;
|
|
305
386
|
}
|
package/dist/provider.js
CHANGED
|
@@ -35,6 +35,48 @@ export function checkLifetime(lifetimeMs, { lifetime, maxLifetimeMs }) {
|
|
|
35
35
|
}
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A run's computer's lifetime, in a provider's create once check() passed the spec: its lifetimeMs, which
|
|
40
|
+
* checkLifetime requires of every spec with no owner. A spec without one is a caller's mistake past check(): a throw.
|
|
41
|
+
*/
|
|
42
|
+
export function runLifetimeMs(spec) {
|
|
43
|
+
if (spec.lifetimeMs === undefined)
|
|
44
|
+
throw new TypeError("a run's computer needs lifetimeMs: check() refuses a spec with neither lifetimeMs nor owner");
|
|
45
|
+
return spec.lifetimeMs;
|
|
46
|
+
}
|
|
47
|
+
/** Why owner is not an agent's ownership, in words, or undefined when it is one. */
|
|
48
|
+
export function ownerProblem(owner) {
|
|
49
|
+
if (typeof owner !== "object" || owner === null || Array.isArray(owner))
|
|
50
|
+
return "owner is { agent, idleTtlMs? }";
|
|
51
|
+
const { agent, idleTtlMs } = owner;
|
|
52
|
+
if (typeof agent !== "string" || agent === "")
|
|
53
|
+
return "owner.agent must be the agent's id, a non-empty string";
|
|
54
|
+
if (agent.includes("\0"))
|
|
55
|
+
return "owner.agent cannot hold a NUL byte: no provider takes one in a label";
|
|
56
|
+
if (idleTtlMs !== undefined && !(Number.isSafeInteger(idleTtlMs) && idleTtlMs > 0))
|
|
57
|
+
return `owner.idleTtlMs is a whole number of milliseconds above 0, not ${JSON.stringify(idleTtlMs)}`;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The lifetime rule every provider's check() shares, with no vendor call. A run's computer (no owner) takes
|
|
62
|
+
* checkLifetime. An agent's computer (owner) needs a provider that declares persistence, an owner that is one
|
|
63
|
+
* (ownerProblem), and no lifetimeMs: it has no run deadline.
|
|
64
|
+
*/
|
|
65
|
+
export function checkTenure({ lifetimeMs, owner }, capabilities, provider = "this") {
|
|
66
|
+
if (owner === undefined)
|
|
67
|
+
return checkLifetime(lifetimeMs, capabilities);
|
|
68
|
+
if (capabilities.persistence === undefined) {
|
|
69
|
+
return [{ field: "owner", message: `the ${provider} provider keeps no computer for an agent (it declares no persistence), so spec.owner is refused: leave it out for a run's computer` }];
|
|
70
|
+
}
|
|
71
|
+
const refusals = [];
|
|
72
|
+
const problem = ownerProblem(owner);
|
|
73
|
+
if (problem !== undefined)
|
|
74
|
+
refusals.push({ field: "owner", message: problem });
|
|
75
|
+
if (lifetimeMs !== undefined) {
|
|
76
|
+
refusals.push({ field: "lifetimeMs", message: "an agent's computer has no run deadline: leave lifetimeMs out (owner.idleTtlMs bounds how long it stays detached)" });
|
|
77
|
+
}
|
|
78
|
+
return refusals;
|
|
79
|
+
}
|
|
38
80
|
/**
|
|
39
81
|
* The one GPU rule every provider's check() shares, with no vendor call: no spec.gpu is no refusal; one given is an
|
|
40
82
|
* object of a declared type (capabilities().gpu.types) and a whole count from 1 to capabilities().gpu.max; a provider
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { RunFolder } from "./conformance/types.js";
|
|
2
|
+
import type { ProviderDescriptor } from "./descriptor.js";
|
|
3
|
+
import { DESCRIPTORS } from "./descriptors/index.js";
|
|
2
4
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
5
|
import type { MountKind } from "./mount.js";
|
|
4
|
-
import type { ComputerProvider
|
|
6
|
+
import type { ComputerProvider } from "./provider.js";
|
|
5
7
|
/** Where the conformance side reads its settings: process.env, or a record of the same shape. */
|
|
6
8
|
export type ProviderEnv = Readonly<Record<string, string | undefined>>;
|
|
7
9
|
/**
|
|
@@ -29,11 +31,6 @@ export interface ProviderModule {
|
|
|
29
31
|
* provider binds a local folder from the registry alone, without building one.
|
|
30
32
|
*/
|
|
31
33
|
readonly MOUNT: readonly MountKind[];
|
|
32
|
-
/**
|
|
33
|
-
* The network forms its computers make, the same as its provider's capabilities().network: a caller tells which
|
|
34
|
-
* provider takes an allowlist, or runs only on the vendor's own network, from the registry alone.
|
|
35
|
-
*/
|
|
36
|
-
readonly NETWORK: readonly NetworkForm[];
|
|
37
34
|
/**
|
|
38
35
|
* The machine kind and groups of each configuration it offers, as its built providers' capabilities() declare them:
|
|
39
36
|
* the kind registry's entry for it (PROVIDERS in kinds.ts) holds the same, and derives its setting kinds from them.
|
|
@@ -51,24 +48,26 @@ export interface ProviderModule {
|
|
|
51
48
|
*/
|
|
52
49
|
conformance?(): Promise<ConformanceModule>;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export declare function
|
|
51
|
+
/** A provider's id: any descriptor's. The built-in ones are BuiltinProviderId. */
|
|
52
|
+
export type ProviderId = string;
|
|
53
|
+
type Builtin = (typeof DESCRIPTORS)[number];
|
|
54
|
+
/** The id of a provider this package holds. */
|
|
55
|
+
export type BuiltinProviderId = Builtin["id"];
|
|
56
|
+
/** Each built-in id's lazy import of its provider module: its descriptor's load(). */
|
|
57
|
+
export declare const providers: { readonly [D in Builtin as D["id"]]: D["load"]; };
|
|
58
|
+
/** The options a built-in id's create() takes. */
|
|
59
|
+
export type ProviderOptions<Id extends BuiltinProviderId> = Parameters<Awaited<ReturnType<Extract<Builtin, {
|
|
60
|
+
id: Id;
|
|
61
|
+
}>["load"]>>["create"]>[0];
|
|
62
|
+
/** Every built-in id, in the registry's order. */
|
|
63
|
+
export declare const providerIds: readonly BuiltinProviderId[];
|
|
64
|
+
/** Whether id names a provider this package holds. */
|
|
65
|
+
export declare function isProviderId(id: string): id is BuiltinProviderId;
|
|
66
|
+
/** A built-in provider's descriptor, or undefined for an id this package does not hold. */
|
|
67
|
+
export declare function descriptorOf(id: string): ProviderDescriptor | undefined;
|
|
71
68
|
/** The provider file's module for an id; an id the registry does not hold is refused, naming the ones it does. */
|
|
72
69
|
export declare function providerModule(id: string): Promise<ProviderModule>;
|
|
73
70
|
/** The provider for an id, built by the provider file's create() from the options given, and nothing else. */
|
|
74
|
-
export declare function providerFor<Id extends
|
|
71
|
+
export declare function providerFor<Id extends BuiltinProviderId>(id: Id, options: ProviderOptions<Id>): Promise<ComputerProvider>;
|
|
72
|
+
export declare function providerFor(id: ProviderId, options: object): Promise<ComputerProvider>;
|
|
73
|
+
export {};
|