@parcha/agentrun-computer 0.1.0-beta.38 → 0.1.0-beta.39

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 (85) hide show
  1. package/README.md +101 -76
  2. package/box/README.md +2 -1
  3. package/box/recipe.d.mts +5 -0
  4. package/dist/agent37.d.ts +17 -4
  5. package/dist/agent37.js +96 -16
  6. package/dist/box-image.d.ts +14 -0
  7. package/dist/box-image.js +24 -0
  8. package/dist/computerd-linux-amd64 +0 -0
  9. package/dist/computerd-linux-arm64 +0 -0
  10. package/dist/computerd.json +2 -2
  11. package/dist/conformance/agent37.d.ts +9 -4
  12. package/dist/conformance/agent37.js +23 -11
  13. package/dist/conformance/browserbase.js +3 -3
  14. package/dist/conformance/cases/apps.d.ts +1 -1
  15. package/dist/conformance/cases/apps.js +1 -1
  16. package/dist/conformance/cases/isolation.d.ts +18 -3
  17. package/dist/conformance/cases/isolation.js +57 -6
  18. package/dist/conformance/cases/mount.js +4 -2
  19. package/dist/conformance/cases/provider.js +41 -0
  20. package/dist/conformance/cli.js +6 -5
  21. package/dist/conformance/e2b.js +9 -4
  22. package/dist/conformance/exec-stream.d.ts +7 -0
  23. package/dist/conformance/exec-stream.js +8 -1
  24. package/dist/conformance/kernel.js +2 -2
  25. package/dist/conformance/modal.js +1 -1
  26. package/dist/conformance/orgo.js +2 -2
  27. package/dist/daytona.d.ts +0 -5
  28. package/dist/daytona.js +16 -27
  29. package/dist/descriptor.d.ts +5 -3
  30. package/dist/descriptors/agent37.d.ts +3 -11
  31. package/dist/descriptors/agent37.js +9 -10
  32. package/dist/descriptors/daytona.d.ts +1 -1
  33. package/dist/descriptors/daytona.js +5 -2
  34. package/dist/descriptors/docker.d.ts +13 -1
  35. package/dist/descriptors/docker.js +3 -1
  36. package/dist/descriptors/e2b.d.ts +2 -9
  37. package/dist/descriptors/e2b.js +8 -8
  38. package/dist/descriptors/index.d.ts +21 -19
  39. package/dist/descriptors/index.js +1 -3
  40. package/dist/descriptors/modal.d.ts +2 -6
  41. package/dist/descriptors/modal.js +8 -6
  42. package/dist/descriptors/orgo.js +2 -1
  43. package/dist/docker/egress-main.js +23 -15
  44. package/dist/docker/egress.d.ts +6 -4
  45. package/dist/docker/egress.js +24 -16
  46. package/dist/docker/inspect.d.ts +2 -2
  47. package/dist/docker/inspect.js +5 -5
  48. package/dist/docker.d.ts +6 -5
  49. package/dist/docker.js +12 -11
  50. package/dist/e2b.d.ts +12 -2
  51. package/dist/e2b.js +42 -19
  52. package/dist/host.d.ts +54 -41
  53. package/dist/hosted/network.d.ts +23 -0
  54. package/dist/hosted/network.js +77 -0
  55. package/dist/hosted/process.d.ts +2 -0
  56. package/dist/hosted/process.js +5 -0
  57. package/dist/hosted/provider.d.ts +6 -4
  58. package/dist/hosted/provider.js +244 -136
  59. package/dist/hosted/rest.d.ts +10 -2
  60. package/dist/hosted/rest.js +9 -4
  61. package/dist/hosted/scripts.d.ts +19 -7
  62. package/dist/hosted/scripts.js +55 -18
  63. package/dist/{agent37-ssh.d.ts → hosted/ssh-exec.d.ts} +19 -9
  64. package/dist/{agent37-ssh.js → hosted/ssh-exec.js} +38 -19
  65. package/dist/hosted/values.d.ts +21 -0
  66. package/dist/hosted/values.js +55 -0
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/isolation.d.ts +0 -2
  70. package/dist/isolation.js +3 -4
  71. package/dist/modal.d.ts +8 -2
  72. package/dist/modal.js +21 -15
  73. package/dist/mount-archil.d.ts +5 -4
  74. package/dist/mount-archil.js +5 -6
  75. package/dist/orgo.js +6 -4
  76. package/dist/providers.d.ts +4 -1
  77. package/dist/surface/api.d.ts +0 -9
  78. package/dist/surface/core.d.ts +7 -2
  79. package/dist/surface/core.js +12 -4
  80. package/dist/surface/index.d.ts +1 -1
  81. package/dist/surface/index.js +1 -1
  82. package/dist/surface/script.d.ts +4 -0
  83. package/dist/surface/script.js +9 -3
  84. package/package.json +1 -1
  85. package/box/build-agent37.mjs +0 -158
