@parcha/agentrun-computer 0.1.0-beta.37 → 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 (93) hide show
  1. package/README.md +259 -203
  2. package/box/Dockerfile +18 -1
  3. package/box/README.md +13 -0
  4. package/box/build-agent37.mjs +8 -27
  5. package/box/build-daytona.py +2 -2
  6. package/box/build-e2b.mjs +41 -18
  7. package/box/recipe.mjs +43 -0
  8. package/dist/agent37-ssh.d.ts +89 -0
  9. package/dist/agent37-ssh.js +445 -0
  10. package/dist/agent37.d.ts +2 -63
  11. package/dist/agent37.js +104 -461
  12. package/dist/browserbase.d.ts +0 -6
  13. package/dist/browserbase.js +1 -5
  14. package/dist/client.d.ts +12 -3
  15. package/dist/client.js +39 -4
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +4 -0
  19. package/dist/conformance/cases/apps.d.ts +6 -0
  20. package/dist/conformance/cases/apps.js +18 -5
  21. package/dist/conformance/cases/isolation.d.ts +7 -5
  22. package/dist/conformance/cases/isolation.js +44 -14
  23. package/dist/conformance/cases/mount.js +1 -1
  24. package/dist/conformance/cli.js +66 -6
  25. package/dist/conformance/daytona.d.ts +9 -20
  26. package/dist/conformance/daytona.js +12 -21
  27. package/dist/conformance/exec-stream.d.ts +45 -0
  28. package/dist/conformance/exec-stream.js +486 -0
  29. package/dist/conformance/sweep.js +8 -8
  30. package/dist/conformance/types.d.ts +2 -2
  31. package/dist/create-requests.d.ts +1 -1
  32. package/dist/daytona.d.ts +20 -131
  33. package/dist/daytona.js +405 -1450
  34. package/dist/descriptor.d.ts +6 -1
  35. package/dist/descriptor.js +7 -0
  36. package/dist/descriptors/agent37.d.ts +1 -1
  37. package/dist/descriptors/agent37.js +1 -1
  38. package/dist/descriptors/daytona.d.ts +6 -5
  39. package/dist/descriptors/daytona.js +9 -5
  40. package/dist/descriptors/index.d.ts +4 -5
  41. package/dist/descriptors/shared.d.ts +1 -1
  42. package/dist/descriptors/shared.js +2 -2
  43. package/dist/desktop.d.ts +18 -4
  44. package/dist/desktop.js +89 -9
  45. package/dist/docker.d.ts +0 -6
  46. package/dist/docker.js +1 -5
  47. package/dist/drift.js +4 -4
  48. package/dist/e2b.d.ts +10 -128
  49. package/dist/e2b.js +130 -233
  50. package/dist/host.d.ts +106 -87
  51. package/dist/host.js +8 -1
  52. package/dist/hosted/process.d.ts +22 -8
  53. package/dist/hosted/process.js +75 -44
  54. package/dist/hosted/provider.d.ts +35 -21
  55. package/dist/hosted/provider.js +312 -261
  56. package/dist/hosted/rest.d.ts +66 -0
  57. package/dist/hosted/rest.js +121 -0
  58. package/dist/hosted/scripts.d.ts +8 -2
  59. package/dist/hosted/scripts.js +27 -2
  60. package/dist/hosted/values.d.ts +5 -0
  61. package/dist/hosted/values.js +8 -0
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/kernel.d.ts +0 -6
  65. package/dist/kernel.js +1 -5
  66. package/dist/kinds.d.ts +3 -1
  67. package/dist/local-chrome.d.ts +0 -6
  68. package/dist/local-chrome.js +1 -5
  69. package/dist/modal.d.ts +7 -84
  70. package/dist/modal.js +50 -174
  71. package/dist/mount-archil.d.ts +8 -4
  72. package/dist/mount-archil.js +22 -11
  73. package/dist/mount.d.ts +10 -4
  74. package/dist/mount.js +8 -4
  75. package/dist/orgo.d.ts +0 -9
  76. package/dist/orgo.js +2 -9
  77. package/dist/phone-harness.d.ts +0 -6
  78. package/dist/phone-harness.js +0 -4
  79. package/dist/protocol.d.ts +4 -1
  80. package/dist/protocol.js +1 -0
  81. package/dist/provider.d.ts +2 -2
  82. package/dist/providers.d.ts +11 -12
  83. package/dist/screen-watch.js +34 -6
  84. package/dist/surface/api.d.ts +14 -2
  85. package/dist/surface/core.d.ts +16 -3
  86. package/dist/surface/core.js +95 -13
  87. package/dist/surface/outline.d.ts +2 -0
  88. package/dist/surface/outline.js +2 -1
  89. package/dist/surface/script.js +2 -0
  90. package/dist/ui-engine.js +19 -3
  91. package/package.json +2 -3
  92. package/dist/conformance/daytona-sweep.d.ts +0 -18
  93. package/dist/conformance/daytona-sweep.js +0 -126
