@parcha/agentrun-computer 0.1.0-beta.35 → 0.1.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -21
- package/box/Dockerfile +3 -1
- package/box/agentrun-archil +59 -7
- package/box/build-daytona.py +20 -4
- package/dist/browser.d.ts +61 -10
- package/dist/browser.js +125 -3
- package/dist/browserbase.d.ts +45 -20
- package/dist/browserbase.js +161 -17
- package/dist/chrome.d.ts +3 -4
- package/dist/chrome.js +6 -11
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/daytona.d.ts +4 -0
- package/dist/conformance/daytona.js +5 -0
- package/dist/daytona.d.ts +13 -1
- package/dist/daytona.js +55 -36
- package/dist/descriptor.d.ts +24 -2
- package/dist/descriptor.js +11 -0
- package/dist/descriptors/browserbase.d.ts +1 -0
- package/dist/descriptors/browserbase.js +2 -0
- package/dist/descriptors/daytona.d.ts +23 -2
- package/dist/descriptors/daytona.js +34 -2
- package/dist/descriptors/index.d.ts +28 -1
- package/dist/descriptors/index.js +1 -1
- package/dist/descriptors/kernel.d.ts +1 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/modal.d.ts +4 -0
- package/dist/descriptors/modal.js +11 -1
- package/dist/descriptors/orgo.d.ts +11 -0
- package/dist/descriptors/orgo.js +6 -1
- package/dist/descriptors/phone-harness.d.ts +5 -0
- package/dist/descriptors/phone-harness.js +3 -0
- package/dist/docker/egress.d.ts +4 -3
- package/dist/docker/egress.js +7 -6
- package/dist/docker.js +7 -5
- package/dist/e2b.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/janitor.d.ts +5 -4
- package/dist/janitor.js +1 -1
- package/dist/kernel.d.ts +16 -24
- package/dist/kernel.js +93 -18
- package/dist/kinds.d.ts +9 -4
- package/dist/labels.d.ts +10 -2
- package/dist/labels.js +30 -7
- package/dist/local-chrome.d.ts +3 -1
- package/dist/local-chrome.js +8 -4
- package/dist/modal.d.ts +3 -3
- package/dist/modal.js +71 -57
- package/dist/mount-archil.d.ts +25 -3
- package/dist/mount-archil.js +39 -8
- package/dist/orgo-desktop.d.ts +15 -6
- package/dist/orgo-desktop.js +295 -53
- package/dist/orgo-names.d.ts +129 -3
- package/dist/orgo-names.js +211 -8
- package/dist/orgo.d.ts +18 -7
- package/dist/orgo.js +381 -69
- package/dist/phone-harness.d.ts +3 -2
- package/dist/phone-harness.js +25 -8
- package/dist/protocol.d.ts +5 -0
- package/dist/provider.d.ts +63 -1
- package/dist/provider.js +8 -3
- package/package.json +1 -1
package/dist/phone-harness.d.ts
CHANGED
|
@@ -171,8 +171,9 @@ export declare function decodeScreencap(raw: Buffer): Result<{
|
|
|
171
171
|
height: number;
|
|
172
172
|
rgba: Buffer;
|
|
173
173
|
}>;
|
|
174
|
-
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame.
|
|
175
|
-
|
|
174
|
+
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. The rows are deflated off the event loop: a
|
|
175
|
+
* 1080x2400 screen took about 170 ms, every request of the server this harness runs in waiting on it. */
|
|
176
|
+
export declare function encodePng(rgba: Buffer, width: number, [x, y, w, h]: Rect): Promise<Buffer>;
|
|
176
177
|
/** uiautomator's dump as the protocol's tree: one root (the window's, or one over several), at most MAX_UI_NODES nodes. */
|
|
177
178
|
export declare function parseUiTree(xml: string, [width, height]: [number, number]): Result<{
|
|
178
179
|
root: UiNode;
|
package/dist/phone-harness.js
CHANGED
|
@@ -12,7 +12,8 @@ import { execFile } from "node:child_process";
|
|
|
12
12
|
import { createHash, randomBytes } from "node:crypto";
|
|
13
13
|
import { readFileSync } from "node:fs";
|
|
14
14
|
import { createConnection } from "node:net";
|
|
15
|
-
import {
|
|
15
|
+
import { promisify } from "node:util";
|
|
16
|
+
import { crc32, deflate } from "node:zlib";
|
|
16
17
|
import { checkActions } from "./actions.js";
|
|
17
18
|
import { PHONE_GROUPS, PHONE_HARNESS } from "./descriptors/phone-harness.js";
|
|
18
19
|
import { MAX_CHUNK_BYTES, MAX_UI_NODES, PROTOCOL_VERSION, } from "./protocol.js";
|
|
@@ -868,11 +869,14 @@ class AdbClient {
|
|
|
868
869
|
this.sleep = sleep;
|
|
869
870
|
this.now = now;
|
|
870
871
|
}
|
|
871
|
-
/** What the phone is: its ABI, its screen's size and density; then the hello it answers. */
|
|
872
|
+
/** What the phone is: its ABI, its Android release, its screen's size and density; then the hello it answers. */
|
|
872
873
|
async open(version) {
|
|
873
874
|
const abi = await this.#shell("getprop ro.product.cpu.abi");
|
|
874
875
|
if (!abi.ok)
|
|
875
876
|
return abi;
|
|
877
|
+
const release = await this.#shell("getprop ro.build.version.release");
|
|
878
|
+
if (!release.ok)
|
|
879
|
+
return release;
|
|
876
880
|
const size = await this.#shell("wm size");
|
|
877
881
|
if (!size.ok)
|
|
878
882
|
return size;
|
|
@@ -887,7 +891,9 @@ class AdbClient {
|
|
|
887
891
|
const dpi = [...density.value.matchAll(/(\d+)/g)].at(-1);
|
|
888
892
|
this.#scale = dpi ? Number(dpi[1]) / 160 : 1;
|
|
889
893
|
const reported = abi.value.trim();
|
|
890
|
-
|
|
894
|
+
// An empty answer says no release: the hello then carries none.
|
|
895
|
+
const osVersion = release.value.trim();
|
|
896
|
+
this.#hello = { protocol: PROTOCOL_VERSION, version, os: "android", ...(osVersion ? { osVersion } : {}), kind: "android", arch: ARCH[reported] ?? reported, groups: [...PHONE_GROUPS] };
|
|
891
897
|
return ok(this.#hello);
|
|
892
898
|
}
|
|
893
899
|
close() {
|
|
@@ -987,7 +993,10 @@ class AdbClient {
|
|
|
987
993
|
}
|
|
988
994
|
rect = r;
|
|
989
995
|
}
|
|
990
|
-
const bytes = encodePng(rgba, width, rect);
|
|
996
|
+
const bytes = await encodePng(rgba, width, rect);
|
|
997
|
+
// close() may have run while the frame was deflating: hold nothing for a closed connection.
|
|
998
|
+
if (this.#closed)
|
|
999
|
+
return fail("gone", "the connection to the phone is closed");
|
|
991
1000
|
const id = randomBytes(6).toString("hex");
|
|
992
1001
|
this.#held = { id, bytes };
|
|
993
1002
|
const data = bytes.subarray(0, MAX_CHUNK_BYTES);
|
|
@@ -1042,9 +1051,14 @@ class AdbClient {
|
|
|
1042
1051
|
const frameWidth = Math.min(width, maxWidth);
|
|
1043
1052
|
const frameHeight = Math.max(1, Math.floor((height * frameWidth) / width));
|
|
1044
1053
|
const pixels = frameWidth === width ? rgba : scaleRgba(rgba, width, height, frameWidth, frameHeight);
|
|
1054
|
+
// Encoded before the frame is published: a watch that reads the seq while this one encodes never gets an older
|
|
1055
|
+
// frame under the newer seq.
|
|
1056
|
+
const bytes = await encodePng(pixels, frameWidth, [0, 0, frameWidth, frameHeight]);
|
|
1057
|
+
if (signal.aborted || this.#closed)
|
|
1058
|
+
return aborted();
|
|
1045
1059
|
watch.seq += 1;
|
|
1046
1060
|
watch.digest = digest;
|
|
1047
|
-
watch.frame = { bytes
|
|
1061
|
+
watch.frame = { bytes, frameWidth, frameHeight, width, height };
|
|
1048
1062
|
return ok(this.#frameAnswer());
|
|
1049
1063
|
}
|
|
1050
1064
|
const left = deadline - this.now();
|
|
@@ -1344,8 +1358,11 @@ function scaleRgba(rgba, width, height, toWidth, toHeight) {
|
|
|
1344
1358
|
}
|
|
1345
1359
|
return out;
|
|
1346
1360
|
}
|
|
1347
|
-
/**
|
|
1348
|
-
|
|
1361
|
+
/** zlib's deflate on its thread pool: a screen's deflate never holds this process's event loop. */
|
|
1362
|
+
const deflateAsync = promisify(deflate);
|
|
1363
|
+
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. The rows are deflated off the event loop: a
|
|
1364
|
+
* 1080x2400 screen took about 170 ms, every request of the server this harness runs in waiting on it. */
|
|
1365
|
+
export async function encodePng(rgba, width, [x, y, w, h]) {
|
|
1349
1366
|
const rows = Buffer.alloc((w * 4 + 1) * h);
|
|
1350
1367
|
for (let row = 0; row < h; row++) {
|
|
1351
1368
|
const from = ((y + row) * width + x) * 4;
|
|
@@ -1363,7 +1380,7 @@ export function encodePng(rgba, width, [x, y, w, h]) {
|
|
|
1363
1380
|
ihdr.writeUInt32BE(w, 0);
|
|
1364
1381
|
ihdr.writeUInt32BE(h, 4);
|
|
1365
1382
|
ihdr.set([8, 6, 0, 0, 0], 8);
|
|
1366
|
-
return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", ihdr), chunk("IDAT",
|
|
1383
|
+
return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", ihdr), chunk("IDAT", await deflateAsync(rows)), chunk("IEND", Buffer.alloc(0))]);
|
|
1367
1384
|
}
|
|
1368
1385
|
const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
1369
1386
|
const unescape = (text) => text.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos);/gi, (_, name) => name[0] === "#" ? String.fromCodePoint(name[1] === "x" || name[1] === "X" ? Number.parseInt(name.slice(2), 16) : Number(name.slice(1))) : ENTITIES[name.toLowerCase()]);
|
package/dist/protocol.d.ts
CHANGED
|
@@ -55,6 +55,11 @@ export interface HelloResult {
|
|
|
55
55
|
/** The daemon's own version (with daemon none, the provider's). */
|
|
56
56
|
version: string;
|
|
57
57
|
os: ComputerOs;
|
|
58
|
+
/**
|
|
59
|
+
* The OS's own version as the computer says it: a phone's Android release (getprop ro.build.version.release), such
|
|
60
|
+
* as "15". Absent where the computer does not say one.
|
|
61
|
+
*/
|
|
62
|
+
osVersion?: string;
|
|
58
63
|
kind: ComputerKind;
|
|
59
64
|
/** Go's name for the architecture: amd64, arm64. */
|
|
60
65
|
arch: string;
|
package/dist/provider.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export type NetworkForm = "none" | "open" | "allow";
|
|
|
12
12
|
export interface ComputerOwner {
|
|
13
13
|
/** The agent's id: a non-empty string with no NUL byte (ownerProblem). */
|
|
14
14
|
agent: string;
|
|
15
|
+
/**
|
|
16
|
+
* The server the agent is on, where more than one server shares a vendor account: two servers may each have an agent
|
|
17
|
+
* of one id, and each owns its own computer. A non-empty string with no NUL byte. Absent: the agent's id alone.
|
|
18
|
+
*/
|
|
19
|
+
server?: string;
|
|
15
20
|
/** How long the computer may stay detached before the janitor deletes it. Absent: it stays until it is deleted. */
|
|
16
21
|
idleTtlMs?: number;
|
|
17
22
|
}
|
|
@@ -45,6 +50,11 @@ export interface ComputerSpec {
|
|
|
45
50
|
* refuses any other kind before a vendor call. An Archil token is never in a label, a read-back or an error.
|
|
46
51
|
*/
|
|
47
52
|
mount?: MountSpec;
|
|
53
|
+
/**
|
|
54
|
+
* A browser's own options, for a provider whose capabilities().browser declares what they ask; check() refuses, in
|
|
55
|
+
* words and before any vendor call, one it does not declare.
|
|
56
|
+
*/
|
|
57
|
+
browser?: BrowserSpec;
|
|
48
58
|
/**
|
|
49
59
|
* GPUs for the computer: a type the provider declares (capabilities().gpu.types, the vendor's own name, such as Modal's
|
|
50
60
|
* "A100-80GB" or Daytona's "H100") and how many, 1 up to capabilities().gpu.max. check() refuses one the provider does
|
|
@@ -80,6 +90,14 @@ export interface GpuCapability {
|
|
|
80
90
|
};
|
|
81
91
|
/** The mount kinds a GPU computer takes, where fewer than capabilities().mount: none yet proven on its GPU computers. */
|
|
82
92
|
mounts?: MountKind[];
|
|
93
|
+
/**
|
|
94
|
+
* Why a GPU computer takes none of the other mounts, in words naming no field: a fact of the vendor's runtime, or
|
|
95
|
+
* (yet) one not proven there. checkGpu's refusal of a mount gives it, and serve's refusal of the run's folder.
|
|
96
|
+
*/
|
|
97
|
+
unmounted?: {
|
|
98
|
+
why: string;
|
|
99
|
+
yet: boolean;
|
|
100
|
+
};
|
|
83
101
|
/**
|
|
84
102
|
* How init holds a GPU computer's programs off its network, where it is not the plain network namespace: on Modal's
|
|
85
103
|
* gVisor, "userns-netns", one made inside a user namespace, as root there may not make one (measured). The fence holds
|
|
@@ -87,6 +105,38 @@ export interface GpuCapability {
|
|
|
87
105
|
*/
|
|
88
106
|
fence?: NetworkFence;
|
|
89
107
|
}
|
|
108
|
+
/** A browser session's options beside the protocol's. A flag set false asks for nothing, so it is never refused. */
|
|
109
|
+
export interface BrowserSpec {
|
|
110
|
+
viewport?: {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
};
|
|
114
|
+
/** A saved profile the session opens: the pointer profiles.create gave, and whether the session saves back to it. */
|
|
115
|
+
profile?: {
|
|
116
|
+
pointer: string;
|
|
117
|
+
save: boolean;
|
|
118
|
+
};
|
|
119
|
+
/** The vendor's anti-bot mode (Browserbase's Verified browser and its CAPTCHA solver). */
|
|
120
|
+
stealth?: boolean;
|
|
121
|
+
headless?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/** What a browser provider's sessions offer beyond the protocol: each optional feature is there only when declared. */
|
|
124
|
+
export interface BrowserFeatures {
|
|
125
|
+
/** "wall-clock": the vendor ends a session lifetimeMs after create; "inactivity": that long after its last connection closes. */
|
|
126
|
+
timeout: "wall-clock" | "inactivity";
|
|
127
|
+
/** The shortest lifetimeMs a session takes (Kernel's shortest idle timeout); absent, any above 0. */
|
|
128
|
+
minLifetimeMs?: number;
|
|
129
|
+
/** settleMs: how long after a saving session ends the vendor may still be writing the profile back. */
|
|
130
|
+
profiles?: {
|
|
131
|
+
settleMs: number;
|
|
132
|
+
};
|
|
133
|
+
stealth?: true;
|
|
134
|
+
headless?: true;
|
|
135
|
+
/** path: the directory a driver points Browser.setDownloadBehavior at, so the vendor keeps what is saved there. */
|
|
136
|
+
downloads?: {
|
|
137
|
+
path: string;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
90
140
|
/** One kind of allowlist entry a provider takes: how many a list may hold, and the ports an entry opens. */
|
|
91
141
|
export interface AllowRule {
|
|
92
142
|
max: number;
|
|
@@ -166,6 +216,8 @@ export interface ComputerCapabilities {
|
|
|
166
216
|
vendorAgentPorts?: number[];
|
|
167
217
|
/** The GPUs spec.gpu may ask for. Absent: none, and check() refuses any spec.gpu. */
|
|
168
218
|
gpu?: GpuCapability;
|
|
219
|
+
/** With kind browser: what its sessions offer beyond the protocol, which spec.browser asks for. */
|
|
220
|
+
browser?: BrowserFeatures;
|
|
169
221
|
}
|
|
170
222
|
/** The os and daemon modes each kind may have; no other pair is valid. */
|
|
171
223
|
export declare const KIND_SHAPES: Readonly<Record<ComputerKind, {
|
|
@@ -287,6 +339,15 @@ export interface AttachContext extends CallContext {
|
|
|
287
339
|
* computer stops with its state kept, still the agent's (a provider that declares persistence; refused otherwise).
|
|
288
340
|
*/
|
|
289
341
|
export type ReleaseHow = "stop" | "delete" | "detach";
|
|
342
|
+
/**
|
|
343
|
+
* release's context: with a claim (a provider that declares persistence), a delete of an agent's computer is that claim's
|
|
344
|
+
* alone: done only while the computer still carries exactly the claim's run and epoch and no attach or detach holds it,
|
|
345
|
+
* else refused in words (fenced, or busy) with the computer as it was. So a claim that made the computer and lost it
|
|
346
|
+
* deletes it only where no later claim has taken it. A provider with no persistence has no agent's computer to fence.
|
|
347
|
+
*/
|
|
348
|
+
export interface ReleaseContext extends CallContext {
|
|
349
|
+
claim?: ComputerClaim;
|
|
350
|
+
}
|
|
290
351
|
/** A live connection to a computer's daemon. */
|
|
291
352
|
export interface ComputerConnection {
|
|
292
353
|
client: ComputerClient;
|
|
@@ -329,8 +390,9 @@ export interface ComputerProvider {
|
|
|
329
390
|
/**
|
|
330
391
|
* Idempotent: a computer already gone is ok. A "stop" capabilities().release does not declare is refused in words. A
|
|
331
392
|
* "detach" is refused in words, the computer as it was, on a provider with no persistence and on a run's computer.
|
|
393
|
+
* context.claim: a delete under that claim alone (ReleaseContext).
|
|
332
394
|
*/
|
|
333
|
-
release(ref: ComputerRef, how: ReleaseHow): Promise<Result<void>>;
|
|
395
|
+
release(ref: ComputerRef, how: ReleaseHow, context?: ReleaseContext): Promise<Result<void>>;
|
|
334
396
|
/**
|
|
335
397
|
* Sets the deadline to now + ttlMs: never earlier than the current deadline, never past created + maxLifetimeMs. A
|
|
336
398
|
* ttlMs that would move it earlier, or past that cap, is refused in words with the deadline unchanged: an extend
|
package/dist/provider.js
CHANGED
|
@@ -47,12 +47,16 @@ export function runLifetimeMs(spec) {
|
|
|
47
47
|
/** Why owner is not an agent's ownership, in words, or undefined when it is one. */
|
|
48
48
|
export function ownerProblem(owner) {
|
|
49
49
|
if (typeof owner !== "object" || owner === null || Array.isArray(owner))
|
|
50
|
-
return "owner is { agent, idleTtlMs? }";
|
|
51
|
-
const { agent, idleTtlMs } = owner;
|
|
50
|
+
return "owner is { agent, server?, idleTtlMs? }";
|
|
51
|
+
const { agent, server, idleTtlMs } = owner;
|
|
52
52
|
if (typeof agent !== "string" || agent === "")
|
|
53
53
|
return "owner.agent must be the agent's id, a non-empty string";
|
|
54
54
|
if (agent.includes("\0"))
|
|
55
55
|
return "owner.agent cannot hold a NUL byte: no provider takes one in a label";
|
|
56
|
+
if (server !== undefined && (typeof server !== "string" || server === ""))
|
|
57
|
+
return "owner.server, when given, is the server's id, a non-empty string";
|
|
58
|
+
if (typeof server === "string" && server.includes("\0"))
|
|
59
|
+
return "owner.server cannot hold a NUL byte: no provider takes one in a label";
|
|
56
60
|
if (idleTtlMs !== undefined && !(Number.isSafeInteger(idleTtlMs) && idleTtlMs > 0))
|
|
57
61
|
return `owner.idleTtlMs is a whole number of milliseconds above 0, not ${JSON.stringify(idleTtlMs)}`;
|
|
58
62
|
return undefined;
|
|
@@ -101,7 +105,8 @@ export function checkGpu(gpu, { gpu: offered }, mount) {
|
|
|
101
105
|
// A mount that is not an object with a kind (null among them) is checkMount's refusal; nothing is read from it here.
|
|
102
106
|
const kind = typeof mount === "object" && mount !== null ? mount.kind : undefined;
|
|
103
107
|
if (kind !== undefined && offered.mounts !== undefined && !offered.mounts.includes(kind)) {
|
|
104
|
-
|
|
108
|
+
const why = offered.unmounted?.why ?? "it is not proven on this provider's GPU computers yet";
|
|
109
|
+
return refuse(`a GPU computer here takes no ${String(kind)} mount: ${why}; ask for a GPU computer without a mount, or a mount without a GPU`);
|
|
105
110
|
}
|
|
106
111
|
return [];
|
|
107
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-computer",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.36",
|
|
4
4
|
"description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|