@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.
Files changed (155) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +547 -478
  3. package/box/Dockerfile +18 -1
  4. package/box/README.md +13 -0
  5. package/box/build-agent37.mjs +158 -0
  6. package/box/build-daytona.py +2 -2
  7. package/box/build-e2b.mjs +41 -18
  8. package/box/recipe.mjs +43 -0
  9. package/dist/agent37-ssh.d.ts +89 -0
  10. package/dist/agent37-ssh.js +445 -0
  11. package/dist/agent37.d.ts +104 -0
  12. package/dist/agent37.js +402 -0
  13. package/dist/attach.d.ts +146 -0
  14. package/dist/attach.js +469 -0
  15. package/dist/browserbase.d.ts +2 -10
  16. package/dist/browserbase.js +3 -6
  17. package/dist/client.d.ts +45 -4
  18. package/dist/client.js +92 -4
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/computerd.json +4 -0
  22. package/dist/conformance/agent37.d.ts +96 -0
  23. package/dist/conformance/agent37.js +154 -0
  24. package/dist/conformance/cases/apps.d.ts +11 -0
  25. package/dist/conformance/cases/apps.js +173 -73
  26. package/dist/conformance/cases/health.js +14 -0
  27. package/dist/conformance/cases/index.js +2 -0
  28. package/dist/conformance/cases/isolation.d.ts +7 -5
  29. package/dist/conformance/cases/isolation.js +44 -14
  30. package/dist/conformance/cases/mount.js +1 -1
  31. package/dist/conformance/cases/provider.js +27 -1
  32. package/dist/conformance/cases/screen.d.ts +3 -0
  33. package/dist/conformance/cases/screen.js +18 -0
  34. package/dist/conformance/cases/settings.d.ts +29 -23
  35. package/dist/conformance/cases/settings.js +76 -58
  36. package/dist/conformance/cases/touch.js +19 -17
  37. package/dist/conformance/cases/ui.d.ts +2 -0
  38. package/dist/conformance/cases/ui.js +475 -0
  39. package/dist/conformance/cli.d.ts +9 -0
  40. package/dist/conformance/cli.js +94 -9
  41. package/dist/conformance/daytona.d.ts +9 -20
  42. package/dist/conformance/daytona.js +12 -21
  43. package/dist/conformance/e2b.d.ts +6 -0
  44. package/dist/conformance/e2b.js +9 -2
  45. package/dist/conformance/exec-stream.d.ts +45 -0
  46. package/dist/conformance/exec-stream.js +486 -0
  47. package/dist/conformance/fixture.d.ts +1 -1
  48. package/dist/conformance/fixture.js +25 -1
  49. package/dist/conformance/modal.d.ts +17 -13
  50. package/dist/conformance/modal.js +18 -9
  51. package/dist/conformance/orgo.d.ts +3 -3
  52. package/dist/conformance/orgo.js +6 -8
  53. package/dist/conformance/phone-harness.d.ts +6 -2
  54. package/dist/conformance/phone-harness.js +21 -4
  55. package/dist/conformance/report.js +1 -1
  56. package/dist/conformance/runner.js +23 -4
  57. package/dist/conformance/sweep.d.ts +50 -0
  58. package/dist/conformance/sweep.js +187 -0
  59. package/dist/conformance/types.d.ts +13 -5
  60. package/dist/conformance/ui-fixture.d.ts +56 -0
  61. package/dist/conformance/ui-fixture.js +43 -0
  62. package/dist/create-requests.d.ts +51 -0
  63. package/dist/create-requests.js +121 -0
  64. package/dist/daytona.d.ts +20 -133
  65. package/dist/daytona.js +405 -1449
  66. package/dist/descriptor.d.ts +11 -1
  67. package/dist/descriptor.js +9 -0
  68. package/dist/descriptors/agent37.d.ts +41 -0
  69. package/dist/descriptors/agent37.js +28 -0
  70. package/dist/descriptors/daytona.d.ts +6 -5
  71. package/dist/descriptors/daytona.js +9 -5
  72. package/dist/descriptors/index.d.ts +42 -7
  73. package/dist/descriptors/index.js +4 -2
  74. package/dist/descriptors/orgo.d.ts +2 -1
  75. package/dist/descriptors/orgo.js +3 -2
  76. package/dist/descriptors/phone-harness.d.ts +1 -1
  77. package/dist/descriptors/phone-harness.js +2 -2
  78. package/dist/descriptors/shared.d.ts +1 -1
  79. package/dist/descriptors/shared.js +2 -2
  80. package/dist/desktop.d.ts +18 -4
  81. package/dist/desktop.js +89 -9
  82. package/dist/docker.d.ts +7 -10
  83. package/dist/docker.js +272 -34
  84. package/dist/drift.js +4 -4
  85. package/dist/e2b.d.ts +16 -290
  86. package/dist/e2b.js +230 -1393
  87. package/dist/fake-ui-driver.d.ts +97 -0
  88. package/dist/fake-ui-driver.js +717 -0
  89. package/dist/host.d.ts +201 -0
  90. package/dist/host.js +8 -0
  91. package/dist/hosted/process.d.ts +81 -0
  92. package/dist/hosted/process.js +259 -0
  93. package/dist/hosted/provider.d.ts +160 -0
  94. package/dist/hosted/provider.js +1415 -0
  95. package/dist/hosted/rest.d.ts +66 -0
  96. package/dist/hosted/rest.js +121 -0
  97. package/dist/hosted/scripts.d.ts +82 -0
  98. package/dist/{child.js → hosted/scripts.js} +118 -12
  99. package/dist/hosted/values.d.ts +5 -0
  100. package/dist/hosted/values.js +8 -0
  101. package/dist/index.d.ts +7 -3
  102. package/dist/index.js +7 -4
  103. package/dist/kernel.d.ts +2 -10
  104. package/dist/kernel.js +3 -6
  105. package/dist/kinds.d.ts +11 -2
  106. package/dist/kinds.js +20 -4
  107. package/dist/local-chrome.d.ts +2 -10
  108. package/dist/local-chrome.js +3 -6
  109. package/dist/modal.d.ts +22 -257
  110. package/dist/modal.js +183 -1280
  111. package/dist/mount-archil.d.ts +8 -4
  112. package/dist/mount-archil.js +22 -11
  113. package/dist/mount.d.ts +10 -4
  114. package/dist/mount.js +8 -4
  115. package/dist/orgo-channel.d.ts +3 -2
  116. package/dist/orgo-channel.js +5 -2
  117. package/dist/orgo-desktop.d.ts +9 -4
  118. package/dist/orgo-desktop.js +33 -13
  119. package/dist/orgo-workspaces.d.ts +47 -0
  120. package/dist/orgo-workspaces.js +94 -0
  121. package/dist/orgo.d.ts +10 -13
  122. package/dist/orgo.js +32 -21
  123. package/dist/phone-harness.d.ts +31 -28
  124. package/dist/phone-harness.js +510 -702
  125. package/dist/png.d.ts +4 -0
  126. package/dist/png.js +27 -0
  127. package/dist/protocol.d.ts +339 -33
  128. package/dist/protocol.js +97 -3
  129. package/dist/provider.d.ts +36 -8
  130. package/dist/provider.js +16 -0
  131. package/dist/providers.d.ts +11 -12
  132. package/dist/result.d.ts +1 -1
  133. package/dist/screen-watch.js +34 -6
  134. package/dist/surface/api.d.ts +260 -0
  135. package/dist/surface/api.js +1 -0
  136. package/dist/surface/core.d.ts +55 -0
  137. package/dist/surface/core.js +475 -0
  138. package/dist/surface/index.d.ts +5 -0
  139. package/dist/surface/index.js +3 -0
  140. package/dist/surface/outline.d.ts +10 -0
  141. package/dist/surface/outline.js +51 -0
  142. package/dist/surface/script.d.ts +10 -0
  143. package/dist/surface/script.js +94 -0
  144. package/dist/ui-engine.d.ts +114 -0
  145. package/dist/ui-engine.js +814 -0
  146. package/package.json +18 -3
  147. package/dist/child.d.ts +0 -42
  148. package/dist/conformance/daytona-sweep.d.ts +0 -18
  149. package/dist/conformance/daytona-sweep.js +0 -126
  150. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  151. package/dist/conformance/e2b-diagnose.js +0 -61
  152. package/dist/conformance/e2b-sweep.d.ts +0 -18
  153. package/dist/conformance/e2b-sweep.js +0 -132
  154. package/dist/conformance/modal-sweep.d.ts +0 -22
  155. package/dist/conformance/modal-sweep.js +0 -213