@@ -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
+ }
@@ -8,6 +8,8 @@ export declare const shellCommand: (script: string, args: readonly string[]) =>
8
8
  export declare const shellLine: (argv: readonly string[]) => string;
9
9
  /** Where start leaves what init writes, root's alone: the words a create that never hears the daemon gives back. */
10
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[];
11
13
  /**
12
14
  * Where a pid1 Archil computer's entrypoint waits for root's word that the run's folder is mounted: beside the daemon,
13
15
  * in the directory install makes root's alone before root makes the gate, so no other user can make it early. (A path
@@ -19,6 +21,8 @@ export interface HostedCommands {
19
21
  install: string[];
20
22
  /** child: init's start, detached; it answers once init is started. */
21
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[];
22
26
  stdio: string[];
23
27
  log: string[];
24
28
  /** pid1: the machine's command. */
@@ -28,14 +32,16 @@ export interface HostedCommands {
28
32
  * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
29
33
  * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
30
34
  * 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.
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.
32
37
  */
33
- export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, }?: ChildCommandOptions & {
38
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, vendorSockets, }?: ChildCommandOptions & {
34
39
  atomic?: boolean;
35
40
  waitS?: number;
36
41
  gate?: string;
37
42
  sha256?: string;
38
43
  nonce?: string;
44
+ vendorSockets?: readonly string[];
39
45
  }): HostedCommands;
40
46
  export interface ChildCommandOptions {
41
47
  /** Where the vendor's upload left the daemon. */
@@ -88,6 +88,29 @@ export const INIT_LOG = `${SOCKET_DIR}-init.log`;
88
88
  * none, so the vendor's call ends at once and nothing of it holds init. As root, or through passwordless sudo.
89
89
  */
90
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
+ }
91
114
  /** The last words init wrote to its log, as root; nothing when it wrote none. */
92
115
  const LOG_SCRIPT = ["# agentrun-computer: log", "l=$1", ROOT, '$p tail -c 2000 "$l" 2>/dev/null || true'].join("\n");
93
116
  /**
@@ -130,9 +153,10 @@ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.las
130
153
  * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
131
154
  * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
132
155
  * 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.
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.
134
158
  */
135
- export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", } = {}) {
159
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", vendorSockets = [], } = {}) {
136
160
  const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
137
161
  if (display !== "" || maxDeadline !== "")
138
162
  init.push(display, maxDeadline);
@@ -142,6 +166,7 @@ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER,
142
166
  start: argvOf(START_SCRIPT, [INIT_LOG, ...argvOf(INIT_SCRIPT, init)]),
143
167
  stdio: argvOf(STDIO_SCRIPT, [DAEMON_IN_COMPUTER, SOCKET_DIR]),
144
168
  log: argvOf(LOG_SCRIPT, [INIT_LOG]),
