@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.37

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.
Files changed (121) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +321 -308
  3. package/box/build-agent37.mjs +177 -0
  4. package/dist/agent37.d.ts +165 -0
  5. package/dist/agent37.js +759 -0
  6. package/dist/attach.d.ts +146 -0
  7. package/dist/attach.js +469 -0
  8. package/dist/browserbase.d.ts +2 -4
  9. package/dist/browserbase.js +2 -1
  10. package/dist/client.d.ts +33 -1
  11. package/dist/client.js +53 -0
  12. package/dist/computerd-linux-amd64 +0 -0
  13. package/dist/computerd-linux-arm64 +0 -0
  14. package/dist/conformance/agent37.d.ts +96 -0
  15. package/dist/conformance/agent37.js +154 -0
  16. package/dist/conformance/cases/apps.d.ts +5 -0
  17. package/dist/conformance/cases/apps.js +160 -73
  18. package/dist/conformance/cases/health.js +14 -0
  19. package/dist/conformance/cases/index.js +2 -0
  20. package/dist/conformance/cases/provider.js +27 -1
  21. package/dist/conformance/cases/screen.d.ts +3 -0
  22. package/dist/conformance/cases/screen.js +18 -0
  23. package/dist/conformance/cases/settings.d.ts +29 -23
  24. package/dist/conformance/cases/settings.js +76 -58
  25. package/dist/conformance/cases/touch.js +19 -17
  26. package/dist/conformance/cases/ui.d.ts +2 -0
  27. package/dist/conformance/cases/ui.js +475 -0
  28. package/dist/conformance/cli.d.ts +9 -0
  29. package/dist/conformance/cli.js +28 -3
  30. package/dist/conformance/e2b.d.ts +6 -0
  31. package/dist/conformance/e2b.js +9 -2
  32. package/dist/conformance/fixture.d.ts +1 -1
  33. package/dist/conformance/fixture.js +25 -1
  34. package/dist/conformance/modal.d.ts +17 -13
  35. package/dist/conformance/modal.js +18 -9
  36. package/dist/conformance/orgo.d.ts +3 -3
  37. package/dist/conformance/orgo.js +6 -8
  38. package/dist/conformance/phone-harness.d.ts +6 -2
  39. package/dist/conformance/phone-harness.js +21 -4
  40. package/dist/conformance/report.js +1 -1
  41. package/dist/conformance/runner.js +23 -4
  42. package/dist/conformance/sweep.d.ts +50 -0
  43. package/dist/conformance/sweep.js +187 -0
  44. package/dist/conformance/types.d.ts +11 -3
  45. package/dist/conformance/ui-fixture.d.ts +56 -0
  46. package/dist/conformance/ui-fixture.js +43 -0
  47. package/dist/create-requests.d.ts +51 -0
  48. package/dist/create-requests.js +121 -0
  49. package/dist/daytona.d.ts +2 -4
  50. package/dist/daytona.js +3 -2
  51. package/dist/descriptor.d.ts +5 -0
  52. package/dist/descriptor.js +2 -0
  53. package/dist/descriptors/agent37.d.ts +41 -0
  54. package/dist/descriptors/agent37.js +28 -0
  55. package/dist/descriptors/index.d.ts +38 -2
  56. package/dist/descriptors/index.js +4 -2
  57. package/dist/descriptors/orgo.d.ts +2 -1
  58. package/dist/descriptors/orgo.js +3 -2
  59. package/dist/descriptors/phone-harness.d.ts +1 -1
  60. package/dist/descriptors/phone-harness.js +2 -2
  61. package/dist/docker.d.ts +7 -4
  62. package/dist/docker.js +271 -29
  63. package/dist/e2b.d.ts +9 -165
  64. package/dist/e2b.js +282 -1342
  65. package/dist/fake-ui-driver.d.ts +97 -0
  66. package/dist/fake-ui-driver.js +717 -0
  67. package/dist/host.d.ts +182 -0
  68. package/dist/host.js +1 -0
  69. package/dist/hosted/process.d.ts +67 -0
  70. package/dist/hosted/process.js +228 -0
  71. package/dist/hosted/provider.d.ts +146 -0
  72. package/dist/hosted/provider.js +1364 -0
  73. package/dist/hosted/scripts.d.ts +76 -0
  74. package/dist/{child.js → hosted/scripts.js} +93 -12
  75. package/dist/index.d.ts +7 -3
  76. package/dist/index.js +7 -4
  77. package/dist/kernel.d.ts +2 -4
  78. package/dist/kernel.js +2 -1
  79. package/dist/kinds.d.ts +8 -1
  80. package/dist/kinds.js +20 -4
  81. package/dist/local-chrome.d.ts +2 -4
  82. package/dist/local-chrome.js +2 -1
  83. package/dist/modal.d.ts +23 -181
  84. package/dist/modal.js +271 -1244
  85. package/dist/orgo-channel.d.ts +3 -2
  86. package/dist/orgo-channel.js +5 -2
  87. package/dist/orgo-desktop.d.ts +9 -4
  88. package/dist/orgo-desktop.js +33 -13
  89. package/dist/orgo-workspaces.d.ts +47 -0
  90. package/dist/orgo-workspaces.js +94 -0
  91. package/dist/orgo.d.ts +10 -4
  92. package/dist/orgo.js +30 -12
  93. package/dist/phone-harness.d.ts +31 -22
  94. package/dist/phone-harness.js +510 -698
  95. package/dist/png.d.ts +4 -0
  96. package/dist/png.js +27 -0
  97. package/dist/protocol.d.ts +335 -32
  98. package/dist/protocol.js +96 -3
  99. package/dist/provider.d.ts +34 -6
  100. package/dist/provider.js +16 -0
  101. package/dist/result.d.ts +1 -1
  102. package/dist/surface/api.d.ts +248 -0
  103. package/dist/surface/api.js +1 -0
  104. package/dist/surface/core.d.ts +42 -0
  105. package/dist/surface/core.js +393 -0
  106. package/dist/surface/index.d.ts +5 -0
  107. package/dist/surface/index.js +3 -0
  108. package/dist/surface/outline.d.ts +8 -0
  109. package/dist/surface/outline.js +50 -0
  110. package/dist/surface/script.d.ts +10 -0
  111. package/dist/surface/script.js +92 -0
  112. package/dist/ui-engine.d.ts +114 -0
  113. package/dist/ui-engine.js +798 -0
  114. package/package.json +17 -1
  115. package/dist/child.d.ts +0 -42
  116. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  117. package/dist/conformance/e2b-diagnose.js +0 -61
  118. package/dist/conformance/e2b-sweep.d.ts +0 -18
  119. package/dist/conformance/e2b-sweep.js +0 -132
  120. package/dist/conformance/modal-sweep.d.ts +0 -22
  121. package/dist/conformance/modal-sweep.js +0 -213