@@ -0,0 +1,66 @@
1
+ import { type ComputerErrorCode, type Result } from "../result.js";
2
+ /** A status as a code: 401 and 403 denied, 404 and 410 not found, 408 timeout, 402/429/507 limit, 400/409/422 invalid, else vendor. */
3
+ export declare function httpCode(status: number): ComputerErrorCode;
4
+ export interface RestAnswer {
5
+ status: number;
6
+ bytes: Uint8Array;
7
+ }
8
+ export interface RestInit {
9
+ json?: unknown;
10
+ form?: FormData;
11
+ timeoutMs?: number;
12
+ /**
13
+ * true: send again on no answer, 429 and 5xx (only for a call that may run twice). A function: send again only on an
14
+ * answer it says is a refusal that did not run the call, never on no answer or a timeout.
15
+ */
16
+ retry?: boolean | ((status: number, bytes: Uint8Array) => boolean);
17
+ /** Whether an answer of this status is a value, with its status, not a failure (not retried). Default: a 2xx. */
18
+ accept?: (status: number) => boolean;
19
+ }
20
+ export interface RestOptions {
21
+ /** The API's root; trailing slashes are cut. `rest.url(path)` joins it. */
22
+ base: string;
23
+ /** The headers of every call (the key, Accept, a source tag). A body's Content-Type is added. */
24
+ headers: () => Record<string, string>;
25
+ /** The provider's id: names a failure of code vendor. */
26
+ vendor: string;
27
+ fetch?: typeof fetch;
28
+ /** The bound of a call that gives none. */
29
+ timeoutMs: number;
30
+ retry?: {
31
+ attempts: number;
32
+ baseMs: number;
33
+ pause?: (ms: number, signal?: AbortSignal) => Promise<void>;
34
+ };
35
+ /** The vendor's own code or words for an answer that is not accepted; what it leaves out is httpCode and `what: status text`. */
36
+ explain?: (answer: {
37
+ status: number;
38
+ bytes: Uint8Array;
39
+ text: string;
40
+ what: string;
41
+ }) => {
42
+ code?: ComputerErrorCode;
43
+ message?: string;
44
+ };
45
+ }
46
+ /** The JSON a body holds; null for none or for text that is not JSON. */
47
+ export declare function jsonOf(bytes: Uint8Array): unknown;
48
+ export interface Rest {
49
+ url(path: string): string;
50
+ call(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<RestAnswer>>;
51
+ /** call, with the body read as JSON (null for none). */
52
+ json(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<unknown>>;
53
+ }
54
+ export declare function rest(options: RestOptions): Rest;
55
+ /**
56
+ * Every item of a paged listing. next gets the cursor of the page to read (none for the first) and answers its items and
57
+ * the cursor of the page after it, or nothing at the end. A cursor that comes back twice, or a listing past max pages,
58
+ * is a failure: this provider would miss machines.
59
+ */
60
+ export declare function allPages<T>(next: (cursor: string | undefined) => Promise<Result<{
61
+ items: T[];
62
+ next?: string;
63
+ }>>, max: number, of: {
64
+ vendor: string;
65
+ what: string;
66
+ }): Promise<Result<T[]>>;
@@ -0,0 +1,121 @@
1
+ // A vendor's REST API, once: fetch with the key in a header, JSON or form both ways, one bound, a retry rule the vendor
2
+ // chooses, and a failure that names the method, path and status and never a header. The status table and the
3
+ // cursor-page loop are here too, so a REST vendor writes only its own words and its own retry rule.
4
+ import { errorOf, fail, ok, vendorFail } from "../result.js";
5
+ import { pause } from "./process.js";
6
+ /** A status as a code: 401 and 403 denied, 404 and 410 not found, 408 timeout, 402/429/507 limit, 400/409/422 invalid, else vendor. */
7
+ export function httpCode(status) {
8
+ if (status === 401 || status === 403)
9
+ return "denied";
10
+ if (status === 404 || status === 410)
11
+ return "not_found";
12
+ if (status === 408)
13
+ return "timeout";
14
+ if (status === 402 || status === 429 || status === 507)
15
+ return "limit";
16
+ if (status === 400 || status === 409 || status === 422)
17
+ return "invalid";
18
+ return "vendor";
19
+ }
20
+ const decoder = new TextDecoder();
21
+ /** The JSON a body holds; null for none or for text that is not JSON. */
22
+ export function jsonOf(bytes) {
23
+ const text = decoder.decode(bytes);
24
+ if (text === "")
25
+ return null;
26
+ try {
27
+ return JSON.parse(text);
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
33
+ /** Whether fetch failed on a redirect it was told not to follow. */
34
+ function redirected(cause) {
35
+ const inner = cause?.cause;
36
+ return /redirect/i.test(`${cause?.message ?? ""} ${inner?.message ?? ""}`);
37
+ }
38
+ export function rest(options) {
39
+ const base = options.base.replace(/\/+$/, "");
40
+ const fetcher = options.fetch ?? fetch;
41
+ const wait = options.retry?.pause ?? pause;
42
+ async function call(method, url, init = {}, signal) {
43
+ const what = `${method} ${new URL(url).pathname}`;
44
+ const attempts = init.retry === undefined || init.retry === false || options.retry === undefined ? 1 : options.retry.attempts;
45
+ const timeoutMs = init.timeoutMs ?? options.timeoutMs;
46
+ const accepted = init.accept ?? ((status) => status >= 200 && status < 300);
47
+ for (let attempt = 1;; attempt++) {
48
+ if (signal?.aborted)
49
+ return fail("aborted", `${what} was aborted`);
50
+ const timeout = AbortSignal.timeout(timeoutMs);
51
+ let failure;
52
+ let retryable;
53
+ try {
54
+ const headers = init.json === undefined ? options.headers() : { ...options.headers(), "Content-Type": "application/json" };
55
+ // Never a redirect: a followed one keeps the key, and could carry a call to another host.
56
+ const response = await fetcher(url, {
57
+ method,
58
+ headers,
59
+ body: init.json === undefined ? init.form : JSON.stringify(init.json),
60
+ redirect: "error",
61
+ signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
62
+ });
63
+ const bytes = new Uint8Array(await response.arrayBuffer());
64
+ if (accepted(response.status))
65
+ return ok({ status: response.status, bytes });
66
+ const own = typeof init.retry === "function";
67
+ retryable = own ? init.retry(response.status, bytes) : init.retry === true && (response.status === 429 || response.status >= 500);
68
+ const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
69
+ const said = options.explain?.({ status: response.status, bytes, text, what }) ?? {};
70
+ failure = errorOf(said.code ?? httpCode(response.status), said.message ?? `${what}: ${response.status} ${text}`, options.vendor);
71
+ }
72
+ catch (cause) {
73
+ if (signal?.aborted)
74
+ return fail("aborted", `${what} was aborted`);
75
+ // No answer: the request may have reached the vendor, so only a call that may run twice is sent again.
76
+ retryable = init.retry === true;
77
+ if (timeout.aborted)
78
+ failure = { code: "timeout", message: `${what} did not answer within ${timeoutMs / 1000} s` };
79
+ else if (redirected(cause))
80
+ return vendorFail(options.vendor, `${what}: the API answered with a redirect, which is never followed: it would carry the key`);
81
+ else
82
+ failure = { code: "vendor", vendor: options.vendor, message: `${what}: ${cause.message}` };
83
+ }
84
+ if (!retryable || attempt >= attempts)
85
+ return { ok: false, error: failure };
86
+ await wait((options.retry?.baseMs ?? 0) * 2 ** (attempt - 1), signal);
87
+ }
88
+ }
89
+ return {
90
+ url: (path) => `${base}${path}`,
91
+ call,
92
+ async json(method, url, init, signal) {
93
+ const answer = await call(method, url, init, signal);
94
+ return answer.ok ? ok(jsonOf(answer.value.bytes)) : answer;
95
+ },
96
+ };
97
+ }
98
+ /**
99
+ * Every item of a paged listing. next gets the cursor of the page to read (none for the first) and answers its items and
100
+ * the cursor of the page after it, or nothing at the end. A cursor that comes back twice, or a listing past max pages,
101
+ * is a failure: this provider would miss machines.
102
+ */
103
+ export async function allPages(next, max, of) {
104
+ const found = [];
105
+ const seen = new Set();
106
+ let cursor;
107
+ for (let page = 0; page < max; page++) {
108
+ const read = await next(cursor);
109
+ if (!read.ok)
110
+ return read;
111
+ found.push(...read.value.items);
112
+ const after = read.value.next;
113
+ if (after === undefined || after === "")
114
+ return ok(found);
115
+ if (seen.has(after))
116
+ return vendorFail(of.vendor, `${of.what}'s cursor ${after} came back twice`);
117
+ seen.add(after);
118
+ cursor = after;
119
+ }
120
+ return vendorFail(of.vendor, `${of.what} ran past ${max} pages`);
121
+ }
@@ -0,0 +1,82 @@
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
+ /** The sockets the sockets script closed, from its `closed <path>` lines. */
12
+ export declare function closedSocketsOf(output: string): string[];
13
+ /**
14
+ * Where a pid1 Archil computer's entrypoint waits for root's word that the run's folder is mounted: beside the daemon,
15
+ * in the directory install makes root's alone before root makes the gate, so no other user can make it early. (A path
16
+ * under /run would hang on an image without /run, or one whose /run another user can write.)
17
+ */
18
+ export declare const ARCHIL_GATE: string;
19
+ /** The scripts the adapter runs, each one argv (see the file's head). */
20
+ export interface HostedCommands {
21
+ install: string[];
22
+ /** child: init's start, detached; it answers once init is started. */
23
+ start: string[];
24
+ /** child: the vendor's sockets (HostFacts.vendorSockets) closed to others, run before start; none when it names none. */
25
+ sockets?: string[];
26
+ stdio: string[];
27
+ log: string[];
28
+ /** pid1: the machine's command. */
29
+ entrypoint: string[];
30
+ }
31
+ /**
32
+ * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
33
+ * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
34
+ * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
35
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. vendorSockets
36
+ * (HostFacts') gives a child its sockets command.
37
+ */
38
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, vendorSockets, }?: ChildCommandOptions & {
39
+ atomic?: boolean;
40
+ waitS?: number;
41
+ gate?: string;
42
+ sha256?: string;
43
+ nonce?: string;
44
+ vendorSockets?: readonly string[];
45
+ }): HostedCommands;
46
+ export interface ChildCommandOptions {
47
+ /** Where the vendor's upload left the daemon. */
48
+ staging?: string;
49
+ /** Init's deadline, an ISO time. */
50
+ deadline?: string;
51
+ /** Who the daemon becomes, uid:gid in numbers. */
52
+ user?: string;
53
+ /** The X display init's screen and input methods drive (its DISPLAY); none for a computer with no screen. */
54
+ display?: string;
55
+ /** The most deadline.extend may move the deadline to, an ISO time; none, and the deadline cannot move. */
56
+ maxDeadline?: string;
57
+ }
58
+ /**
59
+ * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
60
+ * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
61
+ * every argument quoted.
62
+ */
63
+ export declare function childCommands({ staging, deadline, user, display, maxDeadline }?: ChildCommandOptions): {
64
+ install: string;
65
+ init: string;
66
+ stdio: string;
67
+ };
68
+ export interface DaemonExpected {
69
+ version: string;
70
+ /** 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). */
71
+ uid?: string;
72
+ gid?: string;
73
+ arch: string;
74
+ kind: ComputerCapabilities["kind"];
75
+ groups: ComputerCapabilities["groups"];
76
+ }
77
+ /**
78
+ * What the daemon reports of itself, read back through it: hello, its credentials (no capability in any set,
79
+ * no_new_privs, no groups, a seccomp filter), its network (its own loopback alone, from its /proc/self/net/dev), its
80
+ * working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
81
+ */
82
+ 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,98 @@ 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
+ /**
92
+ * Takes others' access off every path unix socket the vendor's patterns ($@, each a shell pattern with no space) name,
93
+ * as root: what init does itself under /run (daemon/internal/isolate CloseSystemSockets), for a vendor's socket
94
+ * elsewhere. The owner's and group's access stays, so the vendor's own service keeps its socket; the computer's user
95
+ * is neither. A link is never followed. Prints `closed <path>` for each socket it closed and `failed <path>` for one
96
+ * it could not; any failure fails the script, and create then refuses the computer.
97
+ */
98
+ const SOCKETS_SCRIPT = [
99
+ "# agentrun-computer: sockets",
100
+ ROOT,
101
+ "failed=0",
102
+ 'for g in "$@"; do',
103
+ "\tfor s in $g; do",
104
+ '\t\t[ -S "$s" ] && [ ! -L "$s" ] || continue',
105
+ '\t\tif $p chmod o-rwx "$s"; then echo "closed $s"; else echo "failed $s"; failed=1; fi',
106
+ "\tdone",
107
+ "done",
108
+ "exit $failed",
109
+ ].join("\n");
110
+ /** The sockets the sockets script closed, from its `closed <path>` lines. */
111
+ export function closedSocketsOf(output) {
112
+ return output.split("\n").flatMap((line) => (line.startsWith("closed ") ? [line.slice("closed ".length).trim()] : []));
113
+ }
114
+ /** The last words init wrote to its log, as root; nothing when it wrote none. */
115
+ const LOG_SCRIPT = ["# agentrun-computer: log", "l=$1", ROOT, '$p tail -c 2000 "$l" 2>/dev/null || true'].join("\n");
116
+ /**
117
+ * A pid1 machine's main process: waits, bounded, for the daemon this create installed to be moved into place executable
118
+ * (the marker beside it, `<daemon>.installed`, holds this create's nonce: a daemon the image had at the path, or one an
119
+ * 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
120
+ * child's: from its home (HOME, and the working directory), with the display, when given, as its DISPLAY. POSIX sh and
121
+ * tools in BusyBox and coreutils alike; `date +%s` bounds the wait however long a sleep takes. An Archil computer's
122
+ * (`--gate <path>` before init's arguments) also waits for the gate, which root makes once the run's folder is mounted;
123
+ * a gate there before it starts (an image that holds one) is not this computer's, and goes first.
124
+ */
125
+ const ENTRYPOINT_SCRIPT = [
126
+ "# agentrun-computer: entrypoint",
127
+ // The display is v, as in init's script; empty for a computer with no screen. n is this create's nonce.
128
+ "d=$1; w=$2; h=$3; v=$4; n=$5; shift 5",
129
+ 'g=; if [ "${1-}" = --gate ]; then g=$2; shift 2; rm -f "$g"; fi',
130
+ "end=$(( $(date +%s) + $w ))",
131
+ // Ours: the daemon executable, and the marker install writes after the move holding this create's nonce.
132
+ 'ours() { [ -f "$d" ] && [ -x "$d" ] && [ -n "$n" ] && [ "$(cat "$d.installed" 2>/dev/null)" = "$n" ]; }',
133
+ 'until ours && { [ -z "$g" ] || [ -f "$g" ]; }; do',
134
+ '\tif [ "$(date +%s)" -gt "$end" ]; then',
135
+ '\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',
136
+ '\t\telse echo "agentrun-computer: the daemon did not arrive at $d within $w s, so this computer ends" >&2; fi',
137
+ "\t\texit 3",
138
+ "\tfi",
139
+ "\tsleep 0.2 2>/dev/null || sleep 1",
140
+ "done",
141
+ 'export HOME="$h"',
142
+ 'cd "$h" || { echo "agentrun-computer: init\'s home $h cannot be entered, so this computer ends" >&2; exit 4; }',
143
+ 'if [ -n "$v" ]; then export DISPLAY="$v"; else unset DISPLAY; fi',
144
+ 'exec "$d" "$@"',
145
+ ].join("\n");
146
+ /**
147
+ * Where a pid1 Archil computer's entrypoint waits for root's word that the run's folder is mounted: beside the daemon,
148
+ * in the directory install makes root's alone before root makes the gate, so no other user can make it early. (A path
149
+ * under /run would hang on an image without /run, or one whose /run another user can write.)
150
+ */
151
+ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.lastIndexOf("/"))}/archil-mounted`;
152
+ /**
153
+ * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
154
+ * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
155
+ * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
156
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. vendorSockets
157
+ * (HostFacts') gives a child its sockets command.
158
+ */
159
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", vendorSockets = [], } = {}) {
160
+ const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
161
+ if (display !== "" || maxDeadline !== "")
162
+ init.push(display, maxDeadline);
163
+ const initArgs = ["init", "--deadline", deadline, "--user", user, "--own-network", ...(maxDeadline === "" ? [] : ["--max-deadline", maxDeadline])];
164
+ return {
165
+ install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...(atomic ? ["1", sha256, nonce] : [])]),
166
+ start: argvOf(START_SCRIPT, [INIT_LOG, ...argvOf(INIT_SCRIPT, init)]),
167
+ stdio: argvOf(STDIO_SCRIPT, [DAEMON_IN_COMPUTER, SOCKET_DIR]),
168
+ log: argvOf(LOG_SCRIPT, [INIT_LOG]),
169
+ ...(vendorSockets.length === 0 ? {} : { sockets: argvOf(SOCKETS_SCRIPT, vendorSockets) }),
170
+ entrypoint: argvOf(ENTRYPOINT_SCRIPT, [DAEMON_IN_COMPUTER, String(waitS), WORK, display, nonce, ...(gate === undefined ? [] : ["--gate", gate]), ...initArgs]),
171
+ };
172
+ }
70
173
  /**
71
174
  * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
72
175
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
@@ -104,10 +207,13 @@ export async function daemonDrift(connection, expected, timeoutMs, signal) {
104
207
  const ids = (name) => (fields.get(name) ?? "").split(/\s+/).filter(Boolean);
105
208
  const uids = ids("Uid");
106
209
  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"))}`);