169
+ ...(vendorSockets.length === 0 ? {} : { sockets: argvOf(SOCKETS_SCRIPT, vendorSockets) }),
145
170
  entrypoint: argvOf(ENTRYPOINT_SCRIPT, [DAEMON_IN_COMPUTER, String(waitS), WORK, display, nonce, ...(gate === undefined ? [] : ["--gate", gate]), ...initArgs]),
146
171
  };
147
172
  }
@@ -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
@@ -10,7 +10,7 @@ export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar }
10
10
  export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
11
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
12
  export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
13
- export { HostedProvider, type HostedOptions, type HostedTimeouts, hostedProvider } from "./hosted/provider.js";
13
+ export { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
14
14
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
15
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";
16
16
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { checkActions, isKey } from "./actions.js";
9
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
10
10
  export { listProcesses, readAll } from "./processes.js";
11
11
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
12
- export { HostedProvider, hostedProvider } from "./hosted/provider.js";
12
+ export { HostedProvider } from "./hosted/provider.js";
13
13
  // The provider classes and their option types are not here: each provider loads by its id through the registry
14
14
  // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /orgo,
15
15
  // /phone-harness, /browserbase, /kernel, /local: each the provider file's name).
package/dist/kernel.d.ts CHANGED
@@ -1,6 +1,4 @@
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
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";
@@ -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;
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(),
package/dist/kinds.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { DescriptorKey, DescriptorSetting, HostCommand, ParkedConfiguration, ProviderDescriptor } from "./descriptor.js";
2
- import type { MountKind } from "./mount.js";
2
+ import type { MountKind, Unmounted } from "./mount.js";
3
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";
@@ -66,6 +66,8 @@ export interface ProviderEntry {
66
66
  readonly settings?: readonly DescriptorSetting[];
67
67
  /** The mount kinds its computers take; [] cannot mount the run's folder. */
68
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;
69
71
  /**
70
72
  * The network forms its computers make, its descriptor's: ["none"], a remote computer whose programs run in a network
71
73
  * of their own; ["open"], the vendor's own network, which no allowlist of this server reaches; Docker's all three.
@@ -1,19 +1,13 @@
1
- import type { KindCapabilities } from "./kinds.js";
2
- import type { MountKind } from "./mount.js";
3
1
  import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreateContext, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
4
2
  import { type Result } from "./result.js";
5
3
  /** The longest a local browser lives: a day, as pi-browser's local Chrome. */
6
4
  export declare const LOCAL_MAX_LIFETIME_MS: number;
7
- /** A browser takes no mount: its descriptor's (descriptors/local-chrome.ts). */
8
- export declare const MOUNT: readonly MountKind[];
9
5
  /** A spec's network as this browser's proxy takes it: open (no list), a list (parseAllow's), or why it can't. */
10
6
  export declare function browserNetworkOf(network: unknown): {
11
7
  allow?: string[];
12
8
  } | {
13
9
  problem: string;
14
10
  };
15
- /** The one configuration it offers, its descriptor's: a browser with a CDP target. */
16
- export declare const CAPABILITIES: readonly KindCapabilities[];
17
11
  export interface LocalBrowserOptions {
18
12
  /** The Chrome or Chromium to run; default the one findChrome finds in `env`, then in the usual places. */
19
13
  executablePath?: string;
@@ -45,8 +45,6 @@ const WINDOW = "--window-size=1280,800";
45
45
  const SOCKET_PATH_MAX = 107;
46
46
  /** How long a release waits for the supervisor, then for Chrome, to end. */
47
47
  const END_MS = 10_000;
48
- /** A browser takes no mount: its descriptor's (descriptors/local-chrome.ts). */
49
- export const MOUNT = LOCAL.mounts;
50
48
  /** The networks a local browser runs on, its descriptor's: through its egress proxy, public addresses ("open"), or only
51
49
  * the hosts of a list ("allow"), public ones still. */
52
50
  const NETWORK = LOCAL.network;
@@ -75,8 +73,6 @@ const networkRecord = (network) => {
75
73
  };
76
74
  /** A browser's network as list, attach and network() read it back from browser.json. */
77
75
  const networkRead = (record) => (record.allow ? { allow: [...record.allow] } : "open");
78
- /** The one configuration it offers, its descriptor's: a browser with a CDP target. */
79
- export const CAPABILITIES = LOCAL.capabilities;
80
76
  const ID = /^lb-[0-9a-f]{16}$/;
81
77
  const idProblem = (id) => (typeof id === "string" && ID.test(id) ? undefined : `${typeof id === "string" ? JSON.stringify(id) : String(id)} is not a local browser's id`);
82
78
  const refOf = (id) => ({ id, name: id });
@@ -124,7 +120,7 @@ export class LocalBrowserProvider {
124
120
  isolation: "host",
125
121
  os: "linux",
126
122
  daemon: "none",
127
- groups: [...CAPABILITIES[0].groups],
123
+ groups: [...LOCAL.capabilities[0].groups],
128
124
  maxLifetimeMs: LOCAL_MAX_LIFETIME_MS,
129
125
  release: ["delete"],
130
126
  browser: { timeout: "wall-clock" },
package/dist/modal.d.ts CHANGED
@@ -1,77 +1,12 @@
1
1
  import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
- import type { KindCapabilities } from "./kinds.js";
3
- import type { MountKind } from "./mount.js";
4
- /** The App sandboxes are made in (modal-client@64880502:js/src/app.ts:32-61). */
5
- export interface ModalApp {
6
- readonly appId: string;
7
- }
8
- /** An Image, built on Modal's side when a sandbox is created from it (js/src/image.ts:311-401). */
9
- export interface ModalImage {
10
- dockerfileCommands(commands: string[]): ModalImage;
11
- }
12
- /** What sandboxes.create is given: every field is one of the SDK's SandboxCreateParams (js/src/sandbox.ts:356-474). */
13
- export interface ModalCreateParams {
14
- /** vm, or gvisor for a GPU computer: Modal offers GPUs on gVisor only. */
15
- runtime: ModalRuntime;
16
- /** The GPUs, as the SDK takes them ("T4", "A100-80GB:4"): a GPU computer only. */
17
- gpu?: string;
18
- command: string[];
19
- timeoutMs: number;
20
- workdir: string;
21
- cpu: number;
22
- cpuLimit: number;
23
- memoryMiB: number;
24
- memoryLimitMiB: number;
25
- blockNetwork?: true;
26
- tags: Record<string, string>;
27
- }
28
- /** A program's stdin in binary mode: the SDK's ModalWriteStream (js/src/streams.ts:33-39) and WritableStream's close. */
29
- export interface ModalByteSink {
30
- writeBytes(bytes: Uint8Array): Promise<void>;
31
- close(): Promise<void>;
32
- }
33
- /** One program started by exec in binary mode: the part of the SDK's ContainerProcess read here (sandbox.ts:2774-2914). */
34
- export interface ModalProcess {
35
- readonly stdin: ModalByteSink;
36
- readonly stdout: AsyncIterable<Uint8Array>;
37
- readonly stderr: AsyncIterable<Uint8Array>;
38
- wait(): Promise<number>;
39
- }
40
- /** The part of the SDK's Sandbox called here (sandbox.ts:1624-2772). */
41
- export interface ModalSandbox {
42
- readonly sandboxId: string;
43
- exec(command: string[], params: {
44
- mode: "binary";
45
- }): Promise<ModalProcess>;
46
- /** null while the sandbox runs, its exit code once it has finished. */
47
- poll(): Promise<number | null>;
48
- getTags(): Promise<Record<string, string>>;
49
- terminate(): Promise<void>;
50
- }
51
- /** The part of the SDK's ModalClient this provider calls. The host passes its own client. */
52
- export interface ModalSdk {
53
- readonly apps: {
54
- fromName(name: string, params: {
55
- createIfMissing: boolean;
56
- }): Promise<ModalApp>;
57
- };
58
- /** fromId opens an image Modal already holds (im-..., as box/build-modal.py prints it); a spec naming one needs it. */
59
- readonly images: {
60
- fromRegistry(tag: string): ModalImage;
61
- fromId?(id: string): Promise<ModalImage>;
62
- };
63
- readonly sandboxes: {
64
- create(app: ModalApp, image: ModalImage, params: ModalCreateParams): Promise<ModalSandbox>;
65
- fromId(id: string): Promise<ModalSandbox>;
66
- list(params: {
67
- appId: string;
68
- tags: Record<string, string>;
69
- }): AsyncIterable<ModalSandbox>;
70
- };
71
- }
2
+ /**
3
+ * The SDK's own types, imported as types only: erased at build, so nothing loads the SDK from here. The host passes its
4
+ * own client (or the constructor), which these name.
5
+ */
6
+ export type ModalSdk = object;
72
7
  /** The Modal provider's options: the client and the app, then the shared adapter's (HostedOptions). */
73
- export interface ModalProviderOptions extends Omit<HostedOptions, "label" | "kind" | "desktop" | "maxLifetimeMs"> {
74
- /** The host's Modal client, or anything with the same slice. */
8
+ export interface ModalProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs"> {
9
+ /** The host's Modal client. */
75
10
  sdk: ModalSdk;
76
11
  /** The Modal App the sandboxes live in; made when missing. */
77
12
  app: string;
@@ -79,12 +14,8 @@ export interface ModalProviderOptions extends Omit<HostedOptions, "label" | "kin
79
14
  maxLifetimeMs?: number;
80
15
  timeouts?: Partial<HostedTimeouts>;
81
16
  }
82
- /** The mount kinds a Modal computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
83
- export declare const MOUNT: readonly MountKind[];
84
17
  /** The runtime a Modal sandbox runs under: vm, or gvisor for a GPU computer (Modal offers GPUs on gVisor only). */
85
18
  export type ModalRuntime = "vm" | "gvisor";
86
- /** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
87
- export declare const CAPABILITIES: readonly KindCapabilities[];
88
19
  /** The SDK's default server (modal-client@64880502:js/src/config.ts:143). */
89
20
  export declare const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com:443";
90
21
  /** What modalClient gives the SDK's ModalClient: the token, explicitly, so the SDK fills none of it in. */
@@ -132,14 +63,6 @@ export declare function modalClient({ tokenId, tokenSecret, serverUrl, ModalClie
132
63
  export declare function create(options: ModalCreateOptions): Promise<ModalProvider>;
133
64
  /** The conformance CLI's module for Modal: its live switch, the run's 30-minute cap and the drifted twin. */
134
65
  export declare const conformance: () => Promise<typeof import("./conformance/modal.js")>;
135
- /**
136
- * The tags a sandbox carries for a machine's labels. Every label is its own tag, with one exception that keeps an
137
- * Archil computer within Modal's 512 bytes: the mount label's folder, agents/<agent>/runs/<run>/work, names the run its
138
- * agentrun.run label holds, so the tag records the agent alone, and labelsOf puts the folder back.
139
- */
140
- export declare function tagsOf(labels: Record<string, string>): Record<string, string>;
141
- /** A sandbox's labels from its tags: tagsOf undone. */
142
- export declare function labelsOf(tags: Record<string, string>): Record<string, string>;
143
66
  /**
144
67
  * Computers that are Modal sandboxes on the VM runtime, or on gVisor with a GPU, on the shared adapter. The daemon is
145
68
  * streamed in through an exec's stdin right after create, while the sandbox's command, the entrypoint, waits for it and