@@ -0,0 +1,76 @@
1
+ import type { ComputerCapabilities, ComputerConnection } from "../provider.js";
2
+ import { type Result } from "../result.js";
3
+ /** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
4
+ export declare function installerOf(output: string): string | undefined;
5
+ /** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
6
+ export declare const shellCommand: (script: string, args: readonly string[]) => string;
7
+ /** One argv as one shell line, every word but a plain one ("sh", "-c") single-quoted: for a vendor whose exec takes a line. */
8
+ export declare const shellLine: (argv: readonly string[]) => string;
9
+ /** Where start leaves what init writes, root's alone: the words a create that never hears the daemon gives back. */
10
+ export declare const INIT_LOG = "/run/agentrun-init.log";
11
+ /**
12
+ * Where a pid1 Archil computer's entrypoint waits for root's word that the run's folder is mounted: beside the daemon,
13
+ * in the directory install makes root's alone before root makes the gate, so no other user can make it early. (A path
14
+ * under /run would hang on an image without /run, or one whose /run another user can write.)
15
+ */
16
+ export declare const ARCHIL_GATE: string;
17
+ /** The scripts the adapter runs, each one argv (see the file's head). */
18
+ export interface HostedCommands {
19
+ install: string[];
20
+ /** child: init's start, detached; it answers once init is started. */
21
+ start: string[];
22
+ stdio: string[];
23
+ log: string[];
24
+ /** pid1: the machine's command. */
25
+ entrypoint: string[];
26
+ }
27
+ /**
28
+ * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
29
+ * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
30
+ * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
31
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for.
32
+ */
33
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, }?: ChildCommandOptions & {
34
+ atomic?: boolean;
35
+ waitS?: number;
36
+ gate?: string;
37
+ sha256?: string;
38
+ nonce?: string;
39
+ }): HostedCommands;
40
+ export interface ChildCommandOptions {
41
+ /** Where the vendor's upload left the daemon. */
42
+ staging?: string;
43
+ /** Init's deadline, an ISO time. */
44
+ deadline?: string;
45
+ /** Who the daemon becomes, uid:gid in numbers. */
46
+ user?: string;
47
+ /** The X display init's screen and input methods drive (its DISPLAY); none for a computer with no screen. */
48
+ display?: string;
49
+ /** The most deadline.extend may move the deadline to, an ISO time; none, and the deadline cannot move. */
50
+ maxDeadline?: string;
51
+ }
52
+ /**
53
+ * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
54
+ * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
55
+ * every argument quoted.
56
+ */
57
+ export declare function childCommands({ staging, deadline, user, display, maxDeadline }?: ChildCommandOptions): {
58
+ install: string;
59
+ init: string;
60
+ stdio: string;
61
+ };
62
+ export interface DaemonExpected {
63
+ version: string;
64
+ /** The uid and gid it runs as; with neither, any one user that is not root (a spec named it, and attach reads it back). */
65
+ uid?: string;
66
+ gid?: string;
67
+ arch: string;
68
+ kind: ComputerCapabilities["kind"];
69
+ groups: ComputerCapabilities["groups"];
70
+ }
71
+ /**
72
+ * What the daemon reports of itself, read back through it: hello, its credentials (no capability in any set,
73
+ * no_new_privs, no groups, a seccomp filter), its network (its own loopback alone, from its /proc/self/net/dev), its
74
+ * working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
75
+ */
76
+ export declare function daemonDrift(connection: ComputerConnection, expected: DaemonExpected, timeoutMs: number, signal?: AbortSignal): Promise<Result<string[]>>;
@@ -1,9 +1,12 @@
1
- // The daemon as a child: for a vendor whose own agent is the computer's first process (Daytona's toolbox, E2B's envd),
2
- // computerd goes in through the vendor's file upload and starts as a command that agent runs. These are the shell
3
- // commands such a provider sends, exactly, and the read-back of the daemon it started: the same for every such vendor.
4
- import { DAEMON_IN_COMPUTER, helloDrift, SOCKET_DIR, WORK } from "./drift.js";
5
- import { readOwnNetwork, TOOL_USER } from "./isolation.js";
6
- import { fail, ok } from "./result.js";
1
+ // The scripts the shared machine-host adapter (./provider.ts) sends into a machine, exactly, and the read-back of the
2
+ // daemon it started: the same for every vendor. A child host (the vendor's own agent is the machine's first process:
3
+ // E2B's envd, Daytona's toolbox) gets the daemon through its upload, installs it, and starts init detached (start);
4
+ // a pid1 host's machine runs the entrypoint as its main process, which waits for the daemon and becomes init. Every
5
+ // connection runs stdio. Each is one argv, `sh -c '<script>' sh <args>`; shellCommand gives it as one string for a
6
+ // vendor whose exec takes a shell line.
7
+ import { DAEMON_IN_COMPUTER, helloDrift, SOCKET_DIR, WORK } from "../drift.js";
8
+ import { readOwnNetwork, TOOL_USER } from "../isolation.js";
9
+ import { fail, ok } from "../result.js";
7
10
  const PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
