@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.38
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/NOTICE +2 -0
- package/README.md +547 -478
- package/box/Dockerfile +18 -1
- package/box/README.md +13 -0
- package/box/build-agent37.mjs +158 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.mjs +43 -0
- package/dist/agent37-ssh.d.ts +89 -0
- package/dist/agent37-ssh.js +445 -0
- package/dist/agent37.d.ts +104 -0
- package/dist/agent37.js +402 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -10
- package/dist/browserbase.js +3 -6
- package/dist/client.d.ts +45 -4
- package/dist/client.js +92 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +11 -0
- package/dist/conformance/cases/apps.js +173 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/isolation.d.ts +7 -5
- package/dist/conformance/cases/isolation.js +44 -14
- package/dist/conformance/cases/mount.js +1 -1
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +94 -9
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/exec-stream.d.ts +45 -0
- package/dist/conformance/exec-stream.js +486 -0
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +13 -5
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +20 -133
- package/dist/daytona.js +405 -1449
- package/dist/descriptor.d.ts +11 -1
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/daytona.d.ts +6 -5
- package/dist/descriptors/daytona.js +9 -5
- package/dist/descriptors/index.d.ts +42 -7
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker.d.ts +7 -10
- package/dist/docker.js +272 -34
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +16 -290
- package/dist/e2b.js +230 -1393
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +201 -0
- package/dist/host.js +8 -0
- package/dist/hosted/process.d.ts +81 -0
- package/dist/hosted/process.js +259 -0
- package/dist/hosted/provider.d.ts +160 -0
- package/dist/hosted/provider.js +1415 -0
- package/dist/hosted/rest.d.ts +66 -0
- package/dist/hosted/rest.js +121 -0
- package/dist/hosted/scripts.d.ts +82 -0
- package/dist/{child.js → hosted/scripts.js} +118 -12
- package/dist/hosted/values.d.ts +5 -0
- package/dist/hosted/values.js +8 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -10
- package/dist/kernel.js +3 -6
- package/dist/kinds.d.ts +11 -2
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -10
- package/dist/local-chrome.js +3 -6
- package/dist/modal.d.ts +22 -257
- package/dist/modal.js +183 -1280
- package/dist/mount-archil.d.ts +8 -4
- package/dist/mount-archil.js +22 -11
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -13
- package/dist/orgo.js +32 -21
- package/dist/phone-harness.d.ts +31 -28
- package/dist/phone-harness.js +510 -702
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +339 -33
- package/dist/protocol.js +97 -3
- package/dist/provider.d.ts +36 -8
- package/dist/provider.js +16 -0
- package/dist/providers.d.ts +11 -12
- package/dist/result.d.ts +1 -1
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +260 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +55 -0
- package/dist/surface/core.js +475 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +10 -0
- package/dist/surface/outline.js +51 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +94 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +814 -0
- package/package.json +18 -3
- package/dist/child.d.ts +0 -42
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
package/dist/png.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Rect } from "./protocol.js";
|
|
2
|
+
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. The rows are deflated off the event loop: a
|
|
3
|
+
* 1080x2400 screen took about 170 ms, every request of the server this harness runs in waiting on it. */
|
|
4
|
+
export declare function encodePng(rgba: Buffer, width: number, [x, y, w, h]: Rect): Promise<Buffer>;
|
package/dist/png.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// PNG encoding for providers that take their own screenshots as raw pixels (Orgo's desktop).
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { crc32, deflate } from "node:zlib";
|
|
4
|
+
/** zlib's deflate on its thread pool: a screen's deflate never holds this process's event loop. */
|
|
5
|
+
const deflateAsync = promisify(deflate);
|
|
6
|
+
/** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. The rows are deflated off the event loop: a
|
|
7
|
+
* 1080x2400 screen took about 170 ms, every request of the server this harness runs in waiting on it. */
|
|
8
|
+
export async function encodePng(rgba, width, [x, y, w, h]) {
|
|
9
|
+
const rows = Buffer.alloc((w * 4 + 1) * h);
|
|
10
|
+
for (let row = 0; row < h; row++) {
|
|
11
|
+
const from = ((y + row) * width + x) * 4;
|
|
12
|
+
rgba.copy(rows, row * (w * 4 + 1) + 1, from, from + w * 4);
|
|
13
|
+
}
|
|
14
|
+
const chunk = (type, data) => {
|
|
15
|
+
const length = Buffer.alloc(4);
|
|
16
|
+
length.writeUInt32BE(data.length);
|
|
17
|
+
const typed = Buffer.concat([Buffer.from(type, "latin1"), data]);
|
|
18
|
+
const crc = Buffer.alloc(4);
|
|
19
|
+
crc.writeUInt32BE(crc32(typed) >>> 0);
|
|
20
|
+
return Buffer.concat([length, typed, crc]);
|
|
21
|
+
};
|
|
22
|
+
const ihdr = Buffer.alloc(13);
|
|
23
|
+
ihdr.writeUInt32BE(w, 0);
|
|
24
|
+
ihdr.writeUInt32BE(h, 4);
|
|
25
|
+
ihdr.set([8, 6, 0, 0, 0], 8);
|
|
26
|
+
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))]);
|
|
27
|
+
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type ComputerOs = "linux" | "windows" | "macos" | "android" | "ios";
|
|
|
33
33
|
* provider's, not computerd's: cdp a browser's CDP target (ComputerConnection.cdp), stream a live view of the screen
|
|
34
34
|
* (provider.stream()), downloads the files a browser saved; a daemon's hello never lists them.
|
|
35
35
|
*/
|
|
36
|
-
export type Group = "exec" | "files" | "processes" | "screen" | "input.pointer" | "input.keys" | "input.touch" | "apps" | "apps.install" | "
|
|
36
|
+
export type Group = "exec" | "files" | "processes" | "screen" | "input.pointer" | "input.keys" | "input.touch" | "apps" | "apps.install" | "ui" | "cdp" | "stream" | "downloads";
|
|
37
37
|
/** Every group, in the order the protocol lists them. */
|
|
38
38
|
export declare const GROUPS: readonly Group[];
|
|
39
39
|
/** The groups a provider answers itself, which a computerd hello never lists. */
|
|
@@ -44,7 +44,7 @@ export declare const PROVIDER_GROUPS: readonly Group[];
|
|
|
44
44
|
* each release: a minor step adds (a method, an optional field, a group), a major one changes or removes. computerd's
|
|
45
45
|
* Go constant (methods.ProtocolVersion) holds the same value, and a test keeps them equal.
|
|
46
46
|
*/
|
|
47
|
-
export declare const PROTOCOL_VERSION = "0.
|
|
47
|
+
export declare const PROTOCOL_VERSION = "0.2";
|
|
48
48
|
export interface HelloParams {
|
|
49
49
|
/** Who is asking, for the daemon's log: a name and version. */
|
|
50
50
|
client: string;
|
|
@@ -56,8 +56,8 @@ export interface HelloResult {
|
|
|
56
56
|
version: string;
|
|
57
57
|
os: ComputerOs;
|
|
58
58
|
/**
|
|
59
|
-
* The OS's own version as the computer says it
|
|
60
|
-
*
|
|
59
|
+
* The OS's own version as the computer says it, with its build or API level when the driver knows it: "15",
|
|
60
|
+
* "15 (API 35)", "26.1 (25B78)". Absent where the computer does not say one.
|
|
61
61
|
*/
|
|
62
62
|
osVersion?: string;
|
|
63
63
|
kind: ComputerKind;
|
|
@@ -68,7 +68,51 @@ export interface HelloResult {
|
|
|
68
68
|
display?: string;
|
|
69
69
|
/** How init holds its programs off the computer's network, when it gave them one of their own (init --own-network). */
|
|
70
70
|
fence?: NetworkFence;
|
|
71
|
+
/** The main screen, in points. Absent on a computer with no screen. */
|
|
72
|
+
screen?: ScreenSize;
|
|
73
|
+
/**
|
|
74
|
+
* What this computer's groups can and cannot do here, by the names in FEATURES. A feature that is off says why, in
|
|
75
|
+
* words a person can act on. A feature not listed is not offered, but for screen.capture, which a computer of the
|
|
76
|
+
* screen group lists when it can be off. A caller ignores a name it does not know.
|
|
77
|
+
*/
|
|
78
|
+
features?: Features;
|
|
79
|
+
/** The machine, for a person and a run's record: "Apple", "MacBook Pro"; "Google", "Pixel 9". */
|
|
80
|
+
device?: Device;
|
|
81
|
+
}
|
|
82
|
+
/** What the machine is, the same fields on every OS. Its CPU is hello's arch, its OS's version hello's osVersion. */
|
|
83
|
+
export interface Device {
|
|
84
|
+
maker: string;
|
|
85
|
+
model: string;
|
|
86
|
+
}
|
|
87
|
+
/** A screen's size in points, and how many pixels a point holds (2 on a Retina Mac, 2.625 on many phones, 1 on Xvfb). */
|
|
88
|
+
export interface ScreenSize {
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
scale: number;
|
|
92
|
+
}
|
|
93
|
+
/** A feature that is off, and why: "Screen Recording is not granted to Computerd". */
|
|
94
|
+
export interface FeatureOff {
|
|
95
|
+
off: string;
|
|
96
|
+
}
|
|
97
|
+
export interface Features {
|
|
98
|
+
[feature: string]: true | FeatureOff;
|
|
71
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The features a computer may list in hello.features, and what each one means. The names say what, never which OS:
|
|
102
|
+
* a driver on any OS lists the same names, and says in the off reason what its OS is missing.
|
|
103
|
+
*/
|
|
104
|
+
export declare const FEATURES: {
|
|
105
|
+
readonly "screen.capture": "screen.shot and screen.watch capture the whole screen; a computer of the screen group that does not list it captures it, and one that lists it off refuses both with its reason (a Mac whose owner has not granted the server it is paired with the screen)";
|
|
106
|
+
readonly "screen.ahead": "screen.watch takes an after one past the newest frame, an ask ahead that waits for the frame after the one the ask before it answers: a caller keeps two asks in flight, and frames come at the computer's pace, not one each round trip";
|
|
107
|
+
readonly "apps.background": "apps.launch with background: true opens an app without bringing it to the front";
|
|
108
|
+
readonly "ui.tree": "ui.observe reads the window's elements; off, it answers the window's image with no nodes (ui.image on) or is refused";
|
|
109
|
+
readonly "ui.image": "ui.observe returns the window's image";
|
|
110
|
+
readonly "ui.background": "steps run as input posted to the app itself: the user's pointer and focus stay where they are";
|
|
111
|
+
readonly "ui.foreground": "steps run as the computer's own input, which moves the pointer and the focus (only when a call allows it)";
|
|
112
|
+
readonly "ui.page": "steps in a web page run through the page itself, by the browser's DevTools or its scripting";
|
|
113
|
+
readonly "ui.nav": "the nav step: back, home and app_switch";
|
|
114
|
+
};
|
|
115
|
+
export type Feature = keyof typeof FEATURES;
|
|
72
116
|
/**
|
|
73
117
|
* How init holds its programs off the computer's network: "netns", a network namespace init made itself as root;
|
|
74
118
|
* "userns-netns", one it made inside a user namespace of its own, where root may not make one (gVisor, whose root holds
|
|
@@ -361,7 +405,10 @@ export interface ProcessWaitParams {
|
|
|
361
405
|
timeoutMs: number;
|
|
362
406
|
}
|
|
363
407
|
export type Empty = Record<string, never>;
|
|
364
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* In screen and input, pixels of the full screenshot, origin top left (a region shot never changes this space). In ui,
|
|
410
|
+
* the window's points, origin at its top left.
|
|
411
|
+
*/
|
|
365
412
|
export type Point = [x: number, y: number];
|
|
366
413
|
export type Rect = [x: number, y: number, w: number, h: number];
|
|
367
414
|
export type Button = "left" | "right" | "middle";
|
|
@@ -400,7 +447,9 @@ export interface ScreenReadResult {
|
|
|
400
447
|
}
|
|
401
448
|
/**
|
|
402
449
|
* The live view's frames (screen.watch): the next frame after the caller's ack, once the screen changed. `after` is
|
|
403
|
-
* the seq of the last frame the caller has whole, 0 for none; an older one gets the newest frame at once.
|
|
450
|
+
* the seq of the last frame the caller has whole, 0 for none; an older one gets the newest frame at once. On a computer
|
|
451
|
+
* that lists screen.ahead, `after` may be one past the newest frame: an ask ahead, which waits as an ask for the newest
|
|
452
|
+
* does.
|
|
404
453
|
*/
|
|
405
454
|
export interface ScreenWatchParams {
|
|
406
455
|
after: number;
|
|
@@ -542,37 +591,244 @@ export interface AppsInstallParams {
|
|
|
542
591
|
/** A file already in the computer (files.write first). */
|
|
543
592
|
path: string;
|
|
544
593
|
}
|
|
545
|
-
/** apps.launch and apps.terminate. */
|
|
546
594
|
export interface AppsLaunchParams {
|
|
595
|
+
/** A bundle id or a package name: "com.apple.Notes", "com.android.settings". */
|
|
596
|
+
id: string;
|
|
597
|
+
/** Open this in the app: a deep link, or a page in a browser. */
|
|
598
|
+
url?: string;
|
|
599
|
+
/** Open it without bringing it to the front (feature apps.background). Without the feature, refused as `unsupported`. */
|
|
600
|
+
background?: boolean;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* The longest apps.launch waits for the app's window: it answers once the app has one, so an observe right after it
|
|
604
|
+
* finds the window, or fails timeout naming the app when none came in this long.
|
|
605
|
+
*/
|
|
606
|
+
export declare const LAUNCH_WINDOW_MS = 10000;
|
|
607
|
+
export interface AppsTerminateParams {
|
|
547
608
|
id: string;
|
|
548
609
|
}
|
|
549
|
-
/** The most nodes
|
|
610
|
+
/** The most nodes one ui.observe returns. */
|
|
550
611
|
export declare const MAX_UI_NODES = 5000;
|
|
612
|
+
/** The most steps one ui.act holds. */
|
|
613
|
+
export declare const MAX_STEPS = 100;
|
|
614
|
+
/** The longest an expect waits; it waits DEFAULT_EXPECT_MS when it names no timeoutMs. */
|
|
615
|
+
export declare const MAX_EXPECT_MS = 60000;
|
|
616
|
+
export declare const DEFAULT_EXPECT_MS = 5000;
|
|
617
|
+
/** The longest a driver waits for a window to settle after the steps, before it answers anyway. */
|
|
618
|
+
export declare const MAX_SETTLE_MS = 3000;
|
|
619
|
+
/**
|
|
620
|
+
* How long a set's value must hold once the act settled: a driver reads it again this long after, and a value the app
|
|
621
|
+
* took back (a field that rejects it, a switch that springs back) answers verified false.
|
|
622
|
+
*/
|
|
623
|
+
export declare const SET_HOLD_MS = 500;
|
|
624
|
+
/** An observe image's longest edge, in pixels: at least MIN_IMAGE_EDGE, at most MAX_IMAGE_EDGE, DEFAULT_IMAGE_EDGE when not given. */
|
|
625
|
+
export declare const MIN_IMAGE_EDGE = 256;
|
|
626
|
+
export declare const MAX_IMAGE_EDGE = 2048;
|
|
627
|
+
export declare const DEFAULT_IMAGE_EDGE = 1568;
|
|
628
|
+
/**
|
|
629
|
+
* The roles a node may have: ARIA's names, which a driver maps its platform's roles onto (AXButton and
|
|
630
|
+
* android.widget.Button are both "button"). A role it cannot map is "generic".
|
|
631
|
+
*/
|
|
632
|
+
export declare const UI_ROLES: readonly ["window", "dialog", "menu", "menuitem", "toolbar", "tab", "button", "link", "textbox", "searchbox", "checkbox", "radio", "switch", "slider", "combobox", "progressbar", "list", "listitem", "table", "row", "cell", "scrollarea", "image", "text", "heading", "group", "generic"];
|
|
633
|
+
export type UiRole = (typeof UI_ROLES)[number];
|
|
634
|
+
/**
|
|
635
|
+
* A driver's name for one element, such as "@e12". It stays good while its element exists, across states and steps;
|
|
636
|
+
* once the element is gone, a step naming it is refused as `stale`. Refs are opaque and start with "@".
|
|
637
|
+
*/
|
|
638
|
+
export type UiRef = string;
|
|
639
|
+
/** Which app and window. A bundle id or package name, and a window id from ui.observe. Omitted: the app in front, its main window. */
|
|
640
|
+
export interface UiTarget {
|
|
641
|
+
app?: string;
|
|
642
|
+
window?: string;
|
|
643
|
+
}
|
|
644
|
+
/** What a node's flags may say. secure: a password field, whose value is never sent. offscreen: in the tree, scrolled out of view. */
|
|
645
|
+
export declare const UI_FLAGS: readonly ["focused", "disabled", "selected", "checked", "secure", "offscreen"];
|
|
646
|
+
export type UiFlag = (typeof UI_FLAGS)[number];
|
|
551
647
|
export interface UiNode {
|
|
552
|
-
|
|
553
|
-
role:
|
|
554
|
-
/**
|
|
648
|
+
ref: UiRef;
|
|
649
|
+
role: UiRole;
|
|
650
|
+
/** What a person reads it as: its label, title or text. */
|
|
651
|
+
name?: string;
|
|
652
|
+
/** What it holds: a text field's text, a slider's value. A secure field's value is never sent. */
|
|
653
|
+
value?: string;
|
|
654
|
+
/** What else it says, beside its name: a row's secondary text ("Mobile, Wi-Fi, hotspot"), a help tag. */
|
|
655
|
+
desc?: string;
|
|
656
|
+
/** The app's own name for it, when it has one: an Android resource-id, a macOS accessibility identifier. */
|
|
555
657
|
id?: string;
|
|
556
|
-
/**
|
|
557
|
-
text?: string;
|
|
558
|
-
/** content-desc or accessibilityLabel. */
|
|
559
|
-
label?: string;
|
|
560
|
-
/** In screenshot pixels (iOS points times scale). */
|
|
658
|
+
/** In window points. */
|
|
561
659
|
bounds: Rect;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
|
|
660
|
+
/** The nearest node above it in this list; absent at the top. A node comes after its parent. */
|
|
661
|
+
parent?: UiRef;
|
|
662
|
+
flags?: UiFlag[];
|
|
663
|
+
/** The platform's own action names, for the perform step: "AXShowMenu", "ACTION_LONG_CLICK". */
|
|
664
|
+
actions?: string[];
|
|
665
|
+
}
|
|
666
|
+
export interface UiObserveParams {
|
|
667
|
+
target?: UiTarget;
|
|
668
|
+
/** Every node. Without it, only the nodes that can be acted on or that have a name, and their parents. */
|
|
669
|
+
full?: boolean;
|
|
670
|
+
/** The window's image (feature ui.image), true at DEFAULT_IMAGE_EDGE. Without the feature, refused as `unsupported`. */
|
|
671
|
+
image?: boolean | {
|
|
672
|
+
maxEdge: number;
|
|
673
|
+
};
|
|
674
|
+
/** A state this connection observed before: the result says what changed since it. */
|
|
675
|
+
since?: string;
|
|
676
|
+
}
|
|
677
|
+
/** A window's image, whole: at most MAX_CHUNK_BYTES before base64 (the driver lowers JPEG quality until it fits). */
|
|
678
|
+
export interface UiImage {
|
|
679
|
+
format: "png" | "jpeg";
|
|
680
|
+
/** Pixels. The image covers the window: a pixel is window.bounds' width / width points. */
|
|
681
|
+
width: number;
|
|
682
|
+
height: number;
|
|
683
|
+
/** base64. */
|
|
684
|
+
data: string;
|
|
685
|
+
}
|
|
686
|
+
/** One window of an app. */
|
|
687
|
+
export interface UiWindow {
|
|
688
|
+
id: string;
|
|
689
|
+
title?: string;
|
|
690
|
+
/** What it is, by the node roles: "dialog" for a sheet, an alert or a panel. Absent: "window". */
|
|
691
|
+
role?: UiRole;
|
|
692
|
+
/** In screen points: where the window sits. */
|
|
693
|
+
bounds: Rect;
|
|
694
|
+
}
|
|
695
|
+
export interface UiObserveResult {
|
|
696
|
+
/** This observation's id, such as "s7". A step's points are read against the state they came from. */
|
|
697
|
+
state: string;
|
|
698
|
+
app: {
|
|
699
|
+
id: string;
|
|
700
|
+
name: string;
|
|
701
|
+
pid?: number;
|
|
702
|
+
};
|
|
703
|
+
window: UiWindow;
|
|
704
|
+
/** In order, a node after its parent. */
|
|
705
|
+
nodes: UiNode[];
|
|
706
|
+
/** Against since, by ref. Absent when since was not given or the driver no longer holds it. */
|
|
707
|
+
diff?: {
|
|
708
|
+
added: UiRef[];
|
|
709
|
+
removed: UiRef[];
|
|
710
|
+
changed: UiRef[];
|
|
711
|
+
};
|
|
712
|
+
image?: UiImage;
|
|
713
|
+
/**
|
|
714
|
+
* Why nodes is empty though the window is not: the tree is off here (feature ui.tree), in words. The result then
|
|
715
|
+
* carries the window's image, asked for or not, so a caller can still act at points.
|
|
716
|
+
*/
|
|
717
|
+
empty?: string;
|
|
718
|
+
/** Nodes were left out: past MAX_UI_NODES, or to keep the reply within the line limit. */
|
|
574
719
|
truncated: boolean;
|
|
575
720
|
}
|
|
721
|
+
/** The ways a driver can make a step happen, best first. A step's result says which one ran. */
|
|
722
|
+
export type UiRoute = "semantic" | "page" | "background" | "foreground";
|
|
723
|
+
/**
|
|
724
|
+
* One action. A step that names a ref acts on its element; a step at a point needs the act's state, and is refused as
|
|
725
|
+
* `stale` when what is under the point is no longer what that state saw.
|
|
726
|
+
*/
|
|
727
|
+
export type UiStep =
|
|
728
|
+
/** The element's default action: AXPress, a click on Android's node. */
|
|
729
|
+
{
|
|
730
|
+
press: UiRef;
|
|
731
|
+
}
|
|
732
|
+
/** Set its value: a text field's text, a slider's value, a switch's "on" or "off". */
|
|
733
|
+
| {
|
|
734
|
+
set: UiRef;
|
|
735
|
+
value: string;
|
|
736
|
+
}
|
|
737
|
+
/** One of its actions, by the platform's name. */
|
|
738
|
+
| {
|
|
739
|
+
perform: UiRef;
|
|
740
|
+
action: string;
|
|
741
|
+
}
|
|
742
|
+
/** On a touch screen, a tap; button right is a long press there. */
|
|
743
|
+
| {
|
|
744
|
+
click: UiRef | Point;
|
|
745
|
+
button?: "left" | "right";
|
|
746
|
+
count?: 1 | 2 | 3;
|
|
747
|
+
}
|
|
748
|
+
/** Type text, into the element when named, else where the focus is. */
|
|
749
|
+
| {
|
|
750
|
+
type: string;
|
|
751
|
+
into?: UiRef;
|
|
752
|
+
}
|
|
753
|
+
/** A chord: names in KEYS or one printable character, joined by "+", the last of which may be "+" itself: "super+s", "enter", "ctrl+shift+t", "shift++". */
|
|
754
|
+
| {
|
|
755
|
+
key: string;
|
|
756
|
+
}
|
|
757
|
+
/** The system's own navigation (feature ui.nav). */
|
|
758
|
+
| {
|
|
759
|
+
nav: "back" | "home" | "app_switch";
|
|
760
|
+
}
|
|
761
|
+
/** Scroll the element, or what is at the point, by points: dy > 0 shows what is below, dx > 0 what is right. */
|
|
762
|
+
| {
|
|
763
|
+
scroll: UiRef | Point;
|
|
764
|
+
dx?: number;
|
|
765
|
+
dy?: number;
|
|
766
|
+
}
|
|
767
|
+
/** Press at the first point, move through the rest, let go at the last: 2 or more points, over ms. */
|
|
768
|
+
| {
|
|
769
|
+
drag: Point[];
|
|
770
|
+
ms?: number;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* What the caller expects to see once the steps ran, checked on the computer against the whole window, polled until
|
|
774
|
+
* it holds or timeoutMs passes. text: some node's name or value holds it. ref: the element exists. Both: that element's
|
|
775
|
+
* name or value holds the text. window: the act's app shows a window that matches it (its main one), whose state the
|
|
776
|
+
* act then answers. gone: the opposite of each. One of text and ref (or both), or window alone.
|
|
777
|
+
*/
|
|
778
|
+
export interface UiExpect {
|
|
779
|
+
text?: string;
|
|
780
|
+
ref?: UiRef;
|
|
781
|
+
/** A window of the act's app: its title holds title, and its role is role. At least one of the two. */
|
|
782
|
+
window?: {
|
|
783
|
+
title?: string;
|
|
784
|
+
role?: UiRole;
|
|
785
|
+
};
|
|
786
|
+
gone?: boolean;
|
|
787
|
+
/** Default DEFAULT_EXPECT_MS, at most MAX_EXPECT_MS. */
|
|
788
|
+
timeoutMs?: number;
|
|
789
|
+
}
|
|
790
|
+
export interface UiActParams {
|
|
791
|
+
/** Where keys and typing without a ref go. Default: the state's app and window, else the app in front. */
|
|
792
|
+
target?: UiTarget;
|
|
793
|
+
/** The state the steps' points were read from. A step at a point needs it. */
|
|
794
|
+
state?: string;
|
|
795
|
+
/** At most MAX_STEPS; their drag ms add up to at most MAX_BATCH_WAIT_MS. No steps and an expect is a wait. */
|
|
796
|
+
steps: UiStep[];
|
|
797
|
+
expect?: UiExpect;
|
|
798
|
+
/** Let steps take the foreground route, which moves the user's pointer and focus. Default false. */
|
|
799
|
+
foreground?: boolean;
|
|
800
|
+
}
|
|
801
|
+
export type UiStepResult =
|
|
802
|
+
/** It ran by this route; verified when a readback showed it took (the value set, the element pressed). */
|
|
803
|
+
{
|
|
804
|
+
route: UiRoute;
|
|
805
|
+
verified: boolean;
|
|
806
|
+
}
|
|
807
|
+
/** It was refused: stale, denied (a secure field, an app the call may not touch), unsupported (with the feature's off reason). */
|
|
808
|
+
| {
|
|
809
|
+
error: {
|
|
810
|
+
kind: DaemonErrorKind;
|
|
811
|
+
message: string;
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
export interface UiActResult {
|
|
815
|
+
/** One per step tried, in order. A refused step is the last: the steps after it do not run. */
|
|
816
|
+
steps: UiStepResult[];
|
|
817
|
+
/** The state after the steps, once the window settled (at most MAX_SETTLE_MS). Absent when window is "closed". */
|
|
818
|
+
state?: string;
|
|
819
|
+
/**
|
|
820
|
+
* "closed": a step closed the act's window and its app has no window left (super+w on the last one), so there is no
|
|
821
|
+
* state to answer. The steps that ran keep their results. Absent while the act has a window.
|
|
822
|
+
*/
|
|
823
|
+
window?: "closed";
|
|
824
|
+
/**
|
|
825
|
+
* Whether the window changed between before the first step and the settled state: its nodes, or its image when it
|
|
826
|
+
* has no nodes. True when the window closed.
|
|
827
|
+
*/
|
|
828
|
+
changed: boolean;
|
|
829
|
+
/** Whether the expect held in time. Absent with no expect, or when a step was refused. */
|
|
830
|
+
expect?: "met" | "unmet";
|
|
831
|
+
}
|
|
576
832
|
/** Moves init's own deadline. Init refuses an earlier one. Typed now; the daemon answers it from the X11 shim's PR on. */
|
|
577
833
|
export interface DeadlineExtendParams {
|
|
578
834
|
/** ISO time. */
|
|
@@ -714,12 +970,16 @@ export interface DaemonMethods {
|
|
|
714
970
|
result: Empty;
|
|
715
971
|
};
|
|
716
972
|
"apps.terminate": {
|
|
717
|
-
params:
|
|
973
|
+
params: AppsTerminateParams;
|
|
718
974
|
result: Empty;
|
|
719
975
|
};
|
|
720
|
-
"
|
|
721
|
-
params:
|
|
722
|
-
result:
|
|
976
|
+
"ui.observe": {
|
|
977
|
+
params: UiObserveParams;
|
|
978
|
+
result: UiObserveResult;
|
|
979
|
+
};
|
|
980
|
+
"ui.act": {
|
|
981
|
+
params: UiActParams;
|
|
982
|
+
result: UiActResult;
|
|
723
983
|
};
|
|
724
984
|
"deadline.extend": {
|
|
725
985
|
params: DeadlineExtendParams;
|
|
@@ -731,6 +991,48 @@ export interface DaemonMethods {
|
|
|
731
991
|
};
|
|
732
992
|
}
|
|
733
993
|
export type DaemonMethod = keyof DaemonMethods;
|
|
994
|
+
/**
|
|
995
|
+
* Every daemon method, as a value: what a caller checks a method name against at run time (serve refuses a call to a
|
|
996
|
+
* method the protocol doesn't have before it reaches a computer). `satisfies` keeps it equal to DaemonMethods: a method
|
|
997
|
+
* added there and not here, or here and not there, fails the build.
|
|
998
|
+
*/
|
|
999
|
+
export declare const DAEMON_METHODS: {
|
|
1000
|
+
hello: true;
|
|
1001
|
+
ping: true;
|
|
1002
|
+
"exec.run": true;
|
|
1003
|
+
"files.read": true;
|
|
1004
|
+
"files.write": true;
|
|
1005
|
+
"files.stat": true;
|
|
1006
|
+
"files.list": true;
|
|
1007
|
+
"files.mkdir": true;
|
|
1008
|
+
"files.move": true;
|
|
1009
|
+
"files.remove": true;
|
|
1010
|
+
"tar.pull.begin": true;
|
|
1011
|
+
"tar.pull.read": true;
|
|
1012
|
+
"tar.pull.end": true;
|
|
1013
|
+
"tar.push.begin": true;
|
|
1014
|
+
"tar.push.write": true;
|
|
1015
|
+
"tar.push.end": true;
|
|
1016
|
+
"process.start": true;
|
|
1017
|
+
"process.read": true;
|
|
1018
|
+
"process.write": true;
|
|
1019
|
+
"process.signal": true;
|
|
1020
|
+
"process.resize": true;
|
|
1021
|
+
"process.list": true;
|
|
1022
|
+
"process.wait": true;
|
|
1023
|
+
"screen.shot": true;
|
|
1024
|
+
"screen.read": true;
|
|
1025
|
+
"screen.watch": true;
|
|
1026
|
+
"input.actions": true;
|
|
1027
|
+
"apps.list": true;
|
|
1028
|
+
"apps.install": true;
|
|
1029
|
+
"apps.launch": true;
|
|
1030
|
+
"apps.terminate": true;
|
|
1031
|
+
"ui.observe": true;
|
|
1032
|
+
"ui.act": true;
|
|
1033
|
+
"deadline.extend": true;
|
|
1034
|
+
"mount.sync": true;
|
|
1035
|
+
};
|
|
734
1036
|
/**
|
|
735
1037
|
* What answers a computer's methods: computerd over a stream (DaemonClient), or, with daemon none, the provider in
|
|
736
1038
|
* process. Callers and the conformance suite see one surface.
|
|
@@ -743,7 +1045,11 @@ export interface ComputerClient {
|
|
|
743
1045
|
close(): void;
|
|
744
1046
|
}
|
|
745
1047
|
/** error.data.kind in the daemon's error replies. */
|
|
746
|
-
export type DaemonErrorKind = "not_found" | "invalid" | "timeout" | "aborted" | "denied" | "limit" | "unsupported" | "exists" | "not_dir" | "is_dir"
|
|
1048
|
+
export type DaemonErrorKind = "not_found" | "invalid" | "timeout" | "aborted" | "denied" | "limit" | "unsupported" | "exists" | "not_dir" | "is_dir"
|
|
1049
|
+
/** A ref whose element is gone, or a point whose window moved or redrew under it since its state. */
|
|
1050
|
+
| "stale"
|
|
1051
|
+
/** The call exists, but this value or state is not one it serves: a step on a disabled control. */
|
|
1052
|
+
| "refused";
|
|
747
1053
|
export declare const JSONRPC_CODES: {
|
|
748
1054
|
readonly parse: -32700;
|
|
749
1055
|
readonly invalidRequest: -32600;
|
package/dist/protocol.js
CHANGED
|
@@ -23,7 +23,7 @@ export const PROCESS_RETAINED_BYTES = 256 * 1024 * 1024;
|
|
|
23
23
|
/** The longest a process.read waits for new bytes. */
|
|
24
24
|
export const MAX_READ_WAIT_MS = 30_000;
|
|
25
25
|
/** Every group, in the order the protocol lists them. */
|
|
26
|
-
export const GROUPS = ["exec", "files", "processes", "screen", "input.pointer", "input.keys", "input.touch", "apps", "apps.install", "
|
|
26
|
+
export const GROUPS = ["exec", "files", "processes", "screen", "input.pointer", "input.keys", "input.touch", "apps", "apps.install", "ui", "cdp", "stream", "downloads"];
|
|
27
27
|
/** The groups a provider answers itself, which a computerd hello never lists. */
|
|
28
28
|
export const PROVIDER_GROUPS = ["cdp", "stream", "downloads"];
|
|
29
29
|
/**
|
|
@@ -32,7 +32,22 @@ export const PROVIDER_GROUPS = ["cdp", "stream", "downloads"];
|
|
|
32
32
|
* each release: a minor step adds (a method, an optional field, a group), a major one changes or removes. computerd's
|
|
33
33
|
* Go constant (methods.ProtocolVersion) holds the same value, and a test keeps them equal.
|
|
34
34
|
*/
|
|
35
|
-
export const PROTOCOL_VERSION = "0.
|
|
35
|
+
export const PROTOCOL_VERSION = "0.2";
|
|
36
|
+
/**
|
|
37
|
+
* The features a computer may list in hello.features, and what each one means. The names say what, never which OS:
|
|
38
|
+
* a driver on any OS lists the same names, and says in the off reason what its OS is missing.
|
|
39
|
+
*/
|
|
40
|
+
export const FEATURES = {
|
|
41
|
+
"screen.capture": "screen.shot and screen.watch capture the whole screen; a computer of the screen group that does not list it captures it, and one that lists it off refuses both with its reason (a Mac whose owner has not granted the server it is paired with the screen)",
|
|
42
|
+
"screen.ahead": "screen.watch takes an after one past the newest frame, an ask ahead that waits for the frame after the one the ask before it answers: a caller keeps two asks in flight, and frames come at the computer's pace, not one each round trip",
|
|
43
|
+
"apps.background": "apps.launch with background: true opens an app without bringing it to the front",
|
|
44
|
+
"ui.tree": "ui.observe reads the window's elements; off, it answers the window's image with no nodes (ui.image on) or is refused",
|
|
45
|
+
"ui.image": "ui.observe returns the window's image",
|
|
46
|
+
"ui.background": "steps run as input posted to the app itself: the user's pointer and focus stay where they are",
|
|
47
|
+
"ui.foreground": "steps run as the computer's own input, which moves the pointer and the focus (only when a call allows it)",
|
|
48
|
+
"ui.page": "steps in a web page run through the page itself, by the browser's DevTools or its scripting",
|
|
49
|
+
"ui.nav": "the nav step: back, home and app_switch",
|
|
50
|
+
};
|
|
36
51
|
/** Every NetworkFence, as hello may report it. */
|
|
37
52
|
export const NETWORK_FENCES = ["netns", "userns-netns"];
|
|
38
53
|
/** The most actions one input.actions batch holds. */
|
|
@@ -51,8 +66,87 @@ export const KEYS = [
|
|
|
51
66
|
"f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12",
|
|
52
67
|
"shift", "ctrl", "alt", "super", "capslock",
|
|
53
68
|
];
|
|
54
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* The longest apps.launch waits for the app's window: it answers once the app has one, so an observe right after it
|
|
71
|
+
* finds the window, or fails timeout naming the app when none came in this long.
|
|
72
|
+
*/
|
|
73
|
+
export const LAUNCH_WINDOW_MS = 10_000;
|
|
74
|
+
// --- ui: eyes and hands with meaning --------------------------------------------------------------------------------
|
|
75
|
+
// One app's window, seen as named elements (ui.observe) and acted on by short lists of steps (ui.act). Every coordinate
|
|
76
|
+
// in this group is in the window's points, origin at the window's top left. A driver of ours answers it; a computer
|
|
77
|
+
// without one keeps screen and input.
|
|
78
|
+
/** The most nodes one ui.observe returns. */
|
|
55
79
|
export const MAX_UI_NODES = 5000;
|
|
80
|
+
/** The most steps one ui.act holds. */
|
|
81
|
+
export const MAX_STEPS = 100;
|
|
82
|
+
/** The longest an expect waits; it waits DEFAULT_EXPECT_MS when it names no timeoutMs. */
|
|
83
|
+
export const MAX_EXPECT_MS = 60_000;
|
|
84
|
+
export const DEFAULT_EXPECT_MS = 5_000;
|
|
85
|
+
/** The longest a driver waits for a window to settle after the steps, before it answers anyway. */
|
|
86
|
+
export const MAX_SETTLE_MS = 3_000;
|
|
87
|
+
/**
|
|
88
|
+
* How long a set's value must hold once the act settled: a driver reads it again this long after, and a value the app
|
|
89
|
+
* took back (a field that rejects it, a switch that springs back) answers verified false.
|
|
90
|
+
*/
|
|
91
|
+
export const SET_HOLD_MS = 500;
|
|
92
|
+
/** An observe image's longest edge, in pixels: at least MIN_IMAGE_EDGE, at most MAX_IMAGE_EDGE, DEFAULT_IMAGE_EDGE when not given. */
|
|
93
|
+
export const MIN_IMAGE_EDGE = 256;
|
|
94
|
+
export const MAX_IMAGE_EDGE = 2048;
|
|
95
|
+
export const DEFAULT_IMAGE_EDGE = 1568;
|
|
96
|
+
/**
|
|
97
|
+
* The roles a node may have: ARIA's names, which a driver maps its platform's roles onto (AXButton and
|
|
98
|
+
* android.widget.Button are both "button"). A role it cannot map is "generic".
|
|
99
|
+
*/
|
|
100
|
+
export const UI_ROLES = [
|
|
101
|
+
"window", "dialog", "menu", "menuitem", "toolbar", "tab",
|
|
102
|
+
"button", "link", "textbox", "searchbox", "checkbox", "radio", "switch", "slider", "combobox", "progressbar",
|
|
103
|
+
"list", "listitem", "table", "row", "cell", "scrollarea",
|
|
104
|
+
"image", "text", "heading", "group", "generic",
|
|
105
|
+
];
|
|
106
|
+
/** What a node's flags may say. secure: a password field, whose value is never sent. offscreen: in the tree, scrolled out of view. */
|
|
107
|
+
export const UI_FLAGS = ["focused", "disabled", "selected", "checked", "secure", "offscreen"];
|
|
108
|
+
/**
|
|
109
|
+
* Every daemon method, as a value: what a caller checks a method name against at run time (serve refuses a call to a
|
|
110
|
+
* method the protocol doesn't have before it reaches a computer). `satisfies` keeps it equal to DaemonMethods: a method
|
|
111
|
+
* added there and not here, or here and not there, fails the build.
|
|
112
|
+
*/
|
|
113
|
+
export const DAEMON_METHODS = {
|
|
114
|
+
hello: true,
|
|
115
|
+
ping: true,
|
|
116
|
+
"exec.run": true,
|
|
117
|
+
"files.read": true,
|
|
118
|
+
"files.write": true,
|
|
119
|
+
"files.stat": true,
|
|
120
|
+
"files.list": true,
|
|
121
|
+
"files.mkdir": true,
|
|
122
|
+
"files.move": true,
|
|
123
|
+
"files.remove": true,
|
|
124
|
+
"tar.pull.begin": true,
|
|
125
|
+
"tar.pull.read": true,
|
|
126
|
+
"tar.pull.end": true,
|
|
127
|
+
"tar.push.begin": true,
|
|
128
|
+
"tar.push.write": true,
|
|
129
|
+
"tar.push.end": true,
|
|
130
|
+
"process.start": true,
|
|
131
|
+
"process.read": true,
|
|
132
|
+
"process.write": true,
|
|
133
|
+
"process.signal": true,
|
|
134
|
+
"process.resize": true,
|
|
135
|
+
"process.list": true,
|
|
136
|
+
"process.wait": true,
|
|
137
|
+
"screen.shot": true,
|
|
138
|
+
"screen.read": true,
|
|
139
|
+
"screen.watch": true,
|
|
140
|
+
"input.actions": true,
|
|
141
|
+
"apps.list": true,
|
|
142
|
+
"apps.install": true,
|
|
143
|
+
"apps.launch": true,
|
|
144
|
+
"apps.terminate": true,
|
|
145
|
+
"ui.observe": true,
|
|
146
|
+
"ui.act": true,
|
|
147
|
+
"deadline.extend": true,
|
|
148
|
+
"mount.sync": true,
|
|
149
|
+
};
|
|
56
150
|
export const JSONRPC_CODES = {
|
|
57
151
|
parse: -32700,
|
|
58
152
|
invalidRequest: -32600,
|