@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.60

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 (143) hide show
  1. package/README.md +285 -81
  2. package/box/Dockerfile +4 -3
  3. package/box/install.sh +57 -11
  4. package/dist/agent37.d.ts +11 -4
  5. package/dist/agent37.js +217 -19
  6. package/dist/attach.d.ts +24 -4
  7. package/dist/attach.js +50 -19
  8. package/dist/boxd.js +22 -9
  9. package/dist/browser.d.ts +56 -11
  10. package/dist/browser.js +76 -17
  11. package/dist/browserbase.d.ts +20 -5
  12. package/dist/browserbase.js +186 -21
  13. package/dist/child-env.d.ts +11 -0
  14. package/dist/child-env.js +22 -0
  15. package/dist/chrome.d.ts +5 -2
  16. package/dist/chrome.js +5 -2
  17. package/dist/cloudflare.d.ts +2 -0
  18. package/dist/cloudflare.js +5 -3
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/computerd.json +1 -1
  22. package/dist/conformance/agent37.d.ts +20 -40
  23. package/dist/conformance/agent37.js +31 -118
  24. package/dist/conformance/archil.d.ts +13 -3
  25. package/dist/conformance/archil.js +22 -17
  26. package/dist/conformance/boxd.d.ts +8 -31
  27. package/dist/conformance/boxd.js +19 -74
  28. package/dist/conformance/browserbase.d.ts +3 -6
  29. package/dist/conformance/browserbase.js +6 -17
  30. package/dist/conformance/cases/health.js +6 -3
  31. package/dist/conformance/cases/provider.js +4 -1
  32. package/dist/conformance/cli.d.ts +3 -1
  33. package/dist/conformance/cli.js +69 -9
  34. package/dist/conformance/cloudflare.d.ts +3 -6
  35. package/dist/conformance/cloudflare.js +7 -15
  36. package/dist/conformance/daytona.d.ts +6 -20
  37. package/dist/conformance/daytona.js +22 -57
  38. package/dist/conformance/dial-only.d.ts +4 -3
  39. package/dist/conformance/dial-only.js +3 -3
  40. package/dist/conformance/docker.d.ts +4 -5
  41. package/dist/conformance/docker.js +8 -14
  42. package/dist/conformance/e2b.d.ts +10 -36
  43. package/dist/conformance/e2b.js +27 -84
  44. package/dist/conformance/fly.d.ts +3 -6
  45. package/dist/conformance/fly.js +2 -6
  46. package/dist/conformance/groundbox.d.ts +7 -23
  47. package/dist/conformance/groundbox.js +16 -56
  48. package/dist/conformance/index.d.ts +1 -0
  49. package/dist/conformance/index.js +1 -0
  50. package/dist/conformance/kernel.d.ts +3 -6
  51. package/dist/conformance/kernel.js +5 -15
  52. package/dist/conformance/kind.d.ts +0 -6
  53. package/dist/conformance/kind.js +0 -4
  54. package/dist/conformance/local-chrome.d.ts +5 -7
  55. package/dist/conformance/local-chrome.js +7 -11
  56. package/dist/conformance/modal.d.ts +10 -38
  57. package/dist/conformance/modal.js +27 -74
  58. package/dist/conformance/module-kit.d.ts +87 -0
  59. package/dist/conformance/module-kit.js +88 -0
  60. package/dist/conformance/morph.d.ts +7 -23
  61. package/dist/conformance/morph.js +20 -66
  62. package/dist/conformance/orgo.d.ts +5 -10
  63. package/dist/conformance/orgo.js +15 -27
  64. package/dist/conformance/phone-harness.d.ts +3 -5
  65. package/dist/conformance/phone-harness.js +3 -11
  66. package/dist/conformance/runner.d.ts +13 -3
  67. package/dist/conformance/runner.js +32 -11
  68. package/dist/conformance/smolcloud.d.ts +7 -23
  69. package/dist/conformance/smolcloud.js +16 -49
  70. package/dist/conformance/sweep.d.ts +10 -5
  71. package/dist/conformance/sweep.js +91 -38
  72. package/dist/conformance/tti.d.ts +69 -0
  73. package/dist/conformance/tti.js +205 -0
  74. package/dist/conformance/types.d.ts +9 -2
  75. package/dist/daytona.js +60 -20
  76. package/dist/descriptor.d.ts +37 -0
  77. package/dist/descriptor.js +9 -0
  78. package/dist/descriptors/agent37.d.ts +4 -1
  79. package/dist/descriptors/agent37.js +5 -2
  80. package/dist/descriptors/browserbase.d.ts +3 -0
  81. package/dist/descriptors/browserbase.js +4 -0
  82. package/dist/descriptors/docker.d.ts +2 -0
  83. package/dist/descriptors/docker.js +5 -0
  84. package/dist/descriptors/env-names.d.ts +32 -0
  85. package/dist/descriptors/env-names.js +60 -0
  86. package/dist/descriptors/index.d.ts +14 -3
  87. package/dist/descriptors/kernel.d.ts +3 -0
  88. package/dist/descriptors/kernel.js +2 -0
  89. package/dist/descriptors/local-chrome.d.ts +1 -1
  90. package/dist/descriptors/local-chrome.js +5 -3
  91. package/dist/descriptors/phone-harness.d.ts +1 -1
  92. package/dist/descriptors/phone-harness.js +4 -2
  93. package/dist/docker/egress.d.ts +7 -0
  94. package/dist/docker/egress.js +8 -0
  95. package/dist/docker/image.d.ts +5 -1
  96. package/dist/docker/image.js +12 -8
  97. package/dist/docker.d.ts +52 -13
  98. package/dist/docker.js +166 -92
  99. package/dist/drift.js +6 -6
  100. package/dist/e2b.d.ts +2 -2
  101. package/dist/e2b.js +2 -3
  102. package/dist/groundbox.js +6 -6
  103. package/dist/host.d.ts +23 -0
  104. package/dist/hosted/download.d.ts +23 -0
  105. package/dist/hosted/download.js +144 -0
  106. package/dist/hosted/process.d.ts +5 -0
  107. package/dist/hosted/process.js +20 -0
  108. package/dist/hosted/provider.js +120 -48
  109. package/dist/hosted/rest.d.ts +19 -8
  110. package/dist/hosted/rest.js +47 -14
  111. package/dist/hosted/scripts.d.ts +10 -0
  112. package/dist/hosted/scripts.js +23 -2
  113. package/dist/hosted/ssh-exec.d.ts +7 -1
  114. package/dist/hosted/ssh-exec.js +19 -14
  115. package/dist/hosted/ssh-key.d.ts +18 -0
  116. package/dist/hosted/ssh-key.js +36 -0
  117. package/dist/index.d.ts +5 -3
  118. package/dist/index.js +4 -2
  119. package/dist/janitor.d.ts +7 -1
  120. package/dist/janitor.js +2 -2
  121. package/dist/kernel.d.ts +14 -4
  122. package/dist/kernel.js +141 -18
  123. package/dist/local-chrome.d.ts +12 -3
  124. package/dist/local-chrome.js +108 -10
  125. package/dist/local-supervisor.js +1 -0
  126. package/dist/modal.d.ts +6 -5
  127. package/dist/modal.js +7 -7
  128. package/dist/morph.js +5 -8
  129. package/dist/orgo-channel.d.ts +3 -2
  130. package/dist/orgo-channel.js +3 -3
  131. package/dist/orgo-desktop.js +2 -4
  132. package/dist/orgo.d.ts +6 -0
  133. package/dist/orgo.js +158 -15
  134. package/dist/phone-harness.d.ts +7 -5
  135. package/dist/phone-harness.js +60 -61
  136. package/dist/protocol.d.ts +10 -0
  137. package/dist/protocol.js +17 -0
  138. package/dist/provider.d.ts +6 -2
  139. package/dist/screen-watch.d.ts +6 -1
  140. package/dist/screen-watch.js +166 -12
  141. package/dist/vendor-sdk.d.ts +9 -0
  142. package/dist/vendor-sdk.js +26 -0
  143. package/package.json +8 -1
