@parcha/agentrun-computer 0.0.0-placeholder → 0.1.0-beta.32
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +2400 -1
- package/box/Dockerfile +69 -0
- package/box/agentrun-archil +168 -0
- package/box/build-daytona.py +26 -0
- package/box/build-e2b.mjs +32 -0
- package/box/build-modal.py +17 -0
- package/dist/actions.d.ts +18 -0
- package/dist/actions.js +139 -0
- package/dist/browser.d.ts +151 -0
- package/dist/browser.js +305 -0
- package/dist/browserbase.d.ts +139 -0
- package/dist/browserbase.js +408 -0
- package/dist/child.d.ts +40 -0
- package/dist/child.js +127 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +136 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/archil.d.ts +68 -0
- package/dist/conformance/archil.js +152 -0
- package/dist/conformance/browserbase.d.ts +35 -0
- package/dist/conformance/browserbase.js +45 -0
- package/dist/conformance/cases/apps.d.ts +2 -0
- package/dist/conformance/cases/apps.js +155 -0
- package/dist/conformance/cases/browser.d.ts +4 -0
- package/dist/conformance/cases/browser.js +105 -0
- package/dist/conformance/cases/drift.d.ts +2 -0
- package/dist/conformance/cases/drift.js +64 -0
- package/dist/conformance/cases/exec.d.ts +2 -0
- package/dist/conformance/cases/exec.js +125 -0
- package/dist/conformance/cases/files.d.ts +2 -0
- package/dist/conformance/cases/files.js +294 -0
- package/dist/conformance/cases/health.d.ts +2 -0
- package/dist/conformance/cases/health.js +71 -0
- package/dist/conformance/cases/index.d.ts +9 -0
- package/dist/conformance/cases/index.js +37 -0
- package/dist/conformance/cases/input.d.ts +12 -0
- package/dist/conformance/cases/input.js +109 -0
- package/dist/conformance/cases/isolation.d.ts +21 -0
- package/dist/conformance/cases/isolation.js +92 -0
- package/dist/conformance/cases/lifetime.d.ts +2 -0
- package/dist/conformance/cases/lifetime.js +64 -0
- package/dist/conformance/cases/mount.d.ts +2 -0
- package/dist/conformance/cases/mount.js +252 -0
- package/dist/conformance/cases/process.d.ts +2 -0
- package/dist/conformance/cases/process.js +240 -0
- package/dist/conformance/cases/provider.d.ts +2 -0
- package/dist/conformance/cases/provider.js +302 -0
- package/dist/conformance/cases/screen.d.ts +9 -0
- package/dist/conformance/cases/screen.js +230 -0
- package/dist/conformance/cases/settings.d.ts +57 -0
- package/dist/conformance/cases/settings.js +142 -0
- package/dist/conformance/cases/touch.d.ts +2 -0
- package/dist/conformance/cases/touch.js +117 -0
- package/dist/conformance/cases/util.d.ts +7 -0
- package/dist/conformance/cases/util.js +8 -0
- package/dist/conformance/cdp.d.ts +13 -0
- package/dist/conformance/cdp.js +88 -0
- package/dist/conformance/cli.d.ts +29 -0
- package/dist/conformance/cli.js +231 -0
- package/dist/conformance/daytona-sweep.d.ts +18 -0
- package/dist/conformance/daytona-sweep.js +118 -0
- package/dist/conformance/daytona.d.ts +83 -0
- package/dist/conformance/daytona.js +107 -0
- package/dist/conformance/docker.d.ts +38 -0
- package/dist/conformance/docker.js +70 -0
- package/dist/conformance/drift-daemon.d.ts +8 -0
- package/dist/conformance/drift-daemon.js +41 -0
- package/dist/conformance/e2b-diagnose.d.ts +16 -0
- package/dist/conformance/e2b-diagnose.js +61 -0
- package/dist/conformance/e2b-sweep.d.ts +18 -0
- package/dist/conformance/e2b-sweep.js +125 -0
- package/dist/conformance/e2b.d.ts +74 -0
- package/dist/conformance/e2b.js +111 -0
- package/dist/conformance/fixture.d.ts +65 -0
- package/dist/conformance/fixture.js +98 -0
- package/dist/conformance/index.d.ts +8 -0
- package/dist/conformance/index.js +8 -0
- package/dist/conformance/kernel.d.ts +31 -0
- package/dist/conformance/kernel.js +40 -0
- package/dist/conformance/kind.d.ts +23 -0
- package/dist/conformance/kind.js +58 -0
- package/dist/conformance/modal-sweep.d.ts +22 -0
- package/dist/conformance/modal-sweep.js +190 -0
- package/dist/conformance/modal.d.ts +69 -0
- package/dist/conformance/modal.js +76 -0
- package/dist/conformance/orgo.d.ts +41 -0
- package/dist/conformance/orgo.js +69 -0
- package/dist/conformance/phone-harness.d.ts +61 -0
- package/dist/conformance/phone-harness.js +241 -0
- package/dist/conformance/png.d.ts +16 -0
- package/dist/conformance/png.js +132 -0
- package/dist/conformance/report.d.ts +2 -0
- package/dist/conformance/report.js +86 -0
- package/dist/conformance/runner.d.ts +11 -0
- package/dist/conformance/runner.js +585 -0
- package/dist/conformance/tar.d.ts +13 -0
- package/dist/conformance/tar.js +105 -0
- package/dist/conformance/types.d.ts +257 -0
- package/dist/conformance/types.js +24 -0
- package/dist/daemon-copy.d.ts +40 -0
- package/dist/daemon-copy.js +259 -0
- package/dist/daytona.d.ts +178 -0
- package/dist/daytona.js +1484 -0
- package/dist/desktop.d.ts +24 -0
- package/dist/desktop.js +68 -0
- package/dist/docker/egress-main.d.ts +1 -0
- package/dist/docker/egress-main.js +68 -0
- package/dist/docker/egress-proxy.d.ts +53 -0
- package/dist/docker/egress-proxy.js +450 -0
- package/dist/docker/egress-table.d.ts +39 -0
- package/dist/docker/egress-table.js +197 -0
- package/dist/docker/egress.d.ts +109 -0
- package/dist/docker/egress.js +318 -0
- package/dist/docker/image.d.ts +49 -0
- package/dist/docker/image.js +302 -0
- package/dist/docker/stage.d.ts +21 -0
- package/dist/docker/stage.js +290 -0
- package/dist/docker/volume.d.ts +24 -0
- package/dist/docker/volume.js +67 -0
- package/dist/docker.d.ts +150 -0
- package/dist/docker.js +1200 -0
- package/dist/drift.d.ts +200 -0
- package/dist/drift.js +416 -0
- package/dist/e2b.d.ts +335 -0
- package/dist/e2b.js +1515 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.js +24 -0
- package/dist/files.d.ts +50 -0
- package/dist/files.js +208 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +26 -0
- package/dist/isolation.d.ts +29 -0
- package/dist/isolation.js +71 -0
- package/dist/janitor.d.ts +50 -0
- package/dist/janitor.js +135 -0
- package/dist/kernel.d.ts +113 -0
- package/dist/kernel.js +358 -0
- package/dist/kinds.d.ts +79 -0
- package/dist/kinds.js +133 -0
- package/dist/labels.d.ts +23 -0
- package/dist/labels.js +50 -0
- package/dist/modal.d.ts +302 -0
- package/dist/modal.js +1374 -0
- package/dist/mount-archil.d.ts +164 -0
- package/dist/mount-archil.js +471 -0
- package/dist/mount.d.ts +57 -0
- package/dist/mount.js +104 -0
- package/dist/orgo-channel.d.ts +96 -0
- package/dist/orgo-channel.js +391 -0
- package/dist/orgo.d.ts +139 -0
- package/dist/orgo.js +1006 -0
- package/dist/phone-harness.d.ts +185 -0
- package/dist/phone-harness.js +1420 -0
- package/dist/processes.d.ts +24 -0
- package/dist/processes.js +40 -0
- package/dist/protocol.d.ts +729 -0
- package/dist/protocol.js +54 -0
- package/dist/provider.d.ts +245 -0
- package/dist/provider.js +37 -0
- package/dist/providers.d.ts +68 -0
- package/dist/providers.js +25 -0
- package/dist/result.d.ts +15 -0
- package/dist/result.js +2 -0
- package/dist/screen-watch.d.ts +150 -0
- package/dist/screen-watch.js +490 -0
- package/dist/test-connection.d.ts +17 -0
- package/dist/test-connection.js +26 -0
- package/dist/wait.d.ts +23 -0
- package/dist/wait.js +65 -0
- package/package.json +64 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { KindCapabilities } from "./kinds.js";
|
|
2
|
+
import type { MountKind } from "./mount.js";
|
|
3
|
+
import { type Group, type Rect, type UiNode } from "./protocol.js";
|
|
4
|
+
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
|
|
5
|
+
import { type Result } from "./result.js";
|
|
6
|
+
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
7
|
+
/** The phone harness's API. */
|
|
8
|
+
export declare const PHONE_HARNESS_URL = "https://api.phone-harness.com";
|
|
9
|
+
/** What a cloud Android offers through this provider, as its capabilities and hello declare them. */
|
|
10
|
+
export declare const PHONE_GROUPS: readonly Group[];
|
|
11
|
+
/** A phone mounts no folder. */
|
|
12
|
+
export declare const MOUNT: readonly MountKind[];
|
|
13
|
+
/** The one configuration it offers, as its capabilities() declare it: the kind registry's entry holds the same. */
|
|
14
|
+
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
15
|
+
/** The image a phone is read back by: a cloud Android has none to choose, so a setting that names none takes this. */
|
|
16
|
+
export declare const PHONE_IMAGE = "android";
|
|
17
|
+
/** The longest lifetime by default: a rented phone bills by the minute. */
|
|
18
|
+
export declare const DEFAULT_MAX_LIFETIME_MS: number;
|
|
19
|
+
/** How long create waits for a phone to be ready by default: the service's own CLI waits 240 s. */
|
|
20
|
+
export declare const DEFAULT_READY_MS = 240000;
|
|
21
|
+
/** One phone this provider made, as its ledger keeps it. */
|
|
22
|
+
export interface PhoneLedgerEntry {
|
|
23
|
+
/** The session's id, the computer's id and name. */
|
|
24
|
+
id: string;
|
|
25
|
+
labels: Record<string, string>;
|
|
26
|
+
/** The image create was asked for, read back as asked. */
|
|
27
|
+
image: string;
|
|
28
|
+
/** When the service ends the session, ISO time. */
|
|
29
|
+
deadline: string;
|
|
30
|
+
/**
|
|
31
|
+
* The Idempotency-Key of a create not answered yet: the entry is put before the POST, under the id pending-<key>,
|
|
32
|
+
* so a phone made under a create whose answer and recovery were both lost is still found. list() takes the account's
|
|
33
|
+
* session whose request_key is exactly this key as the entry's phone.
|
|
34
|
+
*/
|
|
35
|
+
request?: string;
|
|
36
|
+
/**
|
|
37
|
+
* When release sent the phone's DELETE, ISO time. The service ends a session asynchronously (live run 7): the
|
|
38
|
+
* entry is kept, marked, until the phone's own GET is a 404. A phone so marked is not listed, and attach, connect
|
|
39
|
+
* and network answer not_found, as for a deleted computer; a second release of it is ok.
|
|
40
|
+
*/
|
|
41
|
+
released?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Where the provider keeps its phones' labels: the vendor keeps none. Each call may be sync or async. */
|
|
44
|
+
export interface PhoneLedger {
|
|
45
|
+
put(entry: PhoneLedgerEntry): void | Promise<void>;
|
|
46
|
+
get(id: string): PhoneLedgerEntry | undefined | Promise<PhoneLedgerEntry | undefined>;
|
|
47
|
+
list(): PhoneLedgerEntry[] | Promise<PhoneLedgerEntry[]>;
|
|
48
|
+
remove(id: string): void | Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/** A ledger in this process's memory: the default, and enough for one process that makes and ends its phones. */
|
|
51
|
+
export declare function memoryLedger(): PhoneLedger;
|
|
52
|
+
/** What one adb call gave: its exit code and output. */
|
|
53
|
+
export interface AdbResult {
|
|
54
|
+
exitCode: number;
|
|
55
|
+
stdout: Buffer;
|
|
56
|
+
stderr: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* How the provider reaches adb. A spawned process's argv is in /proc for every user of the host, so no secret goes
|
|
60
|
+
* there: the phone's endpoint goes only to the local adb server, over its socket (server), and the unlock code only
|
|
61
|
+
* through a spawned adb's stdin (run's input). A spawned adb names its device by the adb server's transport id.
|
|
62
|
+
*/
|
|
63
|
+
export interface AdbTransport {
|
|
64
|
+
/**
|
|
65
|
+
* Runs adb with args, and input on its stdin when given. A result in words when adb could not run at all (missing,
|
|
66
|
+
* timed out); otherwise its exit code and output, whatever they are. The words never hold the args or the input.
|
|
67
|
+
*/
|
|
68
|
+
run(args: string[], options: {
|
|
69
|
+
timeoutMs: number;
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
input?: string;
|
|
72
|
+
}): Promise<Result<AdbResult>>;
|
|
73
|
+
/**
|
|
74
|
+
* One request to the local adb server by its socket protocol (host:connect:<endpoint>, host:disconnect:<endpoint>,
|
|
75
|
+
* host:devices-l), starting the server first if need be: the answer's words. With transport, the socket is bound to
|
|
76
|
+
* that phone first (host:transport-id:<id>) and the service is one of the phone's (shell:<command>), answered with
|
|
77
|
+
* its output: how the unlock code reaches the phone with no argv holding it. The words never hold the request.
|
|
78
|
+
*/
|
|
79
|
+
server(service: string, options: {
|
|
80
|
+
timeoutMs: number;
|
|
81
|
+
transport?: string;
|
|
82
|
+
}): Promise<Result<string>>;
|
|
83
|
+
}
|
|
84
|
+
/** The adb server's port when none is given: adb's own default. */
|
|
85
|
+
export declare const ADB_SERVER_PORT = 5037;
|
|
86
|
+
/**
|
|
87
|
+
* The adb CLI (Android platform-tools) at path, by execFile, never a shell, and the adb server it starts, on the
|
|
88
|
+
* loopback at port (adb's own default), spoken to by its socket protocol.
|
|
89
|
+
*
|
|
90
|
+
* env is the environment a spawned adb starts from, with every adb variable dropped from it (ADB_SERVER_SOCKET,
|
|
91
|
+
* ANDROID_ADB_SERVER_SOCKET, ANDROID_ADB_SERVER_ADDRESS, ANDROID_SERIAL, ...), so nothing in it points the CLI at
|
|
92
|
+
* another server than its socket requests reach. The library reads no environment of its own: a caller passes it (the
|
|
93
|
+
* conformance module passes process.env). Without env, a spawned adb inherits the process's environment as it is.
|
|
94
|
+
*/
|
|
95
|
+
export declare function adbCli(path?: string, { port, env }?: {
|
|
96
|
+
port?: number;
|
|
97
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
98
|
+
}): AdbTransport;
|
|
99
|
+
/** A service as error words name it: its kind and first word, never the rest (a shell command's code, an endpoint). */
|
|
100
|
+
export declare function serviceWords(service: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* The adb server's answer: OKAY, or FAIL and its words, each optionally followed by a length-prefixed message. FAIL's
|
|
103
|
+
* words may name the phone's endpoint: they are redacted.
|
|
104
|
+
*/
|
|
105
|
+
export declare function adbAnswer(raw: Buffer, what: string): Result<string>;
|
|
106
|
+
export interface PhoneProviderOptions {
|
|
107
|
+
/** The phone harness API key; serve passes PHONE_HARNESS_API_KEY. Never logged, never in an error. */
|
|
108
|
+
apiKey: string;
|
|
109
|
+
/** Which phone: "android", a temporary cloud emulator (the default). "ios" is refused until it is built. */
|
|
110
|
+
platform?: "android" | "ios";
|
|
111
|
+
/** The API's base URL; default PHONE_HARNESS_URL. */
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
/** fetch; default the global one. Tests give a fake. */
|
|
114
|
+
fetch?: typeof globalThis.fetch;
|
|
115
|
+
/** How adb is reached (AdbTransport), or the adb CLI's path; default adbCli("adb"). */
|
|
116
|
+
adb?: AdbTransport | string;
|
|
117
|
+
/** Where the provider's phones and their labels are kept; default memoryLedger(). */
|
|
118
|
+
ledger?: PhoneLedger;
|
|
119
|
+
/** The longest lifetime; default 30 min. */
|
|
120
|
+
maxLifetimeMs?: number;
|
|
121
|
+
/** How long create waits for a phone to be ready; default 240 s. */
|
|
122
|
+
readyMs?: number;
|
|
123
|
+
/** How often create asks whether the phone is ready; default 2 s. */
|
|
124
|
+
pollMs?: number;
|
|
125
|
+
/** The longest one API request may take; default 30 s. A readiness read takes no longer than readyMs has left. */
|
|
126
|
+
requestMs?: number;
|
|
127
|
+
/** The clock: ms since the epoch, and a wait. Tests give a fake that moves at once. */
|
|
128
|
+
now?: () => number;
|
|
129
|
+
sleep?: (ms: number) => Promise<void>;
|
|
130
|
+
/** A signal that fires after ms, which bounds a request; default AbortSignal.timeout. Tests give one they fire. */
|
|
131
|
+
timeout?: (ms: number) => AbortSignal;
|
|
132
|
+
/** The version the phone's hello reports; default the provider's. Only the conformance drift case sets another. */
|
|
133
|
+
daemonVersion?: string;
|
|
134
|
+
}
|
|
135
|
+
/** The phone-harness provider from its options alone; throws in words when one is missing or wrong. */
|
|
136
|
+
export declare function create(options: PhoneProviderOptions): Promise<PhoneHarnessProvider>;
|
|
137
|
+
/** The conformance CLI's module for the phone harness. */
|
|
138
|
+
export declare const conformance: () => Promise<typeof import("./conformance/phone-harness.js")>;
|
|
139
|
+
export declare class PhoneHarnessProvider implements ComputerProvider {
|
|
140
|
+
#private;
|
|
141
|
+
readonly id = "phone-harness";
|
|
142
|
+
readonly version: string;
|
|
143
|
+
constructor(options: PhoneProviderOptions);
|
|
144
|
+
capabilities(): ComputerCapabilities;
|
|
145
|
+
check(spec: ComputerSpec): Refusal[];
|
|
146
|
+
create(spec: ComputerSpec, context?: {
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
}): Promise<Result<CreatedComputer>>;
|
|
149
|
+
attach(ref: {
|
|
150
|
+
id: string;
|
|
151
|
+
} | {
|
|
152
|
+
labels: Record<string, string>;
|
|
153
|
+
}, context?: CallContext): Promise<Result<AttachedComputer>>;
|
|
154
|
+
list(labels: Record<string, string>, context?: CallContext): Promise<Result<ComputerInfo[]>>;
|
|
155
|
+
network(ref: ComputerRef, policy?: NetworkSpec): Promise<Result<NetworkPolicy>>;
|
|
156
|
+
release(ref: ComputerRef, how: "stop" | "delete"): Promise<Result<void>>;
|
|
157
|
+
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
|
158
|
+
/**
|
|
159
|
+
* The live view: the phone client's screen.watch on a connection of the watch's own (daemonWatch), PNG frames from
|
|
160
|
+
* screencap. Upright with no rotation of ours: screencap gives the display in its current orientation, and input tap
|
|
161
|
+
* and swipe take that same space, so each frame's width and height come from its own screencap, never from wm size.
|
|
162
|
+
*/
|
|
163
|
+
watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
|
|
164
|
+
/**
|
|
165
|
+
* Settings' test: one GET /sessions, the account's sessions joined to the ledger, and a GET of any phone of the
|
|
166
|
+
* ledger the listing leaves out. It rents nothing.
|
|
167
|
+
*/
|
|
168
|
+
testConnection(context?: CallContext): Promise<Result<{
|
|
169
|
+
detail: string;
|
|
170
|
+
}>>;
|
|
171
|
+
}
|
|
172
|
+
/** The frame `adb exec-out screencap` gives: a header (width, height, format, and a color space on newer Androids), then the pixels. */
|
|
173
|
+
export declare function decodeScreencap(raw: Buffer): Result<{
|
|
174
|
+
width: number;
|
|
175
|
+
height: number;
|
|
176
|
+
rgba: Buffer;
|
|
177
|
+
}>;
|
|
178
|
+
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. */
|
|
179
|
+
export declare function encodePng(rgba: Buffer, width: number, [x, y, w, h]: Rect): Buffer;
|
|
180
|
+
/** uiautomator's dump as the protocol's tree: one root (the window's, or one over several), at most MAX_UI_NODES nodes. */
|
|
181
|
+
export declare function parseUiTree(xml: string, [width, height]: [number, number]): Result<{
|
|
182
|
+
root: UiNode;
|
|
183
|
+
nodes: number;
|
|
184
|
+
truncated: boolean;
|
|
185
|
+
}>;
|