210
+ // With no user expected, the one it runs as: every id of the four the same, and uid not root.
211
+ const uid = expected.uid ?? (uids[0] === "0" ? undefined : uids[0]);
212
+ const gid = expected.gid ?? gids[0];
213
+ if (uids.length !== 4 || uid === undefined || uids.some((id) => id !== uid))
214
+ found.push(`daemon user: declared ${expected.uid === undefined ? "one uid that is not root" : `uid ${expected.uid}`}, read back ${show(fields.get("Uid"))}`);
215
+ if (gids.length !== 4 || gid === undefined || gids.some((id) => id !== gid))
216
+ found.push(`daemon group: declared ${expected.gid === undefined ? "one gid" : `gid ${expected.gid}`}, read back ${show(fields.get("Gid"))}`);
111
217
  if ((fields.get("Groups") ?? "") !== "")
112
218
  found.push(`daemon groups: declared none, read back ${show(fields.get("Groups"))}`);
113
219
  if (fields.get("NoNewPrivs") !== "1")
@@ -0,0 +1,5 @@
1
+ /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
2
+ export declare const DOMAIN: RegExp;
3
+ export declare const isWhole: (value: unknown) => value is number;
4
+ /** A time the vendor reports: a Date, an ISO string, or a whole number of ms (or seconds); undefined when it is none of them. */
5
+ export declare function dateOf(value: unknown, unit?: "ms" | "s"): Date | undefined;
@@ -0,0 +1,8 @@
1
+ /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
2
+ export const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
3
+ export const isWhole = (value) => typeof value === "number" && Number.isSafeInteger(value);
4
+ /** A time the vendor reports: a Date, an ISO string, or a whole number of ms (or seconds); undefined when it is none of them. */
5
+ export function dateOf(value, unit = "ms") {
6
+ const at = value instanceof Date ? value.getTime() : typeof value === "string" ? Date.parse(value) : isWhole(value) ? value * (unit === "s" ? 1000 : 1) : Number.NaN;
7
+ return Number.isNaN(at) ? undefined : new Date(at);
8
+ }
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 } 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 } 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,5 @@
1
1
  import { type BrowserComputerProvider, type BrowserProfiles, type BrowserStream, type ReleaseConfirm, type RestInit, type RestReply } from "./browser.js";