@@ -1,4 +1,4 @@
1
- import { type ComputerErrorCode, type Result } from "../result.js";
1
+ import { type ComputerError, type ComputerErrorCode, type Result } from "../result.js";
2
2
  /**
3
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
4
  * else vendor; 409 is exists on a call that carries the machine's name (RestInit.named).
@@ -37,6 +37,8 @@ export interface RestOptions {
37
37
  fetch?: typeof fetch;
38
38
  /** The bound of a call that gives none. */
39
39
  timeoutMs: number;
40
+ /** A signal that fires after ms, which bounds a call; default a timer. Tests give one they fire. */
41
+ timeout?: (ms: number) => AbortSignal;
40
42
  retry?: {
41
43
  attempts: number;
42
44
  baseMs: number;
@@ -55,6 +57,13 @@ export interface RestOptions {
55
57
  }
56
58
  /** The JSON a body holds; null for none or for text that is not JSON. */
57
59
  export declare function jsonOf(bytes: Uint8Array): unknown;
60
+ /**
61
+ * A call's failure. `redirect` marks one the API answered with a redirect, refused unfollowed: its answer is unread,
62
+ * so the vendor may have acted on the call (a 303 after a create is the usual answer to a POST).
63
+ */
64
+ export interface RestError extends ComputerError {
65
+ redirect?: true;
66
+ }
58
67
  /** An accepted answer whose body is read as it comes: an event stream. */
59
68
  export interface RestStream {
60
69
  status: number;
@@ -62,20 +71,22 @@ export interface RestStream {
62
71
  }
63
72
  export interface Rest {
64
73
  url(path: string): string;
65
- call(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<RestAnswer>>;
74
+ call(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<RestAnswer, RestError>>;
66
75
  /** call, with the body read as JSON (null for none). */
67
- json(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<unknown>>;
76
+ json(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<unknown, RestError>>;
68
77
  /**
69
78
  * call, with an accepted answer's body handed back unread, as it comes (a process's events). The bound covers the
70
79
  * answer's start alone: the body has none but the caller's signal, which ends it too.
71
80
  */
72
- stream(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<RestStream>>;
81
+ stream(method: string, url: string, init?: RestInit, signal?: AbortSignal): Promise<Result<RestStream, RestError>>;
73
82
  }
74
83
  /**
75
- * An API's https base URL, with no trailing slash, so a key never crosses in the clear; throws in words on another,
76
- * loopback http included. Every provider that takes a URL from its caller and sends a key to it takes the URL through
77
- * it: Agent37, boxd, Browserbase, the Cloudflare relay, Daytona, Groundbox, Kernel, Modal, Morph, Orgo, the phone
78
- * harness and smol cloud. E2B takes a host name and Fly nothing, and each builds its https URL itself.
84
+ * An API's https base URL: its origin and path, normalized, with no trailing slash. Throws in words on another scheme,
85
+ * loopback http included, so a key never crosses in the clear, and on a user or password, a query or a fragment, which
86
+ * no provider's API takes. Every provider that takes a URL from its caller and sends a key to it takes the URL through
87
+ * it: Agent37, boxd, Browserbase, the Cloudflare relay, Daytona (and the toolbox URL Daytona answers with), Groundbox,
88
+ * Kernel, Modal, Morph, Orgo, the phone harness and smol cloud, and so does each sweep scope that names one. E2B takes a
89
+ * host name and Fly nothing, and each builds its https URL itself.
79
90
  */
80
91
  export declare function httpsBase(url: string, what: string): string;
81
92
  export declare function rest(options: RestOptions): Rest;
@@ -40,12 +40,28 @@ function redirected(cause) {
40
40
  const inner = cause?.cause;
41
41
  return /redirect/i.test(`${cause?.message ?? ""} ${inner?.message ?? ""}`);
42
42
  }
43
+ /**
44
+ * An answer's body. One that is not a 2xx keeps its status when its words break off, unless the bound or the caller cut
45
+ * them: the status is the vendor's answer, the words only explain it.
46
+ */
47
+ async function bytesOf(response, cut) {
48
+ try {
49
+ return new Uint8Array(await response.arrayBuffer());
50
+ }
51
+ catch (error) {
52
+ if (response.ok || cut.aborted)
53
+ throw error;
54
+ return new Uint8Array();
55
+ }
56
+ }
43
57
  const NO_BODY = { async *[Symbol.asyncIterator]() { } };
44
58
  /**
45
- * An API's https base URL, with no trailing slash, so a key never crosses in the clear; throws in words on another,
46
- * loopback http included. Every provider that takes a URL from its caller and sends a key to it takes the URL through
47
- * it: Agent37, boxd, Browserbase, the Cloudflare relay, Daytona, Groundbox, Kernel, Modal, Morph, Orgo, the phone
48
- * harness and smol cloud. E2B takes a host name and Fly nothing, and each builds its https URL itself.
59
+ * An API's https base URL: its origin and path, normalized, with no trailing slash. Throws in words on another scheme,
60
+ * loopback http included, so a key never crosses in the clear, and on a user or password, a query or a fragment, which
61
+ * no provider's API takes. Every provider that takes a URL from its caller and sends a key to it takes the URL through
62
+ * it: Agent37, boxd, Browserbase, the Cloudflare relay, Daytona (and the toolbox URL Daytona answers with), Groundbox,
63
+ * Kernel, Modal, Morph, Orgo, the phone harness and smol cloud, and so does each sweep scope that names one. E2B takes a
64
+ * host name and Fly nothing, and each builds its https URL itself.
49
65
  */
50
66
  export function httpsBase(url, what) {
51
67
  let parsed;
@@ -53,11 +69,19 @@ export function httpsBase(url, what) {
53
69
  parsed = new URL(url);
54
70
  }
55
71
  catch {
56
- throw new Error(`${what} is not a URL: ${JSON.stringify(url)}`);
72
+ // Nothing of the string is echoed: it may carry a key in its query.
73
+ throw new Error(`${what} is not a URL`);
57
74
  }
58
75
  if (parsed.protocol !== "https:")
59
76
  throw new Error(`${what} must be https, so the key never crosses in the clear: ${parsed.protocol}`);
60
- return url.replace(/\/+$/, "");
77
+ // The words give the origin alone: a user, a password or a query may be a key.
78
+ if (parsed.username !== "" || parsed.password !== "")
79
+ throw new Error(`${what} takes no user or password, since the key goes to it: ${parsed.origin}`);
80
+ if (parsed.search !== "" || parsed.hash !== "")
81
+ throw new Error(`${what} takes no query or fragment: ${parsed.origin}`);
82
+ // The normalized form (lower-case scheme and host, a default port dropped), so a consumer that reads the scheme
83
+ // case-sensitively, as nice-grpc does for Modal's server, sees https.
84
+ return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
61
85
  }
62
86
  export function rest(options) {
63
87
  const base = options.base.replace(/\/+$/, "");
@@ -74,22 +98,28 @@ export function rest(options) {
74
98
  return fail("aborted", `${what} was aborted`);
75
99
  // A bound that lets go once the answer is taken, so a body read after it (a stream's) is never cut by it.
76
100
  const timeout = new AbortController();
77
- const timer = setTimeout(() => timeout.abort(), timeoutMs);
101
+ const cut = () => timeout.abort();
102
+ const bound = options.timeout?.(timeoutMs);
103
+ const timer = bound === undefined ? setTimeout(cut, timeoutMs) : undefined;
104
+ if (bound?.aborted)
105
+ cut();
106
+ bound?.addEventListener("abort", cut, { once: true });
78
107
  let failure;
79
108
  let retryable;
80
109
  try {
81
110
  const headers = init.json === undefined ? options.headers() : { ...options.headers(), "Content-Type": "application/json" };
111
+ const either = signal ? AbortSignal.any([signal, timeout.signal]) : timeout.signal;
82
112
  // Never a redirect: a followed one keeps the key, and could carry a call to another host.
83
113
  const response = await fetcher(url, {
84
114
  method,
85
115
  headers,
86
116
  body: init.json === undefined ? (init.bytes ?? init.form) : JSON.stringify(init.json),
87
117
  redirect: "error",
88
- signal: signal ? AbortSignal.any([signal, timeout.signal]) : timeout.signal,
118
+ signal: either,
89
119
  });
90
120
  if (accepted(response.status))
91
- return ok(await take(response));
92
- const bytes = new Uint8Array(await response.arrayBuffer());
121
+ return ok(await take(response, either));
122
+ const bytes = await bytesOf(response, either);
93
123
  const own = typeof init.retry === "function";
94
124
  retryable = own ? init.retry(response.status, bytes) : init.retry === true && (response.status === 429 || response.status >= 500);
95
125
  const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
@@ -102,21 +132,24 @@ export function rest(options) {
102
132
  // No answer: the request may have reached the vendor, so only a call that may run twice is sent again.
103
133
  retryable = init.retry === true;
104
134
  if (timeout.signal.aborted)
105
- failure = { code: "timeout", message: `${what} did not answer within ${timeoutMs / 1000} s` };
106
- else if (redirected(cause))
107
- return vendorFail(options.vendor, `${what}: the API answered with a redirect, which is never followed: it would carry the key`);
135
+ failure = { code: "timeout", message: `${what} did not answer within ${Math.round(timeoutMs / 100) / 10} s` };
136
+ else if (redirected(cause)) {
137
+ const message = `${what}: the API answered with a redirect, which is never followed: it would carry the key`;
138
+ return { ok: false, error: { code: "vendor", vendor: options.vendor, message, redirect: true } };
139
+ }
108
140
  else
109
141
  failure = { code: "vendor", vendor: options.vendor, message: `${what}: ${cause.message}` };
110
142
  }
111
143
  finally {
112
144
  clearTimeout(timer);
145
+ bound?.removeEventListener("abort", cut);
113
146
  }
114
147
  if (!retryable || attempt >= attempts)
115
148
  return { ok: false, error: failure };
116
149
  await wait((options.retry?.baseMs ?? 0) * 2 ** (attempt - 1), signal);
117
150
  }
118
151
  }
119
- const call = (method, url, init = {}, signal) => exchange(method, url, init, signal, async (response) => ({ status: response.status, bytes: new Uint8Array(await response.arrayBuffer()) }));
152
+ const call = (method, url, init = {}, signal) => exchange(method, url, init, signal, async (response, cut) => ({ status: response.status, bytes: await bytesOf(response, cut) }));
120
153
  return {
121
154
  url: (path) => `${base}${path}`,
122
155
  call,
@@ -1,6 +1,8 @@
1
1
  import { PassThrough } from "node:stream";
2
2
  import type { ComputerCapabilities, ComputerConnection } from "../provider.js";
3
3
  import { type Result } from "../result.js";
4
+ /** Root for what follows: the command's own user when it is root, else passwordless sudo, which the install checked. */
5
+ export declare const ROOT = "p=; [ \"$(id -u)\" = 0 ] || p=\"sudo -n\"";
4
6
  /** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
5
7
  export declare function installerOf(output: string): string | undefined;
6
8
  /** One word for a shell, single-quoted. */
@@ -13,6 +15,12 @@ export declare const shellLine: (argv: readonly string[]) => string;
13
15
  export declare const AGENTRUN_DIAL = "/usr/local/bin/agentrun-dial";
14
16
  /** Where start leaves what init writes, root's alone: the words a create that never hears the daemon gives back. */
15
17
  export declare const INIT_LOG = "/run/agentrun-init.log";
18
+ /** Where read-stage leaves its copies: a directory root's alone (0700) in /run, which no other user can write. */
19
+ export declare const READ_COPIES = "/run/agentrun-read";
20
+ /** The read-stage argv: path copied to copy, read as uid:gid. */
21
+ export declare const readStage: (uid: string, gid: string, path: string, copy: string) => string[];
22
+ /** The read-unstage argv: copy removed. */
23
+ export declare const readUnstage: (copy: string) => string[];
16
24
  /**
17
25
  * The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
18
26
  * namespace cuts: every child host's create closes them to the computer's user before init starts. The window
@@ -119,6 +127,8 @@ export interface DaemonExpected {
119
127
  * working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
120
128
  */
121
129
  export declare function daemonDrift(connection: ComputerConnection, expected: DaemonExpected, timeoutMs: number, signal?: AbortSignal): Promise<Result<string[]>>;
130
+ /** The echo of the running sh's pid and start time: PID_WRAPPER's line on stderr, and Groundbox's pid record in a file. */
131
+ export declare const PID_ECHO = "echo \"$$ $(s=$(cat /proc/$$/stat) && set -- ${s##*\") \"} && echo \"${20}\")\"";
122
132
  /**
123
133
  * The sh a process starts under where the vendor has no kill that ends it (framedExec with no kill, SSH, Modal): one
124
134
  * line on stderr, its pid and its start time (field 22 of /proc/<pid>/stat, counted past the command's name in
@@ -12,7 +12,7 @@ import { fail, ok } from "../result.js";
12
12
  const PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
13
13
  const CAPS = ["CapInh", "CapPrm", "CapEff", "CapBnd", "CapAmb"];
14
14
  /** Root for what follows: the command's own user when it is root, else passwordless sudo, which the install checked. */
15
- const ROOT = 'p=; [ "$(id -u)" = 0 ] || p="sudo -n"';
15
+ export const ROOT = 'p=; [ "$(id -u)" = 0 ] || p="sudo -n"';
16
16
  /** Whether the daemon at d is root's alone: the binary and every directory above it owned by root and writable by no
17
17
  * group or other user (and so no symbolic link, no ACL). Else a user who could rename an entry on the path could put
18
18
  * another binary there, which init and every bridge would run as root. Only root can change an owner or a mode, so a
@@ -101,6 +101,25 @@ export const INIT_LOG = `${SOCKET_DIR}-init.log`;
101
101
  * umask 077, so the log is root's alone whatever the vendor's umask.
102
102
  */
103
103
  const START_SCRIPT = ["# agentrun-computer: start", "l=$1; shift", ROOT, `exec $p sh -c 'umask 077; exec >"$0" 2>&1 </dev/null; setsid "$@" &' "$l" "$@"`].join("\n");
104
+ /** Where read-stage leaves its copies: a directory root's alone (0700) in /run, which no other user can write. */
105
+ export const READ_COPIES = `${SOCKET_DIR}-read`;
106
+ /**
107
+ * read-stage: [uid, gid, path, copy]. Copies path to copy, the file opened as uid:gid with no supplementary groups, as
108
+ * the daemon opens it (setpriv, util-linux), so the copy holds only what the daemon's user can read; root writes the copy
109
+ * under umask 077 in its directory, READ_COPIES. A copy that fails is removed, and the script fails: where setpriv is
110
+ * missing or takes no --reuid, every copy fails, and the daemon reads the file.
111
+ */
112
+ const READ_STAGE_SCRIPT = [
113
+ "# agentrun-computer: read-stage",
114
+ ROOT,
115
+ `exec $p sh -c 'umask 077; mkdir -p "\${3%/*}" && chmod 0700 "\${3%/*}" && setpriv --reuid="$0" --regid="$1" --clear-groups -- cat -- "$2" >"$3" || { rm -f -- "$3"; exit 1; }' "$@"`,
116
+ ].join("\n");
117
+ /** read-unstage: [copy]. Removes a copy read-stage made. */
118
+ const READ_UNSTAGE_SCRIPT = ["# agentrun-computer: read-unstage", ROOT, 'exec $p rm -f -- "$1"'].join("\n");
119
+ /** The read-stage argv: path copied to copy, read as uid:gid. */
120
+ export const readStage = (uid, gid, path, copy) => argvOf(READ_STAGE_SCRIPT, [uid, gid, path, copy]);
121
+ /** The read-unstage argv: copy removed. */
122
+ export const readUnstage = (copy) => argvOf(READ_UNSTAGE_SCRIPT, [copy]);
104
123
  /**
105
124
  * The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
106
125
  * namespace cuts: every child host's create closes them to the computer's user before init starts. The window
@@ -327,12 +346,14 @@ export async function daemonDrift(connection, expected, timeoutMs, signal) {
327
346
  }
328
347
  return ok(found);
329
348
  }
349
+ /** The echo of the running sh's pid and start time: PID_WRAPPER's line on stderr, and Groundbox's pid record in a file. */
350
+ export const PID_ECHO = 'echo "$$ $(s=$(cat /proc/$$/stat) && set -- ${s##*") "} && echo "${20}")"';
330
351
  /**
331
352
  * The sh a process starts under where the vendor has no kill that ends it (framedExec with no kill, SSH, Modal): one
332
353
  * line on stderr, its pid and its start time (field 22 of /proc/<pid>/stat, counted past the command's name in
333
354
  * parentheses, which may hold spaces), then the command in its place, which keeps both. pidLine takes the line off.
334
355
  */
335
- export const PID_WRAPPER = ["sh", "-c", 'echo "$$ $(s=$(cat /proc/$$/stat) && set -- ${s##*") "} && echo "${20}")" >&2; exec "$@"', "sh"];
356
+ export const PID_WRAPPER = ["sh", "-c", `${PID_ECHO} >&2; exec "$@"`, "sh"];
336
357
  /**
337
358
  * The sh pidKill starts, given the pid and start time: a pid whose process has ended, and may be another's now, is let
338
359
  * be. Otherwise it kills the process and every process under it (an upload's head and base64 would wait on the open
@@ -75,11 +75,17 @@ export interface SshExecOptions {
75
75
  /** The login to machine id. */
76
76
  loginOf: (id: string) => SshLogin;
77
77
  tunnelOf: SshTunnelOf;
78
+ /**
79
+ * Until when (ms since the epoch) a login machine id's sshd refuses is tried again, every DENIED_RETRY_MS within the
80
+ * call's bound: a key the vendor is still handing its machines (Agent37's, minutes after its registration). Absent,
81
+ * or past: a refused login fails at once.
82
+ */
83
+ deniedUntil?: (id: string) => number;
78
84
  }
79
85
  /** MachineHost.exec over SSH: argv as the host's login, as channels on one connection per machine, shared by its execs. */
80
86
  export declare class SshExec {
81
87
  #private;
82
- constructor({ ssh2, loginOf, tunnelOf }: SshExecOptions);
88
+ constructor({ ssh2, loginOf, tunnelOf, deniedUntil }: SshExecOptions);
83
89
  /** Ends every connection to machine id, channels and all: the vendor calls it once the machine is deleted. */
84
90
  closeAll(id: string): void;
85
91
  /**
@@ -7,6 +7,7 @@ import { createPrivateKey, randomBytes } from "node:crypto";
7
7
  import { PassThrough } from "node:stream";
8
8
  import { boundOf, redact } from "./process.js";
9
9
  import { PID_WRAPPER, pidKill, pidStderr, shellLine } from "./scripts.js";
10
+ import { sshString } from "./ssh-key.js";
10
11
  /**
11
12
  * ssh2's keepalive, which also keeps the edge from seeing an idle tunnel (the CLI's ServerAliveInterval is 60 s, cli.js:32).
12
13
  * ssh2 pings every KEEPALIVE_MS and ends the connection at the tick after KEEPALIVE_COUNT_MAX pings went unanswered
@@ -47,20 +48,24 @@ const isBound = (error) => {
47
48
  const name = error?.name;
48
49
  return name === "TimeoutError" || name === "AbortError";
49
50
  };
51
+ /** The pause between two logins an sshd refused, while deniedUntil says the key may still reach it. */
52
+ const DENIED_RETRY_MS = 2_000;
50
53
  /** MachineHost.exec over SSH: argv as the host's login, as channels on one connection per machine, shared by its execs. */
51
54
  export class SshExec {
52
55
  #ssh2;
53
56
  #loginOf;
54
57
  #tunnelOf;
58
+ #deniedUntil;
55
59
  /**
56
60
  * The SSH connections to each machine, opening, open, or done and still held, until each ends: one, and a second
57
61
  * past CHANNELS_PER_CONNECTION channels. A done one takes no new channel; closeAll ends them all.
58
62
  */
59
63
  #links = new Map();
60
- constructor({ ssh2, loginOf, tunnelOf }) {
64
+ constructor({ ssh2, loginOf, tunnelOf, deniedUntil }) {
61
65
  this.#ssh2 = ssh2;
62
66
  this.#loginOf = loginOf;
63
67
  this.#tunnelOf = tunnelOf;
68
+ this.#deniedUntil = deniedUntil;
64
69
  }
65
70
  /** Ends every connection to machine id, channels and all: the vendor calls it once the machine is deleted. */
66
71
  closeAll(id) {
@@ -71,24 +76,31 @@ export class SshExec {
71
76
  * An SSH session as the host's login over the machine's tunnel, its handshake within ctx. A tunnel that fails to
72
77
  * open, or closes before the SSH handshake, is opened again after a pause, TUNNEL_TRIES times in all within ctx: an
73
78
  * instance fresh from its create can refuse the first (seen live once in eight creates, the daemon's upload
74
- * refused). Nothing has run before a handshake, so a retry repeats nothing. A refused key or a handshake past its
75
- * bound is not retried.
79
+ * refused). Nothing has run before a handshake, so a retry repeats nothing. A refused key is tried again only while
80
+ * deniedUntil says it may still reach the machine; a handshake past its bound is not retried.
76
81
  */
77
82
  async #ssh(id, ctx) {
78
83
  const bound = boundOf(ctx.timeoutMs, ctx.signal, `the SSH connection to ${id}`);
79
84
  // Ends the handshake in flight when this call gives up on it (its bound passed, or the caller aborted).
80
85
  const givenUp = new AbortController();
81
86
  try {
82
- for (let attempt = 1;; attempt++) {
87
+ for (let attempt = 1;;) {
88
+ let pause;
83
89
  try {
84
90
  return await Promise.race([this.#handshake(id, ctx.timeoutMs, givenUp.signal), bound.promise]);
85
91
  }
86
92
  catch (error) {
87
- const early = error instanceof SshTunnelError || error.level === "client-socket";
88
- if (!early || attempt >= TUNNEL_TRIES)
93
+ const level = error.level;
94
+ const left = level === "client-authentication" ? (this.#deniedUntil?.(id) ?? 0) - Date.now() : 0;
95
+ const early = error instanceof SshTunnelError || level === "client-socket";
96
+ if (left > 0)
97
+ pause = Math.min(DENIED_RETRY_MS, left);
98
+ else if (early && attempt < TUNNEL_TRIES)
99
+ pause = TUNNEL_RETRY_MS * 2 ** (attempt++ - 1);
100
+ else
89
101
  throw error;
90
102
  }
91
- await Promise.race([new Promise((resolve) => setTimeout(resolve, TUNNEL_RETRY_MS * 2 ** (attempt - 1))), bound.promise]);
103
+ await Promise.race([new Promise((resolve) => setTimeout(resolve, pause)), bound.promise]);
92
104
  }
93
105
  }
94
106
  catch (error) {
@@ -474,13 +486,6 @@ function fromPkcs8(pem) {
474
486
  return openSshEd25519(key);
475
487
  return undefined;
476
488
  }
477
- /** An SSH string (RFC 4251 §5): its uint32 length, then its bytes. */
478
- const sshString = (bytes) => {
479
- const body = Buffer.from(bytes);
480
- const length = Buffer.alloc(4);
481
- length.writeUInt32BE(body.length);
482
- return Buffer.concat([length, body]);
483
- };
484
489
  /**
485
490
  * An Ed25519 private key in OpenSSH's own format, unencrypted (openssh-portable PROTOCOL.key; sshkey.c writes it so):
486
491
  * "openssh-key-v1\0", cipher "none", KDF "none", empty KDF options, the key count 1, the public key blob (RFC 8709 §4:
@@ -0,0 +1,18 @@
1
+ /** An SSH string (RFC 4251 §5): its uint32 length, then its bytes. */
2
+ export declare const sshString: (bytes: Uint8Array | string) => Buffer;
3
+ /** A new ed25519 private key, as PKCS#8 PEM. */
4
+ export declare function newEd25519(): string;
5
+ /** The public half of an ed25519 key, as SSH reads it. */
6
+ export interface SshPublicKey {
7
+ /** One OpenSSH line, "ssh-ed25519 <blob in base64>", with no comment. */
8
+ readonly line: string;
9
+ /** "SHA256:" and the blob's SHA-256 in base64 with no padding (ssh-keygen -l). */
10
+ readonly fingerprint: string;
11
+ /** The blob's SHA-256 in hex: a name made from it says which key without being one. */
12
+ readonly hash: string;
13
+ }
14
+ /**
15
+ * The public half of `pem`, a PKCS#8 ed25519 private key, or undefined when it is not one. The blob is RFC 8709 §4's:
16
+ * the string "ssh-ed25519", then the 32-byte public key, each length-prefixed.
17
+ */
18
+ export declare function ed25519PublicOf(pem: string): SshPublicKey | undefined;
@@ -0,0 +1,36 @@
1
+ // An SSH key a provider makes for itself: ed25519, its private half as PKCS#8 PEM (what node:crypto writes, and what
2
+ // pemOf in ./ssh-exec.ts turns into the OpenSSH form ssh2 reads), its public half as one OpenSSH line, and that line's
3
+ // fingerprint as OpenSSH and the vendors print it.
4
+ import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync } from "node:crypto";
5
+ /** An SSH string (RFC 4251 §5): its uint32 length, then its bytes. */
6
+ export const sshString = (bytes) => {
7
+ const body = Buffer.from(bytes);
8
+ const length = Buffer.alloc(4);
9
+ length.writeUInt32BE(body.length);
10
+ return Buffer.concat([length, body]);
11
+ };
12
+ /** A new ed25519 private key, as PKCS#8 PEM. */
13
+ export function newEd25519() {
14
+ return generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" });
15
+ }
16
+ /**
17
+ * The public half of `pem`, a PKCS#8 ed25519 private key, or undefined when it is not one. The blob is RFC 8709 §4's:
18
+ * the string "ssh-ed25519", then the 32-byte public key, each length-prefixed.
19
+ */
20
+ export function ed25519PublicOf(pem) {
21
+ let x;
22
+ try {
23
+ const key = createPrivateKey(pem);
24
+ if (key.asymmetricKeyType !== "ed25519")
25
+ return undefined;
26
+ x = createPublicKey(key).export({ format: "jwk" }).x;
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ if (typeof x !== "string")
32
+ return undefined;
33
+ const blob = Buffer.concat([sshString("ssh-ed25519"), sshString(Buffer.from(x, "base64url"))]);
34
+ const digest = createHash("sha256").update(blob).digest();
35
+ return { line: `ssh-ed25519 ${blob.toString("base64")}`, fingerprint: `SHA256:${digest.toString("base64").replace(/=+$/, "")}`, hash: digest.toString("hex") };
36
+ }
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./provider.js";
4
4
  export * from "./ui-engine.js";
5
5
  export * from "./attach.js";
6
6
  export * from "./mount.js";
7
+ export { SDK_MISSING } from "./vendor-sdk.js";
7
8
  export { type CallOptions, DaemonClient, type DaemonStream, findNodes, refusedStep, type UiActOptions, type UiQuery, UiSession } from "./client.js";
8
9
  export { type ActionFailure, type CheckActionsOptions, checkActions, isKey } from "./actions.js";
9
10
  export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar } from "./files.js";
@@ -15,9 +16,10 @@ export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, Machine
15
16
  export { HostedProvider, type HostedDial, type HostedOptions, type HostedTimeouts, hostedDaemonPath } from "./hosted/provider.js";
16
17
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
17
18
  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";
18
- export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
19
+ export { ADB_ENV_NAMES, adbEnv, BASE_ENV_NAMES, CHROME_ENV_NAMES, childEnv, chromeEnv, DOCKER_ENV_NAMES, dockerEnv, type HostEnv } from "./child-env.js";
20
+ export { containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
19
21
  export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, type ArchilMount, type ArchilEgress, type ArchilMountOptions, type ArchilRoot, type ProviderNote, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, type RecordedFolder, type RecordedSource, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
20
- export { type BrowserComputerProvider, type BrowserDownloads, type BrowserFile, type BrowserProfiles, type BrowserSessionUsage, browserSpecRefusals, type BrowserStream, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, type ReleaseConfirm, type RestReply, type UrlStore, } from "./browser.js";
22
+ export { type BrowserComputerProvider, type BrowserDownloads, type BrowserFile, type BrowserProfiles, type BrowserSessionUsage, browserSpecRefusals, type BrowserStream, isBrowserProvider, BrowserVendorError, CREATE_LABEL, ATTEMPT_LABEL, causeOf, memoryUrls, RECOVER_MS, type ReleaseConfirm, type RestReply, type UrlStore, } from "./browser.js";
21
23
  export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
22
24
  export { DAEMON_IN_COMPUTER, helloDrift, type HelloExpected } from "./drift.js";
23
25
  export { drift, hostOf, inspectDrift, mountOf, networkOf, type DockerHost, type DockerInfo, type DockerInspect, type DriftExpected } from "./docker/inspect.js";
@@ -25,7 +27,7 @@ export { type ReleasedOlder, releaseOlder, sweep, type SweepOptions, type Swept
25
27
  export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerFilter, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
26
28
  export { waitUntil, type WaitOptions } from "./wait.js";
27
29
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
28
- export { connectOf, type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
30
+ export { connectOf, type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor, type ProviderSecrets } from "./descriptor.js";
29
31
  export { AGENT37, AGENT37_BASE_TEMPLATE, BOXD, BOXD_DEFAULT_IMAGE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, GROUNDBOX, GROUNDBOX_OWN_IMAGE, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, SMOLCLOUD, } from "./descriptors/index.js";
30
32
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
31
33
  export { configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, kindServed, type ProviderEntry, PROVIDERS, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export * from "./provider.js";
4
4
  export * from "./ui-engine.js";
5
5
  export * from "./attach.js";
6
6
  export * from "./mount.js";
7
+ export { SDK_MISSING } from "./vendor-sdk.js";
7
8
  export { DaemonClient, findNodes, refusedStep, UiSession } from "./client.js";
8
9
  export { checkActions, isKey } from "./actions.js";
9
10
  export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
@@ -17,9 +18,10 @@ export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
17
18
  // /phone-harness, /browserbase, /kernel, /local, /smolcloud, /groundbox: each the provider file's name).
18
19
  export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
19
20
  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";
20
- export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
21
+ export { ADB_ENV_NAMES, adbEnv, BASE_ENV_NAMES, CHROME_ENV_NAMES, childEnv, chromeEnv, DOCKER_ENV_NAMES, dockerEnv } from "./child-env.js";
22
+ export { containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
21
23
  export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
22
- export { browserSpecRefusals, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, } from "./browser.js";
24
+ export { browserSpecRefusals, isBrowserProvider, BrowserVendorError, CREATE_LABEL, ATTEMPT_LABEL, causeOf, memoryUrls, RECOVER_MS, } from "./browser.js";
23
25
  // Local Chrome's provider class is on its provider id's subpath (@parcha/agentrun-computer/local-chrome), as every
24
26
  // provider's is; the Chrome helpers it runs on are not a provider and stay here.
25
27
  export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
package/dist/janitor.d.ts CHANGED
@@ -11,6 +11,12 @@ export interface SweepOptions {
11
11
  * agent's computer whose owner is gone is deleted; without this, no owner counts as gone.
12
12
  */
13
13
  ownerGone?: (owner: ComputerOwner) => boolean | Promise<boolean>;
14
+ /**
15
+ * Whether a leftover (sweepLeftovers: a part a computer left behind), by the labels it carries, is the caller's to
16
+ * remove; default every one with `labels`. A caller that shares the provider's host with another (serve: a run of
17
+ * this store) answers true for its own alone.
18
+ */
19
+ mine?: (labels: Record<string, string>) => boolean | Promise<boolean>;
14
20
  signal?: AbortSignal;
15
21
  }
16
22
  export interface Swept {
@@ -36,7 +42,7 @@ export interface Swept {
36
42
  * provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
37
43
  * ends them.
38
44
  */
39
- export declare function sweep(provider: ComputerProvider, { labels, now, ownerGone, signal }?: SweepOptions): Promise<Result<Swept>>;
45
+ export declare function sweep(provider: ComputerProvider, { labels, now, ownerGone, mine, signal }?: SweepOptions): Promise<Result<Swept>>;
40
46
  export interface ReleasedOlder {
41
47
  /** The run's computers deleted: each with a lower epoch, and each that carries no epoch it can read. */
42
48
  released: ComputerRef[];
package/dist/janitor.js CHANGED
@@ -49,7 +49,7 @@ async function ownerEnds(info, owner, at, ownerGone) {
49
49
  * provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
50
50
  * ends them.
51
51
  */
52
- export async function sweep(provider, { labels = {}, now, ownerGone, signal } = {}) {
52
+ export async function sweep(provider, { labels = {}, now, ownerGone, mine, signal } = {}) {
53
53
  const { lifetime, maxLifetimeMs, persistence } = provider.capabilities();
54
54
  if (lifetime !== "janitor" && persistence === undefined) {
55
55
  return fail("refused", `the ${provider.id} provider declares lifetime "${lifetime}": its vendor ends its computers itself, so the janitor does not sweep them`);
@@ -95,7 +95,7 @@ export async function sweep(provider, { labels = {}, now, ownerGone, signal } =
95
95
  if (provider.sweepLeftovers) {
96
96
  if (signal?.aborted)
97
97
  return fail("aborted", `the sweep was aborted; it had deleted ${deleted.join(", ") || "none"}`);
98
- const left = await provider.sweepLeftovers({ labels, now: new Date(at), signal });
98
+ const left = await provider.sweepLeftovers({ labels, now: new Date(at), signal, ...(mine === undefined ? {} : { mine }) });
99
99
  if (left.ok)
100
100
  leftovers = left.value;
101
101
  else {
package/dist/kernel.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface KernelBrowser {
15
15
  /** The live view's URL: a secret. */
16
16
  browser_live_view_url?: unknown;
17
17
  tags?: unknown;
18
+ /** When Kernel made the browser. */
19
+ created_at?: unknown;
18
20
  deleted_at?: unknown;
19
21
  }
20
22
  /**
@@ -39,6 +41,12 @@ export interface KernelProviderOptions {
39
41
  fetch?: typeof fetch;
40
42
  confirm?: ReleaseConfirm;
41
43
  sleep?: (ms: number) => Promise<void>;
44
+ /**
45
+ * How long, in all, a cleanup a create runs for itself may take: the release of the browser its POST made once its
46
+ * caller is gone, or once another create of the request made one first, and the search and release after a lost
47
+ * reply. Default RECOVER_MS. The caller's signal never cuts it short.
48
+ */
49
+ cleanupMs?: number;
42
50
  }
43
51
  /** Computers that are Kernel browsers. */
44
52
  export declare class KernelProvider implements ComputerProvider, BrowserComputerProvider {
@@ -46,7 +54,7 @@ export declare class KernelProvider implements ComputerProvider, BrowserComputer
46
54
  readonly id = "kernel";
47
55
  readonly version: string;
48
56
  readonly profiles: BrowserProfiles;
49
- constructor({ apiKey, apiUrl, env, fetch: fetcher, confirm, sleep }: KernelProviderOptions);
57
+ constructor({ apiKey, apiUrl, env, fetch: fetcher, confirm, sleep, cleanupMs }: KernelProviderOptions);
50
58
  /**
51
59
  * A browser: Kernel ends a browser after its idle timeout (lifetime vendor), at most 72 h; it reaches the open web;
52
60
  * each browser is its own VM. Kernel's replays and file APIs are not wired here, so recordings and downloads are not
@@ -56,9 +64,11 @@ export declare class KernelProvider implements ComputerProvider, BrowserComputer
56
64
  capabilities(): ComputerCapabilities;
57
65
  check(spec: ComputerSpec): Refusal[];
58
66
  /**
59
- * Makes a browser at most once, with the lifetime as its idle timeout in whole seconds and the labels as its tags.
60
- * spec.browser is the session's own options, each refused by check() unless declared; a profile is made first if
61
- * Kernel does not know it.
67
+ * Makes a browser once per request (provider.md, Idempotent create), with the lifetime as its idle timeout in whole
68
+ * seconds and the labels as its tags, with the request's name (computerNameFor) as its create label. A request whose
69
+ * browser Kernel still holds undeleted answers that one, found by its create label; one whose browser was deleted here
70
+ * is refused exists; a create of a request in flight here waits for the first (CreateRequests). spec.browser is the
71
+ * session's own options, each refused by check() unless declared; a profile is made first if Kernel does not know it.
62
72
  */
63
73
  create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
64
74
  /**