8
11
  const CAPS = ["CapInh", "CapPrm", "CapEff", "CapBnd", "CapAmb"];
9
12
  /** Root for what follows: the command's own user when it is root, else passwordless sudo, which the install checked. */
@@ -22,14 +25,22 @@ const HELD = 'held() { x=$1; while :; do set -- $(ls -ldn "$x" 2>/dev/null); cas
22
25
  * image's is relied on. */
23
26
  const INSTALL_SCRIPT = [
24
27
  "# agentrun-computer: install",
25
- "s=$1; d=$2; h=$3; r=$4; b=${d%/*}",
28
+ // a: when set, the binary goes in beside its path and is moved into place last, so a pid1 entrypoint waiting for the
29
+ // path never starts one half written; e: when set too, the sha256 it must read before it is moved, so the entrypoint
30
+ // never starts one that is not the daemon uploaded; n: when set too, this create's nonce, written to the marker beside
31
+ // the daemon once it is in place, so the entrypoint starts the daemon this create installed and never one the image
32
+ // had there. (Not x: held() assigns x.)
33
+ "s=$1; d=$2; h=$3; r=$4; a=${5-}; e=${6-}; n=${7-}; b=${d%/*}; t=$d; [ -z \"$a\" ] || t=$d.part",
26
34
  'if [ "$(id -u)" = 0 ]; then p=; elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then p="sudo -n"; else echo "the sandbox user $(id -un) is not root and has no passwordless sudo, so the daemon cannot be installed"; exit 3; fi',
27
35
  HELD,
28
36
  '[ -d "${b%/*}" ] || $p mkdir -p -m 0755 "${b%/*}" || { echo "installing the daemon at $d failed"; exit 5; }',
29
37
  'held "${b%/*}" || exit 6',
30
38
  '[ ! -L "$b" ] || { echo "the daemon at $d is not root\'s alone: $b is a symbolic link"; exit 6; }',
31
- '$p mkdir -p "$b" "$h" "$r" && $p chown 0:0 "$b" && $p chmod 0755 "$b" && $p rm -f "$d" && $p install -m 0755 -o 0 -g 0 "$s" "$d" || { echo "installing the daemon at $d failed"; exit 5; }',
39
+ '$p mkdir -p "$b" "$h" "$r" && $p chown 0:0 "$b" && $p chmod 0755 "$b" && $p rm -f "$d" "$t" "$d.installed" && $p install -m 0755 -o 0 -g 0 "$s" "$t" || { echo "installing the daemon at $d failed"; exit 5; }',
40
+ 'if [ -n "$a" ] && [ -n "$e" ]; then w=$($p sha256sum "$t" | cut -c1-64); [ "$w" = "$e" ] || { echo "sha256 $w"; echo "the daemon written to $t reads sha256 $w, not $e, so it is not moved into place"; $p rm -f "$t"; exit 7; }; fi',
41
+ '[ "$t" = "$d" ] || $p mv -f "$t" "$d" || { echo "installing the daemon at $d failed"; exit 5; }',
32
42
  'held "$d" || exit 6',
43
+ `[ -z "$n" ] || { printf '%s\\n' "$n" | $p tee "$d.installed" >/dev/null; } || { echo "installing the daemon at $d failed: its marker was not written"; exit 5; }`,
33
44
  'rm -f "$s"',
34
45
  // Who installed it: the sandbox user's uid and name, and "sudo" when through passwordless sudo (installerOf).
35
46
  'echo "installer $(id -u) $(id -un 2>/dev/null || echo unnamed)${p:+ sudo}"',
@@ -67,6 +78,73 @@ const STDIO_SCRIPT = ["# agentrun-computer: stdio", "d=$1; r=$2", HELD, 'held "$
67
78
  const quote = (word) => `'${word.replaceAll("'", "'\\''")}'`;
68
79
  /** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
69
80
  export const shellCommand = (script, args) => ["sh", "-c", quote(script), "sh", ...args.map(quote)].join(" ");
81
+ /** One argv as one shell line, every word but a plain one ("sh", "-c") single-quoted: for a vendor whose exec takes a line. */
82
+ export const shellLine = (argv) => argv.map((word) => (/^[A-Za-z0-9_./:=@%+-]+$/.test(word) ? word : quote(word))).join(" ");
83
+ const argvOf = (script, args) => ["sh", "-c", script, "sh", ...args];
84
+ /** Where start leaves what init writes, root's alone: the words a create that never hears the daemon gives back. */
85
+ export const INIT_LOG = `${SOCKET_DIR}-init.log`;
86
+ /**
87
+ * Starts init detached from the call that starts it: in a session of its own (setsid), its output to the log, its stdin
88
+ * none, so the vendor's call ends at once and nothing of it holds init. As root, or through passwordless sudo.
89
+ */
90
+ const START_SCRIPT = ["# agentrun-computer: start", "l=$1; shift", ROOT, `exec $p sh -c 'exec >"$0" 2>&1 </dev/null; setsid "$@" &' "$l" "$@"`].join("\n");
91
+ /** The last words init wrote to its log, as root; nothing when it wrote none. */
92
+ const LOG_SCRIPT = ["# agentrun-computer: log", "l=$1", ROOT, '$p tail -c 2000 "$l" 2>/dev/null || true'].join("\n");
93
+ /**
94
+ * A pid1 machine's main process: waits, bounded, for the daemon this create installed to be moved into place executable
95
+ * (the marker beside it, `<daemon>.installed`, holds this create's nonce: a daemon the image had at the path, or one an
96
+ * earlier install left, has none, or another, and is never started), then becomes it with exec, so init is the machine's main process and the machine ends when init does. It starts init as start does a
97
+ * child's: from its home (HOME, and the working directory), with the display, when given, as its DISPLAY. POSIX sh and
98
+ * tools in BusyBox and coreutils alike; `date +%s` bounds the wait however long a sleep takes. An Archil computer's
99
+ * (`--gate <path>` before init's arguments) also waits for the gate, which root makes once the run's folder is mounted;
100
+ * a gate there before it starts (an image that holds one) is not this computer's, and goes first.
101
+ */
102
+ const ENTRYPOINT_SCRIPT = [
103
+ "# agentrun-computer: entrypoint",
104
+ // The display is v, as in init's script; empty for a computer with no screen. n is this create's nonce.
105
+ "d=$1; w=$2; h=$3; v=$4; n=$5; shift 5",
106
+ 'g=; if [ "${1-}" = --gate ]; then g=$2; shift 2; rm -f "$g"; fi',
107
+ "end=$(( $(date +%s) + $w ))",
108
+ // Ours: the daemon executable, and the marker install writes after the move holding this create's nonce.
109
+ 'ours() { [ -f "$d" ] && [ -x "$d" ] && [ -n "$n" ] && [ "$(cat "$d.installed" 2>/dev/null)" = "$n" ]; }',
110
+ 'until ours && { [ -z "$g" ] || [ -f "$g" ]; }; do',
111
+ '\tif [ "$(date +%s)" -gt "$end" ]; then',
112
+ '\t\tif ours; then echo "agentrun-computer: the Archil mount was not made within $w s ($g is not there), so this computer ends" >&2',
113
+ '\t\telse echo "agentrun-computer: the daemon did not arrive at $d within $w s, so this computer ends" >&2; fi',
114
+ "\t\texit 3",
115
+ "\tfi",
116
+ "\tsleep 0.2 2>/dev/null || sleep 1",
117
+ "done",
118
+ 'export HOME="$h"',
119
+ 'cd "$h" || { echo "agentrun-computer: init\'s home $h cannot be entered, so this computer ends" >&2; exit 4; }',
120
+ 'if [ -n "$v" ]; then export DISPLAY="$v"; else unset DISPLAY; fi',
121
+ 'exec "$d" "$@"',
122
+ ].join("\n");
123
+ /**
124
+ * Where a pid1 Archil computer's entrypoint waits for root's word that the run's folder is mounted: beside the daemon,
125
+ * in the directory install makes root's alone before root makes the gate, so no other user can make it early. (A path
126
+ * under /run would hang on an image without /run, or one whose /run another user can write.)
127
+ */
128
+ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.lastIndexOf("/"))}/archil-mounted`;
129
+ /**
130
+ * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
131
+ * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
132
+ * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
133
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for.
134
+ */
135
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", } = {}) {
136
+ const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
137
+ if (display !== "" || maxDeadline !== "")
138
+ init.push(display, maxDeadline);
139
+ const initArgs = ["init", "--deadline", deadline, "--user", user, "--own-network", ...(maxDeadline === "" ? [] : ["--max-deadline", maxDeadline])];
140
+ return {
141
+ install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...(atomic ? ["1", sha256, nonce] : [])]),
142
+ start: argvOf(START_SCRIPT, [INIT_LOG, ...argvOf(INIT_SCRIPT, init)]),
143
+ stdio: argvOf(STDIO_SCRIPT, [DAEMON_IN_COMPUTER, SOCKET_DIR]),
144
+ log: argvOf(LOG_SCRIPT, [INIT_LOG]),
145
+ entrypoint: argvOf(ENTRYPOINT_SCRIPT, [DAEMON_IN_COMPUTER, String(waitS), WORK, display, nonce, ...(gate === undefined ? [] : ["--gate", gate]), ...initArgs]),
146
+ };
147
+ }
70
148
  /**
71
149
  * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
72
150
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
@@ -104,10 +182,13 @@ export async function daemonDrift(connection, expected, timeoutMs, signal) {
104
182
  const ids = (name) => (fields.get(name) ?? "").split(/\s+/).filter(Boolean);
105
183
  const uids = ids("Uid");
106
184
  const gids = ids("Gid");
107
- if (uids.length !== 4 || uids.some((id) => id !== expected.uid))
108
- found.push(`daemon user: declared uid ${expected.uid}, read back ${show(fields.get("Uid"))}`);
109
- if (gids.length !== 4 || gids.some((id) => id !== expected.gid))
110
- found.push(`daemon group: declared gid ${expected.gid}, read back ${show(fields.get("Gid"))}`);
185
+ // With no user expected, the one it runs as: every id of the four the same, and uid not root.
186
+ const uid = expected.uid ?? (uids[0] === "0" ? undefined : uids[0]);
187
+ const gid = expected.gid ?? gids[0];
188
+ if (uids.length !== 4 || uid === undefined || uids.some((id) => id !== uid))
189
+ found.push(`daemon user: declared ${expected.uid === undefined ? "one uid that is not root" : `uid ${expected.uid}`}, read back ${show(fields.get("Uid"))}`);
190
+ if (gids.length !== 4 || gid === undefined || gids.some((id) => id !== gid))
191
+ found.push(`daemon group: declared ${expected.gid === undefined ? "one gid" : `gid ${expected.gid}`}, read back ${show(fields.get("Gid"))}`);
111
192
  if ((fields.get("Groups") ?? "") !== "")
112
193
  found.push(`daemon groups: declared none, read back ${show(fields.get("Groups"))}`);
113
194
  if (fields.get("NoNewPrivs") !== "1")
package/dist/index.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  export * from "./protocol.js";
2
2
  export * from "./result.js";
3
3
  export * from "./provider.js";
4
+ export * from "./ui-engine.js";
5
+ export * from "./attach.js";
4
6
  export * from "./mount.js";
5
- export { type CallOptions, DaemonClient, type DaemonStream } from "./client.js";
7
+ export { type CallOptions, DaemonClient, type DaemonStream, findNodes, refusedStep, type UiActOptions, type UiQuery, UiSession } from "./client.js";
6
8
  export { type ActionFailure, type CheckActionsOptions, checkActions, isKey } from "./actions.js";
7
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar } from "./files.js";
8
10
  export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
9
11
  export { type ActionMapper, createActionMapper, daemonWatch, redactWords, type ScreenFrame, type ScreenFrames, type ScreenWatch, ScreenWatchError, type ScreenWatchHandlers, toAction, type ViewerEvent, type WatchEndCode, watchEndCode, type WatchOptions, watchScreen, } from "./screen-watch.js";
12
+ export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
13
+ export { HostedProvider, type HostedOptions, type HostedTimeouts, hostedProvider } from "./hosted/provider.js";
10
14
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
11
15
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, type EnsureImageOptions, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, type ImageSource, imageSourceProblem, type Making, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
12
16
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
@@ -20,7 +24,7 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
20
24
  export { waitUntil, type WaitOptions } from "./wait.js";
21
25
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
22
26
  export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
23
- export { BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
27
+ export { AGENT37, AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
24
28
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
25
- export { type ComputerSettingKind, configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, type ProviderEntry, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
29
+ export { type ComputerSettingKind, configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, kindServed, type ProviderEntry, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
26
30
  export * from "./conformance/index.js";
package/dist/index.js CHANGED
@@ -1,14 +1,17 @@
1
1
  export * from "./protocol.js";
2
2
  export * from "./result.js";
3
3
  export * from "./provider.js";
4
+ export * from "./ui-engine.js";
5
+ export * from "./attach.js";
4
6
  export * from "./mount.js";
5
- export { DaemonClient } from "./client.js";
7
+ export { DaemonClient, findNodes, refusedStep, UiSession } from "./client.js";
6
8
  export { checkActions, isKey } from "./actions.js";
7
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
8
10
  export { listProcesses, readAll } from "./processes.js";
9
11
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
12
+ export { HostedProvider, hostedProvider } from "./hosted/provider.js";
10
13
  // The provider classes and their option types are not here: each provider loads by its id through the registry
11
- // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /orgo,
14
+ // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /orgo,
12
15
  // /phone-harness, /browserbase, /kernel, /local: each the provider file's name).
13
16
  export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
14
17
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, imageSourceProblem, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
@@ -25,6 +28,6 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
25
28
  export { waitUntil } from "./wait.js";
26
29
  export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
27
30
  export { defineProvider, descriptorProblems } from "./descriptor.js";
28
- export { BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
29
- export { configurationOf, entryOf, imagesOf, kindOf, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
31
+ export { AGENT37, AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
32
+ export { configurationOf, entryOf, imagesOf, kindOf, kindServed, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
30
33
  export * from "./conformance/index.js";
package/dist/kernel.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type BrowserComputerProvider, type BrowserProfiles, type BrowserStream, type ReleaseConfirm, type RestInit, type RestReply } from "./browser.js";
2
2
  import type { KindCapabilities } from "./kinds.js";
3
3
  import type { MountKind } from "./mount.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, type ReleaseHow } from "./provider.js";
4
+ import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
5
5
  import { type Result } from "./result.js";
6
6
  export declare const KERNEL_API_URL = "https://api.onkernel.com";
7
7
  /** The domain a Kernel CDP URL is on (wss://<host>.kernel.sh:8443, read live 11-08; its API is onkernel.com): cdpUrlProblem holds it there. */
@@ -66,9 +66,7 @@ export declare class KernelProvider implements ComputerProvider, BrowserComputer
66
66
  * spec.browser is the session's own options, each refused by check() unless declared; a profile is made first if
67
67
  * Kernel does not know it.
68
68
  */
69
- create(spec: ComputerSpec, { signal }?: {
70
- signal?: AbortSignal;
71
- }): Promise<Result<CreatedComputer>>;
69
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
72
70
  /**
73
71
  * Settings' test: one page of the organization's active browsers (GET /browsers?status=active), which makes nothing.
74
72
  * A refused key is unauthorized and a Kernel not reached unreachable; the words name the call, never the key.
package/dist/kernel.js CHANGED
@@ -101,7 +101,8 @@ export class KernelProvider {
101
101
  * spec.browser is the session's own options, each refused by check() unless declared; a profile is made first if
102
102
  * Kernel does not know it.
103
103
  */
104
- async create(spec, { signal } = {}) {
104
+ async create(spec, context) {
105
+ const signal = context?.signal;
105
106
  const refusals = this.check(spec);
106
107
  if (refusals.length > 0)
107
108
  return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
package/dist/kinds.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { DescriptorKey, DescriptorSetting, HostCommand, ParkedConfiguration, ProviderDescriptor } from "./descriptor.js";
2
2
  import type { MountKind } from "./mount.js";
3
- import type { ComputerKind, Group } from "./protocol.js";
3
+ import type { ComputerKind, Group, HelloResult } from "./protocol.js";
4
4
  import type { ComputerCapabilities, NetworkForm } from "./provider.js";
5
5
  import type { Result } from "./result.js";
6
6
  /**
@@ -35,6 +35,13 @@ export type KindCapabilities = Pick<ComputerCapabilities, "kind" | "groups" | "g
35
35
  };
36
36
  /** Why capabilities do not serve a setting kind, in words; none when they do. */
37
37
  export declare function servingRefusals(capabilities: KindCapabilities, kind: ComputerSettingKind): string[];
38
+ /**
39
+ * The groups a computer's hello must add to serve the setting kind its machine kind belongs to: the required groups
40
+ * hello.groups lacks, for the SETTING_KINDS entry whose machineKinds holds hello.kind. Empty when it serves that kind.
41
+ * A desktop that declares no input.pointer can't be given to an agent, so serve refuses it at connect and pairing, and
42
+ * health.kind-served fails a driver whose hello says so.
43
+ */
44
+ export declare function kindServed(hello: Pick<HelloResult, "kind" | "groups">): Group[];
38
45
  /** Whether a provider with these capabilities serves the kind: its machine kind is one of the kind's, and it declares every required group. */
39
46
  export declare function serves(capabilities: KindCapabilities, kind: ComputerSettingKind): boolean;
40
47
  /** The setting kind these capabilities serve, or undefined when they serve none. Machine kinds are apart, so at most one. */
package/dist/kinds.js CHANGED
@@ -2,8 +2,8 @@ import { DESCRIPTORS } from "./descriptors/index.js";
2
2
  export const SETTING_KINDS = {
3
3
  none: { machineKinds: [], required: [], optional: [] },
4
4
  sandbox: { machineKinds: ["linux"], required: ["exec", "files", "processes"], optional: [] },
5
- desktop: { machineKinds: ["desktop"], required: ["screen", "input.pointer", "input.keys"], optional: ["exec", "files", "processes", "apps", "stream"] },
6
- phone: { machineKinds: ["android", "ios"], required: ["screen", "input.touch", "apps"], optional: ["input.keys", "apps.install", "apps.ui_tree", "stream"] },
5
+ desktop: { machineKinds: ["desktop"], required: ["screen", "input.pointer", "input.keys"], optional: ["exec", "files", "processes", "apps", "ui", "stream"] },
6
+ phone: { machineKinds: ["android", "ios"], required: ["screen", "input.touch", "apps"], optional: ["input.keys", "apps.install", "ui", "stream"] },
7
7
  browser: { machineKinds: ["browser"], required: ["cdp"], optional: ["stream", "downloads"] },
8
8
  };
9
9
  /** Every setting kind, in the table's order. */
@@ -18,12 +18,28 @@ export function servingRefusals(capabilities, kind) {
18
18
  const refusals = [];
19
19
  if (!spec.machineKinds.includes(capabilities.kind))
20
20
  refusals.push(`kind ${kind} is a ${spec.machineKinds.join(" or ")} machine, not a ${capabilities.kind} one`);
21
- const groups = Array.isArray(capabilities.groups) ? capabilities.groups : [];
22
- const missing = spec.required.filter((group) => !groups.includes(group));
21
+ const missing = missingGroups(spec, capabilities.groups);
23
22
  if (missing.length > 0)
24
23
  refusals.push(`kind ${kind} needs groups ${missing.join(", ")}, which the provider does not declare`);
25
24
  return refusals;
26
25
  }
26
+ /** The groups a setting kind requires that `groups` lacks; a groups that is no list lacks them all. */
27
+ function missingGroups(spec, groups) {
28
+ const declared = Array.isArray(groups) ? groups : [];
29
+ return spec.required.filter((group) => !declared.includes(group));
30
+ }
31
+ /**
32
+ * The groups a computer's hello must add to serve the setting kind its machine kind belongs to: the required groups
33
+ * hello.groups lacks, for the SETTING_KINDS entry whose machineKinds holds hello.kind. Empty when it serves that kind.
34
+ * A desktop that declares no input.pointer can't be given to an agent, so serve refuses it at connect and pairing, and
35
+ * health.kind-served fails a driver whose hello says so.
36
+ */
37
+ export function kindServed(hello) {
38
+ const kind = SETTING_KIND_NAMES.find((name) => SETTING_KINDS[name].machineKinds.includes(hello.kind));
39
+ if (kind === undefined)
40
+ return [];
41
+ return missingGroups(SETTING_KINDS[kind], hello.groups);
42
+ }
27
43
  /** Whether a provider with these capabilities serves the kind: its machine kind is one of the kind's, and it declares every required group. */
28
44
  export function serves(capabilities, kind) {
29
45
  return servingRefusals(capabilities, kind).length === 0;
@@ -1,6 +1,6 @@
1
1
  import type { KindCapabilities } from "./kinds.js";
2
2
  import type { MountKind } from "./mount.js";
3
- import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
3
+ import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreateContext, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
4
4
  import { type Result } from "./result.js";
5
5
  /** The longest a local browser lives: a day, as pi-browser's local Chrome. */
6
6
  export declare const LOCAL_MAX_LIFETIME_MS: number;
@@ -49,9 +49,7 @@ export declare class LocalBrowserProvider implements ComputerProvider {
49
49
  executable(): string | null;
50
50
  check(spec: ComputerSpec): Refusal[];
51
51
  /** Starts Chrome under a supervisor of its own, waits until its DevTools socket answers, and hands back its ref. */
52
- create(spec: ComputerSpec, { signal }?: {
53
- signal?: AbortSignal;
54
- }): Promise<Result<CreatedComputer>>;
52
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
55
53
  /**
56
54
  * Settings' test: finds the Chrome and starts it once, headless, on a blank page, with its sandbox on (chrome.ts
57
55
  * checkChrome), with a proxy that reaches nothing. No browser is kept and no key is read; no Chrome, root, or a Chrome
@@ -188,7 +188,8 @@ export class LocalBrowserProvider {
188
188
  }
189
189
  }
190
190
  /** Starts Chrome under a supervisor of its own, waits until its DevTools socket answers, and hands back its ref. */
191
- async create(spec, { signal } = {}) {
191
+ async create(spec, context) {
192
+ const signal = context?.signal;
192
193
  const refusals = this.check(spec);
193
194
  if (refusals.length > 0)
194
195
  return fail(refusals.some((r) => r.field === "image" && r.message.endsWith(NO_CHROME)) ? "not_found" : "refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));