@@ -1,6 +1,9 @@
1
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;
2
+ /**
3
+ * A status as a code: 401 and 403 denied, 404 and 410 not found, 408 timeout, 402/429/507 limit, 400/409/422 invalid,
4
+ * else vendor; 409 is exists on a call that carries the machine's name (RestInit.named).
5
+ */
6
+ export declare function httpCode(status: number, named?: boolean): ComputerErrorCode;
4
7
  export interface RestAnswer {
5
8
  status: number;
6
9
  bytes: Uint8Array;
@@ -16,6 +19,11 @@ export interface RestInit {
16
19
  retry?: boolean | ((status: number, bytes: Uint8Array) => boolean);
17
20
  /** Whether an answer of this status is a value, with its status, not a failure (not retried). Default: a 2xx. */
18
21
  accept?: (status: number) => boolean;
22
+ /**
23
+ * The call carries the machine's name (a create by MachineRequest.name): its 409 is the vendor's word that a machine
24
+ * has that name, exists, which the adapter reads as the machine its listing by the name finds.
25
+ */
26
+ named?: boolean;
19
27
  }
20
28
  export interface RestOptions {
21
29
  /** The API's root; trailing slashes are cut. `rest.url(path)` joins it. */
@@ -3,8 +3,11 @@
3
3
  // cursor-page loop are here too, so a REST vendor writes only its own words and its own retry rule.
4
4
  import { errorOf, fail, ok, vendorFail } from "../result.js";
5
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) {
6
+ /**
7
+ * A status as a code: 401 and 403 denied, 404 and 410 not found, 408 timeout, 402/429/507 limit, 400/409/422 invalid,
8
+ * else vendor; 409 is exists on a call that carries the machine's name (RestInit.named).
9
+ */
10
+ export function httpCode(status, named = false) {
8
11
  if (status === 401 || status === 403)
9
12
  return "denied";
10
13
  if (status === 404 || status === 410)
@@ -13,7 +16,9 @@ export function httpCode(status) {
13
16
  return "timeout";
14
17
  if (status === 402 || status === 429 || status === 507)
15
18
  return "limit";
16
- if (status === 400 || status === 409 || status === 422)
19
+ if (status === 409)
20
+ return named ? "exists" : "invalid";
21
+ if (status === 400 || status === 422)
17
22
  return "invalid";
18
23
  return "vendor";
19
24
  }
@@ -67,7 +72,7 @@ export function rest(options) {
67
72
  retryable = own ? init.retry(response.status, bytes) : init.retry === true && (response.status === 429 || response.status >= 500);
68
73
  const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
69
74
  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);
75
+ failure = errorOf(said.code ?? httpCode(response.status, init.named), said.message ?? `${what}: ${response.status} ${text}`, options.vendor);
71
76
  }
72
77
  catch (cause) {
73
78
  if (signal?.aborted)
@@ -8,6 +8,12 @@ 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
+ /**
12
+ * The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
13
+ * namespace cuts: every child host's create closes them to the computer's user before init starts. The window
14
+ * manager's bus is its own, at an abstract address, so closing these takes nothing from it.
15
+ */
16
+ export declare const SESSION_BUSES: readonly string[];
11
17
  /** The sockets the sockets script closed, from its `closed <path>` lines. */
12
18
  export declare function closedSocketsOf(output: string): string[];
13
19
  /**
@@ -21,8 +27,10 @@ export interface HostedCommands {
21
27
  install: string[];
22
28
  /** child: init's start, detached; it answers once init is started. */
23
29
  start: string[];
24
- /** child: the vendor's sockets (HostFacts.vendorSockets) closed to others, run before start; none when it names none. */
25
- sockets?: string[];
30
+ /** child: the session buses in /tmp (SESSION_BUSES) closed to others, run before start. */
31
+ sockets: string[];
32
+ /** Write taken off every user but root on the host's rootOnly paths, run before the daemon's upload. */
33
+ rootOnly: string[];
26
34
  stdio: string[];
27
35
  log: string[];
28
36
  /** pid1: the machine's command. */
@@ -32,16 +40,18 @@ export interface HostedCommands {
32
40
  * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
33
41
  * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
34
42
  * 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.
43
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. sockets are
44
+ * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
45
+ * others' write off (default none).
37
46
  */
38
- export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, vendorSockets, }?: ChildCommandOptions & {
47
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, sockets, rootOnly, network, }?: ChildCommandOptions & {
39
48
  atomic?: boolean;
40
49
  waitS?: number;
41
50
  gate?: string;
42
51
  sha256?: string;
43
52
  nonce?: string;
44
- vendorSockets?: readonly string[];
53
+ sockets?: readonly string[];
54
+ rootOnly?: readonly string[];
45
55
  }): HostedCommands;
46
56
  export interface ChildCommandOptions {
47
57
  /** Where the vendor's upload left the daemon. */
@@ -54,13 +64,15 @@ export interface ChildCommandOptions {
54
64
  display?: string;
55
65
  /** The most deadline.extend may move the deadline to, an ISO time; none, and the deadline cannot move. */
56
66
  maxDeadline?: string;
67
+ /** The network form init's egress proxy serves (./network.ts networkFormOf): open, or allow: and a list; none, no proxy. */
68
+ network?: string;
57
69
  }
58
70
  /**
59
71
  * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
60
72
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
61
73
  * every argument quoted.
62
74
  */
63
- export declare function childCommands({ staging, deadline, user, display, maxDeadline }?: ChildCommandOptions): {
75
+ export declare function childCommands({ staging, deadline, user, display, maxDeadline, network }?: ChildCommandOptions): {
64
76
  install: string;
65
77
  init: string;
66
78
  stdio: string;
@@ -60,15 +60,17 @@ export function installerOf(output) {
60
60
  * them (Daytona's toolbox, E2B's envd), which runs commands as root for whoever reaches it: a network of their own,
61
61
  * their loopback alone, no vsock, no other process of their uid (src/isolation.ts). Init holds every process and ends
62
62
  * them at the deadline. A display, when given, is init's DISPLAY, the X display its screen and input methods drive; a
63
- * maximum, when given, is the most deadline.extend may move the deadline to. */
63
+ * maximum, when given, is the most deadline.extend may move the deadline to; a network form, when given (open, or
64
+ * allow: and a list), has init start the egress proxy that serves it before it leaves the machine's network
65
+ * (./network.ts). */
64
66
  const INIT_SCRIPT = [
65
67
  "# agentrun-computer: init",
66
- // The display is v, not x: held() assigns x, and runs before the exec that reads it.
67
- "d=$1; t=$2; w=$3; h=$4; r=$5; v=${6-}; m=${7-}",
68
+ // The display is v, not x: held() assigns x, and runs before the exec that reads it. The network form is n.
69
+ "d=$1; t=$2; w=$3; h=$4; r=$5; v=${6-}; m=${7-}; n=${8-}",
68
70
  HELD,
69
71
  'held "$d" >&2 || exit 6',
70
72
  ROOT,
71
- `exec $p env -i PATH=${PATH} HOME="$h" AGENTRUN_COMPUTERD_SOCKET="$r/computerd.sock" \${v:+DISPLAY="$v"} sh -c 'cd "$HOME" && exec "$@"' sh "$d" init --deadline "$t" --user "$w" --own-network \${m:+--max-deadline "$m"}`,
73
+ `exec $p env -i PATH=${PATH} HOME="$h" AGENTRUN_COMPUTERD_SOCKET="$r/computerd.sock" \${v:+DISPLAY="$v"} sh -c 'cd "$HOME" && exec "$@"' sh "$d" init --deadline "$t" --user "$w" --own-network \${m:+--max-deadline "$m"} \${n:+--network "$n"}`,
72
74
  ].join("\n");
73
75
  /** The bridge one connection runs: stdin and stdout to init's socket. As root, to reach a socket in a directory that is
74
76
  * the daemon's user's alone; it only carries bytes, and the command's user is root or has passwordless sudo already.
@@ -89,8 +91,14 @@ export const INIT_LOG = `${SOCKET_DIR}-init.log`;
89
91
  */
90
92
  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
93
  /**
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
+ * The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
95
+ * namespace cuts: every child host's create closes them to the computer's user before init starts. The window
96
+ * manager's bus is its own, at an abstract address, so closing these takes nothing from it.
97
+ */
98
+ export const SESSION_BUSES = ["/tmp/dbus-*"];
99
+ /**
100
+ * Takes others' access off every path unix socket the patterns ($@, each a shell pattern with no space) name, as
101
+ * root: what init does itself under /run (daemon/internal/isolate CloseSystemSockets), for a vendor's socket
94
102
  * elsewhere. The owner's and group's access stays, so the vendor's own service keeps its socket; the computer's user
95
103
  * is neither. A link is never followed. Prints `closed <path>` for each socket it closed and `failed <path>` for one
96
104
  * it could not; any failure fails the script, and create then refuses the computer.
@@ -107,6 +115,27 @@ const SOCKETS_SCRIPT = [
107
115
  "done",
108
116
  "exit $failed",
109
117
  ].join("\n");
118
+ /**
119
+ * Makes each path ($@) root's alone, as root, and for a directory everything under it (no link is followed): root owns
120
+ * every entry (a link itself, `chown -h`), and no group or other user may write one. Only the entries that need it are
121
+ * changed. Then it reads them back: an entry not root's alone fails the script, and create then refuses the computer.
122
+ * An owner who is not root could give write back with chmod, so the owner is made root as well as the mode. A path the
123
+ * image lacks is skipped. For a host whose image leaves places root runs or reads open to other users
124
+ * (HostFacts.rootOnly); it runs before the daemon's upload. Root is the user `$p` runs as, read by `id -u`.
125
+ */
126
+ const ROOT_ONLY_SCRIPT = [
127
+ "# agentrun-computer: root-only",
128
+ ROOT,
129
+ 'r=$($p id -u) || { echo "running a command as root failed"; exit 5; }',
130
+ 'for f in "$@"; do',
131
+ '\t[ -e "$f" ] || [ -L "$f" ] || continue',
132
+ '\t[ ! -L "$f" ] || { echo "$f is a symbolic link"; exit 6; }',
133
+ '\t$p find "$f" ! -user "$r" -exec chown -h "$r" {} + || { echo "making root the owner of $f failed"; exit 5; }',
134
+ '\t$p find "$f" ! -type l -perm /022 -exec chmod go-w {} + || { echo "taking write off $f failed"; exit 5; }',
135
+ '\tw=$($p find "$f" \\( ! -user "$r" -o ! -type l -perm /022 \\) -print 2>/dev/null | head -n 1)',
136
+ '\t[ -z "$w" ] || { echo "$w is not root\'s alone"; exit 5; }',
137
+ "done",
138
+ ].join("\n");
110
139
  /** The sockets the sockets script closed, from its `closed <path>` lines. */
111
140
  export function closedSocketsOf(output) {
112
141
  return output.split("\n").flatMap((line) => (line.startsWith("closed ") ? [line.slice("closed ".length).trim()] : []));
@@ -153,32 +182,40 @@ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.las
153
182
  * The adapter's commands for one computer. Init's flags are the child's (childCommands) for both modes: --own-network
154
183
  * always, the display and the most deadline.extend may move the deadline to when given. waitS bounds a pid1 entrypoint's
155
184
  * 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.
185
+ * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. sockets are
186
+ * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
187
+ * others' write off (default none).
158
188
  */
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])];
189
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", sockets = SESSION_BUSES, rootOnly = [], network = "", } = {}) {
190
+ const init = initScriptArgs({ deadline, user, display, maxDeadline, network });
191
+ const initArgs = ["init", "--deadline", deadline, "--user", user, "--own-network", ...(maxDeadline === "" ? [] : ["--max-deadline", maxDeadline]), ...(network === "" ? [] : ["--network", network])];
164
192
  return {
165
193
  install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...(atomic ? ["1", sha256, nonce] : [])]),
166
194
  start: argvOf(START_SCRIPT, [INIT_LOG, ...argvOf(INIT_SCRIPT, init)]),
167
195
  stdio: argvOf(STDIO_SCRIPT, [DAEMON_IN_COMPUTER, SOCKET_DIR]),
168
196
  log: argvOf(LOG_SCRIPT, [INIT_LOG]),
169
- ...(vendorSockets.length === 0 ? {} : { sockets: argvOf(SOCKETS_SCRIPT, vendorSockets) }),
197
+ sockets: argvOf(SOCKETS_SCRIPT, sockets),
198
+ rootOnly: argvOf(ROOT_ONLY_SCRIPT, rootOnly),
170
199
  entrypoint: argvOf(ENTRYPOINT_SCRIPT, [DAEMON_IN_COMPUTER, String(waitS), WORK, display, nonce, ...(gate === undefined ? [] : ["--gate", gate]), ...initArgs]),
171
200
  };
172
201
  }
202
+ /** The init script's arguments: the daemon, the deadline, the user, home and the socket's folder, then the display, the
203
+ * maximum and the network form, each empty when not given, where any of them is. */
204
+ function initScriptArgs({ deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "" }) {
205
+ const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
206
+ if (network !== "")
207
+ init.push(display, maxDeadline, network);
208
+ else if (display !== "" || maxDeadline !== "")
209
+ init.push(display, maxDeadline);
210
+ return init;
211
+ }
173
212
  /**
174
213
  * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
175
214
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
176
215
  * every argument quoted.
177
216
  */
178
- export function childCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "" } = {}) {
179
- const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
180
- if (display !== "" || maxDeadline !== "")
181
- init.push(display, maxDeadline);
217
+ export function childCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "" } = {}) {
218
+ const init = initScriptArgs({ deadline, user, display, maxDeadline, network });
182
219
  return {
183
220
  install: shellCommand(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR]),
184
221
  init: shellCommand(INIT_SCRIPT, init),
@@ -1,5 +1,5 @@
1
1
  import { Duplex } from "node:stream";
2
- import type { HostCall, MachineProcess } from "./host.js";
2
+ import type { HostCall, MachineProcess } from "../host.js";
3
3
  /** A readable side of an ssh2 channel, as this provider uses it: piped, or drained. */
4
4
  export interface Ssh2Readable {
5
5
  pipe(destination: NodeJS.WritableStream): unknown;
@@ -23,8 +23,9 @@ export interface Ssh2Channel extends Ssh2Readable {
23
23
  /** The options of ssh2's Client.connect this provider gives (ssh2@1.17.0 lib/client.js). */
24
24
  export interface Ssh2ConnectConfig {
25
25
  sock: Duplex;
26
- username: "root";
27
- privateKey: string;
26
+ username: string;
27
+ privateKey?: string;
28
+ password?: string;
28
29
  readyTimeout: number;
29
30
  keepaliveInterval: number;
30
31
  keepaliveCountMax: number;
@@ -59,22 +60,31 @@ export interface SshTunnel {
59
60
  }
60
61
  /** How a vendor opens the stream to machine id's sshd: a fresh one per call, nothing started before it is used. */
61
62
  export type SshTunnelOf = (id: string) => SshTunnel;
63
+ /** How a host logs in to a machine's sshd: as root (MachineHost.exec's user), by a key or a password. */
64
+ export interface SshLogin {
65
+ username: string;
66
+ /** A private key in the PEM armor ssh2 reads (see pemOf). */
67
+ privateKey?: string;
68
+ password?: string;
69
+ /** What no error may carry, beside the key and the password, which never do: a key inside the username (Morph's). */
70
+ secrets?: readonly string[];
71
+ }
62
72
  export interface SshExecOptions {
63
73
  /** The host's own ssh2 package, or anything with the same slice. */
64
74
  ssh2: Ssh2Module;
65
- /** A private key in the PEM armor ssh2 reads (see pemOf). */
66
- privateKey: string;
75
+ /** The login to machine id. */
76
+ loginOf: (id: string) => SshLogin;
67
77
  tunnelOf: SshTunnelOf;
68
78
  }
69
- /** MachineHost.exec over SSH: argv as root, as channels on one connection per machine, shared by its execs. */
79
+ /** MachineHost.exec over SSH: argv as the host's login, as channels on one connection per machine, shared by its execs. */
70
80
  export declare class SshExec {
71
81
  #private;
72
- constructor({ ssh2, privateKey, tunnelOf }: SshExecOptions);
82
+ constructor({ ssh2, loginOf, tunnelOf }: SshExecOptions);
73
83
  /** Ends every connection to machine id, channels and all: the vendor calls it once the machine is deleted. */
74
84
  closeAll(id: string): void;
75
85
  /**
76
- * argv as root over SSH, under WRAPPER, as one channel on the machine's shared connection (#start). stdout and
77
- * stderr are the channel's, piped; end sends end of file. wait answers once the channel closes, with the
86
+ * argv as the host's login over SSH, under WRAPPER, as one channel on the machine's shared connection (#start).
87
+ * stdout and stderr are the channel's, piped; end sends end of file. wait answers once the channel closes, with the
78
88
  * exit-status, or -1 for an exit by signal or none. kill ends the process group over a channel of its own (on a
79
89
  * connection with room), then closes the exec's channel, never a connection; if the close does not come, wait
80
90
  * answers -1 and the connection takes no new channel.
@@ -1,11 +1,12 @@
1
- // Agent37's SSH exec: its instances are reached over SSH (as root, one connection per process, under a wrapper that
2
- // names the process group), through the stream agent37.ts gives to each instance's sshd (its WebSocket tunnel), and
3
- // this is its MachineHost.exec. The host's own ssh2 package does the protocol; this package names only the slice it
4
- // uses (Ssh2Module) and imports nothing at load.
1
+ // MachineHost.exec over SSH, for a vendor whose machines run an sshd: one connection per machine shared by its execs,
2
+ // each process under a wrapper that names its process group, through the stream the host gives to the machine's sshd
3
+ // (Agent37's WebSocket tunnel) and as the login the host gives (Agent37's root and key). Every error it throws or
4
+ // rejects with is redacted of the login's secrets. The host's own ssh2 package does the protocol; this package names
5
+ // only the slice it uses (Ssh2Module) and imports nothing at load.
5
6
  import { randomBytes } from "node:crypto";
6
7
  import { PassThrough } from "node:stream";
7
- import { boundOf } from "./hosted/process.js";
8
- import { shellLine } from "./hosted/scripts.js";
8
+ import { boundOf, redact } from "./process.js";
9
+ import { shellLine } from "./scripts.js";
9
10
  /**
10
11
  * ssh2's keepalive, which also keeps the edge from seeing an idle tunnel (the CLI's ServerAliveInterval is 60 s, cli.js:32).
11
12
  * ssh2 pings every KEEPALIVE_MS and ends the connection at the tick after KEEPALIVE_COUNT_MAX pings went unanswered
@@ -66,19 +67,19 @@ const isBound = (error) => {
66
67
  const name = error?.name;
67
68
  return name === "TimeoutError" || name === "AbortError";
68
69
  };
69
- /** MachineHost.exec over SSH: argv as root, as channels on one connection per machine, shared by its execs. */
70
+ /** MachineHost.exec over SSH: argv as the host's login, as channels on one connection per machine, shared by its execs. */
70
71
  export class SshExec {
71
72
  #ssh2;
72
- #privateKey;
73
+ #loginOf;
73
74
  #tunnelOf;
74
75
  /**
75
76
  * The SSH connections to each machine, opening, open, or done and still held, until each ends: one, and a second
76
77
  * past CHANNELS_PER_CONNECTION channels. A done one takes no new channel; closeAll ends them all.
77
78
  */
78
79
  #links = new Map();
79
- constructor({ ssh2, privateKey, tunnelOf }) {
80
+ constructor({ ssh2, loginOf, tunnelOf }) {
80
81
  this.#ssh2 = ssh2;
81
- this.#privateKey = privateKey;
82
+ this.#loginOf = loginOf;
82
83
  this.#tunnelOf = tunnelOf;
83
84
  }
84
85
  /** Ends every connection to machine id, channels and all: the vendor calls it once the machine is deleted. */
@@ -87,10 +88,11 @@ export class SshExec {
87
88
  this.#end(link);
88
89
  }
89
90
  /**
90
- * An SSH session as root over the instance's tunnel, its handshake within ctx. A tunnel that fails to open, or closes
91
- * before the SSH handshake, is opened again after a pause, TUNNEL_TRIES times in all within ctx: an instance fresh
92
- * from its create can refuse the first (seen live once in eight creates, the daemon's upload refused). Nothing has
93
- * run before a handshake, so a retry repeats nothing. A refused key or a handshake past its bound is not retried.
91
+ * An SSH session as the host's login over the machine's tunnel, its handshake within ctx. A tunnel that fails to
92
+ * open, or closes before the SSH handshake, is opened again after a pause, TUNNEL_TRIES times in all within ctx: an
93
+ * instance fresh from its create can refuse the first (seen live once in eight creates, the daemon's upload
94
+ * refused). Nothing has run before a handshake, so a retry repeats nothing. A refused key or a handshake past its
95
+ * bound is not retried.
94
96
  */
95
97
  async #ssh(id, ctx) {
96
98
  const bound = boundOf(ctx.timeoutMs, ctx.signal, `the SSH connection to ${id}`);
@@ -136,13 +138,14 @@ export class SshExec {
136
138
  quit(givenUp());
137
139
  };
138
140
  stop.addEventListener("abort", drop, { once: true });
141
+ const { username, privateKey, password } = this.#loginOf(id);
139
142
  try {
140
143
  await Promise.race([opened, quitted]);
141
144
  await Promise.race([
142
145
  new Promise((resolve, reject) => {
143
146
  client.once("ready", resolve);
144
147
  client.once("error", reject);
145
- client.connect({ sock: duplex, username: "root", privateKey: this.#privateKey, readyTimeout: timeoutMs, keepaliveInterval: KEEPALIVE_MS, keepaliveCountMax: KEEPALIVE_COUNT_MAX });
148
+ client.connect({ sock: duplex, username, privateKey, password, readyTimeout: timeoutMs, keepaliveInterval: KEEPALIVE_MS, keepaliveCountMax: KEEPALIVE_COUNT_MAX });
146
149
  }),
147
150
  quitted,
148
151
  ]);
@@ -333,15 +336,31 @@ export class SshExec {
333
336
  }
334
337
  }
335
338
  /**
336
- * argv as root over SSH, under WRAPPER, as one channel on the machine's shared connection (#start). stdout and
337
- * stderr are the channel's, piped; end sends end of file. wait answers once the channel closes, with the
339
+ * error with machine id's login secrets taken out of its message and stack, in place: its class, name and fields stay,
340
+ * which the adapter reads its code by. ssh2's words can carry the username, and a host's may hold a key.
341
+ */
342
+ #redacted(id, error) {
343
+ const { privateKey, password, secrets = [] } = this.#loginOf(id);
344
+ const hidden = [privateKey, password, ...secrets];
345
+ if (!(error instanceof Error))
346
+ return new Error(redact(String(error), hidden));
347
+ error.message = redact(error.message, hidden);
348
+ if (error.stack !== undefined)
349
+ error.stack = redact(error.stack, hidden);
350
+ return error;
351
+ }
352
+ /**
353
+ * argv as the host's login over SSH, under WRAPPER, as one channel on the machine's shared connection (#start).
354
+ * stdout and stderr are the channel's, piped; end sends end of file. wait answers once the channel closes, with the
338
355
  * exit-status, or -1 for an exit by signal or none. kill ends the process group over a channel of its own (on a
339
356
  * connection with room), then closes the exec's channel, never a connection; if the close does not come, wait
340
357
  * answers -1 and the connection takes no new channel.
341
358
  */
342
359
  async exec(id, argv, ctx) {
343
360
  const pidFile = `/tmp/.agentrun-exec-${randomBytes(8).toString("hex")}`;
344
- const opened = await this.#start(id, shellLine(["sh", "-c", WRAPPER, pidFile, ...argv]), ctx, `the exec in ${id}`);
361
+ const opened = await this.#start(id, shellLine(["sh", "-c", WRAPPER, pidFile, ...argv]), ctx, `the exec in ${id}`).catch((error) => {
362
+ throw this.#redacted(id, error);
363
+ });
345
364
  const { link: held, channel } = opened;
346
365
  const stdout = new PassThrough();
347
366
  const stderr = new PassThrough();
@@ -367,7 +386,7 @@ export class SshExec {
367
386
  write: (bytes) => new Promise((resolve, reject) => {
368
387
  if (ended || closed)
369
388
  return reject(new Error(ended ? "stdin was ended" : "the process has ended"));
370
- channel.write(bytes, (error) => (error ? reject(error) : resolve()));
389
+ channel.write(bytes, (error) => (error ? reject(this.#redacted(id, error)) : resolve()));
371
390
  }),
372
391
  end: async () => {
373
392
  if (ended || closed)
@@ -1,5 +1,26 @@
1
+ import type { HostFacts } from "../host.js";
2
+ import type { ComputerSpec, Refusal } from "../provider.js";
1
3
  /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
2
4
  export declare const DOMAIN: RegExp;
3
5
  export declare const isWhole: (value: unknown) => value is number;
6
+ /** A vendor whose computer has its image's size: a spec's cpus or memoryMb, refused in words (computer: "an E2B computer"). */
7
+ export declare function sizeRefusals(spec: Partial<ComputerSpec>, computer: string, image: string): Refusal[];
4
8
  /** 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
9
  export declare function dateOf(value: unknown, unit?: "ms" | "s"): Date | undefined;
10
+ /** The label a packed machine is listed by (packLabels): its value is the machine's name, MachineRequest.name. */
11
+ export declare const PACKED_NAME = "agentrun";
12
+ /**
13
+ * A machine's labels as a vendor whose labels can't hold them as they are stores them (facts.labels.packed): a cap of 5
14
+ * tags, Kubernetes' values, Cloudflare's 16-byte names, a list of strings. PACKED_NAME, the one label a host's list
15
+ * filters on, holds name; the whole map, as JSON, deflated and base64url, goes in parts of at most valueBytes. Every name
16
+ * is at most 11 bytes of [a-z0-9-], every value [A-Za-z0-9_-] with a letter or digit at each end, and no "=", so a
17
+ * host of a string list stores each as name=value. unpackLabels reads the map back exactly. A map that does not fit
18
+ * room (count, bytes and valueBytes, of the packed labels), or whose JSON is past PACKED_JSON_MAX, is refused in words.
19
+ */
20
+ export declare function packLabels(labels: Record<string, string>, name: string, room?: HostFacts["labels"]): {
21
+ labels: Record<string, string>;
22
+ } | {
23
+ problem: string;
24
+ };
25
+ /** The labels packLabels packed in stored, exactly; undefined where stored holds no packed map (a machine not the adapter's). */
26
+ export declare function unpackLabels(stored: Record<string, string>): Record<string, string> | undefined;
@@ -1,8 +1,63 @@
1
+ // Small readings every hosted vendor makes of what its API answers: a whole number, a value in words, a date; and the
2
+ // label codec of a vendor whose labels can't hold the adapter's as they are.
3
+ import { deflateRawSync, inflateRawSync } from "node:zlib";
1
4
  /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
2
5
  export const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
3
6
  export const isWhole = (value) => typeof value === "number" && Number.isSafeInteger(value);
7
+ /** A vendor whose computer has its image's size: a spec's cpus or memoryMb, refused in words (computer: "an E2B computer"). */
8
+ export function sizeRefusals(spec, computer, image) {
9
+ return ["cpus", "memoryMb"].filter((field) => spec[field] !== undefined).map((field) => ({ field, message: `${computer} has the size of its ${image}: name a ${image} of the size you need, not ${field}` }));
10
+ }
4
11
  /** 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
12
  export function dateOf(value, unit = "ms") {
6
13
  const at = value instanceof Date ? value.getTime() : typeof value === "string" ? Date.parse(value) : isWhole(value) ? value * (unit === "s" ? 1000 : 1) : Number.NaN;
7
14
  return Number.isNaN(at) ? undefined : new Date(at);
8
15
  }
16
+ /** The label a packed machine is listed by (packLabels): its value is the machine's name, MachineRequest.name. */
17
+ export const PACKED_NAME = "agentrun";
18
+ /** The packed map's parts: agentrun-0, agentrun-1, and on. */
19
+ const PART = `${PACKED_NAME}-`;
20
+ /** The most bytes of a packed map's JSON: unpackLabels inflates no more. */
21
+ const PACKED_JSON_MAX = 1 << 20;
22
+ /**
23
+ * A machine's labels as a vendor whose labels can't hold them as they are stores them (facts.labels.packed): a cap of 5
24
+ * tags, Kubernetes' values, Cloudflare's 16-byte names, a list of strings. PACKED_NAME, the one label a host's list
25
+ * filters on, holds name; the whole map, as JSON, deflated and base64url, goes in parts of at most valueBytes. Every name
26
+ * is at most 11 bytes of [a-z0-9-], every value [A-Za-z0-9_-] with a letter or digit at each end, and no "=", so a
27
+ * host of a string list stores each as name=value. unpackLabels reads the map back exactly. A map that does not fit
28
+ * room (count, bytes and valueBytes, of the packed labels), or whose JSON is past PACKED_JSON_MAX, is refused in words.
29
+ */
30
+ export function packLabels(labels, name, room = {}) {
31
+ const json = Buffer.from(JSON.stringify(labels));
32
+ if (json.length > PACKED_JSON_MAX)
33
+ return { problem: `its labels come to ${json.length} bytes as JSON, past the ${PACKED_JSON_MAX} a packed map holds` };
34
+ const payload = deflateRawSync(json).toString("base64url");
35
+ const { count, bytes, packed } = room;
36
+ // base64url can begin or end with - or _, which a Kubernetes value can't: each part is wrapped in a letter.
37
+ const size = (packed?.valueBytes ?? payload.length + 2) - 2;
38
+ if (size < 1 || Buffer.byteLength(name) > size + 2)
39
+ return { problem: `its labels' values hold at most ${packed?.valueBytes} bytes, too few for the name ${name} and a part of the rest` };
40
+ const parts = [];
41
+ for (let at = 0; at < payload.length; at += size)
42
+ parts.push([`${PART}${parts.length}`, `p${payload.slice(at, at + size)}p`]);
43
+ const all = [[PACKED_NAME, name], ...parts];
44
+ const total = all.reduce((sum, [key, value]) => sum + key.length + Buffer.byteLength(value), 0);
45
+ if ((count !== undefined && all.length > count) || (bytes !== undefined && total > bytes))
46
+ return { problem: `its labels pack into ${all.length} labels of ${total} bytes in all, past the ${[count === undefined ? "" : `${count} labels`, bytes === undefined ? "" : `${bytes} bytes`].filter(Boolean).join(" and ")} it keeps` };
47
+ return { labels: Object.fromEntries(all) };
48
+ }
49
+ /** The labels packLabels packed in stored, exactly; undefined where stored holds no packed map (a machine not the adapter's). */
50
+ export function unpackLabels(stored) {
51
+ let payload = "";
52
+ for (let part = 0; stored[`${PART}${part}`] !== undefined; part++)
53
+ payload += stored[`${PART}${part}`]?.slice(1, -1);
54
+ if (payload === "")
55
+ return undefined;
56
+ try {
57
+ const map = JSON.parse(inflateRawSync(Buffer.from(payload, "base64url"), { maxOutputLength: PACKED_JSON_MAX }).toString());
58
+ return typeof map === "object" && map !== null && !Array.isArray(map) && Object.values(map).every((value) => typeof value === "string") ? map : undefined;
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ }
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
24
24
  export { waitUntil, type WaitOptions } from "./wait.js";
25
25
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
26
26
  export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.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";
27
+ export { AGENT37, AGENT37_BASE_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
28
28
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
29
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";
30
30
  export * from "./conformance/index.js";
package/dist/index.js CHANGED
@@ -28,6 +28,6 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
28
28
  export { waitUntil } from "./wait.js";
29
29
  export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
30
30
  export { defineProvider, descriptorProblems } from "./descriptor.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";
31
+ export { AGENT37, AGENT37_BASE_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
32
32
  export { configurationOf, entryOf, imagesOf, kindOf, kindServed, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
33
33
  export * from "./conformance/index.js";
@@ -2,8 +2,6 @@ import type { ComputerClient } from "./protocol.js";
2
2
  import { type Result } from "./result.js";
3
3
  /** The uid:gid the programs of a remote computer run as by default: the box image's agentrun-tool, no sudo. */
4
4
  export declare const TOOL_USER = "2510:2510";
5
- /** Why a remote provider refuses network open or an allowlist, in words. */
6
- export declare const OWN_NETWORK_ONLY = "a remote computer takes network \"none\" only: its programs run in a network of their own, their loopback alone, so the vendor's agent in it (which runs commands as root) is out of their reach; open and allowlists wait for a proxy out of that network";
7
5
  /**
8
6
  * The drift of a computer's programs' network from their own loopback alone, in words: none when the live interfaces
9
7
  * (up or addressed) of the daemon's network namespace are `lo` alone, else what they are (or that they could not be read).
package/dist/isolation.js CHANGED
@@ -4,14 +4,13 @@
4
4
  // while another process holds the programs' uid, moves itself into a network namespace whose loopback alone is up or
5
5
  // addressed, and refuses vsock and io_uring to every thread (daemon/internal/isolate). A kernel with the tunnel modules
6
6
  // loaded also gives that namespace its fallback tunnels (tunl0, gre0, sit0, ...), down with no address; no program can
7
- // raise them, holding no CAP_NET_ADMIN, and the read-back here proves it through computerd's probe. Network "none" is
8
- // all such a computer takes until a proxy carries open and allowlists out of that namespace.
7
+ // raise them, holding no CAP_NET_ADMIN, and the read-back here proves it through computerd's probe. Under network "open"
8
+ // or a list the namespace is the same: init's relay on its loopback carries the programs' connections out over a Unix
9
+ // socket to the egress proxy init started outside it (hosted/network.ts), which goes to the public internet alone.
9
10
  import { DAEMON_IN_COMPUTER } from "./drift.js";
10
11
  import { fail, failAs, ok } from "./result.js";
11
12
  /** The uid:gid the programs of a remote computer run as by default: the box image's agentrun-tool, no sudo. */
12
13
  export const TOOL_USER = "2510:2510";
13
- /** Why a remote provider refuses network open or an allowlist, in words. */
14
- export const OWN_NETWORK_ONLY = 'a remote computer takes network "none" only: its programs run in a network of their own, their loopback alone, so the vendor\'s agent in it (which runs commands as root) is out of their reach; open and allowlists wait for a proxy out of that network';
15
14
  /**
16
15
  * The drift of a computer's programs' network from their own loopback alone, in words: none when the live interfaces
17
16
  * (up or addressed) of the daemon's network namespace are `lo` alone, else what they are (or that they could not be read).
package/dist/modal.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
+ import { type Result } from "./result.js";
2
3
  /**
3
4
  * The SDK's own types, imported as types only: erased at build, so nothing loads the SDK from here. The host passes its
4
5
  * own client (or the constructor), which these name.
@@ -14,8 +15,6 @@ export interface ModalProviderOptions extends Omit<HostedOptions, "kind" | "desk
14
15
  maxLifetimeMs?: number;
15
16
  timeouts?: Partial<HostedTimeouts>;
16
17
  }
17
- /** The runtime a Modal sandbox runs under: vm, or gvisor for a GPU computer (Modal offers GPUs on gVisor only). */
18
- export type ModalRuntime = "vm" | "gvisor";
19
18
  /** The SDK's default server (modal-client@64880502:js/src/config.ts:143). */
20
19
  export declare const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com:443";
21
20
  /** What modalClient gives the SDK's ModalClient: the token, explicitly, so the SDK fills none of it in. */
@@ -71,5 +70,12 @@ export declare const conformance: () => Promise<typeof import("./conformance/mod
71
70
  * memoryMb) and name the uid its programs run as, never root.
72
71
  */
73
72
  export declare class ModalProvider extends HostedProvider {
73
+ /**
74
+ * The provider contract's prepareImage (its descriptor declares it): the box image the release publishes, by its
75
+ * public registry tag (box-image.ts), which has the Archil client and its root helper. No call: Modal pulls a
76
+ * registry tag at the first create from it in a workspace (images.fromRegistry), so there is nothing to pull ahead of
77
+ * it, and onWait is never told (the claim's wait is the create's). A sandbox with GPUs starts from the same image.
78
+ */
79
+ prepareImage(): Promise<Result<string>>;
74
80
  constructor(options: ModalProviderOptions);
75
81
  }