2
- import type { KindCapabilities } from "./kinds.js";
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";
2
+ 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
3
  import { type Result } from "./result.js";
6
4
  export declare const KERNEL_API_URL = "https://api.onkernel.com";
7
5
  /** 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. */
@@ -9,10 +7,6 @@ export declare const KERNEL_CDP_DOMAIN = "kernel.sh";
9
7
  /** Kernel's shortest and longest idle timeout. */
10
8
  export declare const KERNEL_MIN_LIFETIME_MS = 10000;
11
9
  export declare const KERNEL_MAX_LIFETIME_MS = 259200000;
12
- /** A browser takes no mount. */
13
- export declare const MOUNT: readonly MountKind[];
14
- /** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
15
- export declare const CAPABILITIES: readonly KindCapabilities[];
16
10
  /** A browser as Kernel answers it; only what the provider reads. */
17
11
  export interface KernelBrowser {
18
12
  session_id?: unknown;
@@ -66,9 +60,7 @@ export declare class KernelProvider implements ComputerProvider, BrowserComputer
66
60
  * spec.browser is the session's own options, each refused by check() unless declared; a profile is made first if
67
61
  * Kernel does not know it.
68
62
  */
69
- create(spec: ComputerSpec, { signal }?: {
70
- signal?: AbortSignal;
71
- }): Promise<Result<CreatedComputer>>;
63
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
72
64
  /**
73
65
  * Settings' test: one page of the organization's active browsers (GET /browsers?status=active), which makes nothing.
74
66
  * A refused key is unauthorized and a Kernel not reached unreachable; the words name the call, never the key.
package/dist/kernel.js CHANGED
@@ -37,10 +37,6 @@ export const KERNEL_MIN_LIFETIME_MS = 10_000;
37
37
  export const KERNEL_MAX_LIFETIME_MS = 259_200_000;
38
38
  /** The most pages a list reads before it fails rather than run on. */
39
39
  const MAX_PAGES = 100;
40
- /** A browser takes no mount. */
41
- export const MOUNT = KERNEL.mounts;
42
- /** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
43
- export const CAPABILITIES = KERNEL.capabilities;
44
40
  /** Kernel's REST API over fetch: the default request. */
45
41
  export function kernelRest({ apiKey, apiUrl = KERNEL_API_URL, fetch: fetcher = fetch }) {
46
42
  const o = { vendor: NAME, fetch: fetcher, base: httpsBase(apiUrl, "the Kernel API URL"), headers: { Authorization: `Bearer ${apiKey}` } };
@@ -87,7 +83,7 @@ export class KernelProvider {
87
83
  isolation: "vm",
88
84
  os: "linux",
89
85
  daemon: "none",
90
- groups: [...CAPABILITIES[0].groups],
86
+ groups: [...KERNEL.capabilities[0].groups],
91
87
  maxLifetimeMs: KERNEL_MAX_LIFETIME_MS,
92
88
  release: ["delete"],
93
89
  browser: KERNEL_BROWSER(),
@@ -101,7 +97,8 @@ export class KernelProvider {
101
97
  * spec.browser is the session's own options, each refused by check() unless declared; a profile is made first if
102
98
  * Kernel does not know it.
103
99
  */
104
- async create(spec, { signal } = {}) {
100
+ async create(spec, context) {
101
+ const signal = context?.signal;
105
102
  const refusals = this.check(spec);
106
103
  if (refusals.length > 0)
107
104
  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
- import type { MountKind } from "./mount.js";
3
- import type { ComputerKind, Group } from "./protocol.js";
2
+ import type { MountKind, Unmounted } from "./mount.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. */
@@ -59,6 +66,8 @@ export interface ProviderEntry {
59
66
  readonly settings?: readonly DescriptorSetting[];
60
67
  /** The mount kinds its computers take; [] cannot mount the run's folder. */
61
68
  readonly mounts: readonly MountKind[];
69
+ /** Why its computers take none of these mount kinds, each in one sentence (descriptor.ts). */
70
+ readonly unmounted?: Unmounted;
62
71
  /**
63
72
  * The network forms its computers make, its descriptor's: ["none"], a remote computer whose programs run in a network
64
73
  * of their own; ["open"], the vendor's own network, which no allowlist of this server reaches; Docker's all three.