@parcha/agentrun-computer 0.1.0-beta.33 → 0.1.0-beta.34

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 (59) hide show
  1. package/README.md +169 -15
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +6 -3
  4. package/dist/browserbase.d.ts +3 -1
  5. package/dist/browserbase.js +3 -1
  6. package/dist/child.d.ts +2 -0
  7. package/dist/child.js +13 -2
  8. package/dist/chrome.d.ts +73 -0
  9. package/dist/chrome.js +224 -0
  10. package/dist/computerd-linux-amd64 +0 -0
  11. package/dist/computerd-linux-arm64 +0 -0
  12. package/dist/conformance/cases/gpu.d.ts +2 -0
  13. package/dist/conformance/cases/gpu.js +108 -0
  14. package/dist/conformance/cases/health.js +83 -3
  15. package/dist/conformance/cases/index.js +2 -0
  16. package/dist/conformance/cases/mount.d.ts +8 -1
  17. package/dist/conformance/cases/mount.js +4 -3
  18. package/dist/conformance/cases/provider.js +14 -0
  19. package/dist/conformance/cli.js +46 -7
  20. package/dist/conformance/local.d.ts +30 -0
  21. package/dist/conformance/local.js +36 -0
  22. package/dist/conformance/report.js +10 -5
  23. package/dist/conformance/runner.js +45 -13
  24. package/dist/conformance/types.d.ts +63 -16
  25. package/dist/daytona.d.ts +32 -3
  26. package/dist/daytona.js +96 -24
  27. package/dist/docker.d.ts +3 -1
  28. package/dist/docker.js +11 -3
  29. package/dist/drift.d.ts +3 -1
  30. package/dist/drift.js +9 -0
  31. package/dist/e2b.d.ts +3 -1
  32. package/dist/e2b.js +7 -4
  33. package/dist/index.d.ts +4 -2
  34. package/dist/index.js +4 -2
  35. package/dist/isolation.d.ts +0 -2
  36. package/dist/isolation.js +0 -16
  37. package/dist/kernel.d.ts +3 -1
  38. package/dist/kernel.js +3 -1
  39. package/dist/kinds.d.ts +10 -4
  40. package/dist/kinds.js +26 -6
  41. package/dist/labels.d.ts +6 -0
  42. package/dist/labels.js +26 -1
  43. package/dist/local-supervisor.d.ts +51 -0
  44. package/dist/local-supervisor.js +221 -0
  45. package/dist/local.d.ts +89 -0
  46. package/dist/local.js +472 -0
  47. package/dist/modal.d.ts +31 -4
  48. package/dist/modal.js +90 -30
  49. package/dist/orgo.d.ts +3 -1
  50. package/dist/orgo.js +14 -27
  51. package/dist/phone-harness.d.ts +3 -1
  52. package/dist/phone-harness.js +7 -4
  53. package/dist/protocol.d.ts +20 -0
  54. package/dist/protocol.js +9 -0
  55. package/dist/provider.d.ts +63 -3
  56. package/dist/provider.js +28 -0
  57. package/dist/providers.d.ts +7 -1
  58. package/dist/providers.js +1 -0
  59. package/package.json +1 -1
@@ -3,6 +3,7 @@
3
3
  // Exits 0 when Core passes, 1 when it fails, 2 on a usage error, and 3 when --only left Core cases out and every case
4
4
  // that ran passed: a partial run is never a Core pass, so no script reads its exit code as one. With --kind it exits on
5
5
  // the kind's verdict alone: 0 when the provider passes the kind, 1 when it does not.
6
+ import { randomBytes } from "node:crypto";
6
7
  import { resolve } from "node:path";
7
8
  import { pathToFileURL } from "node:url";
8
9
  import { isCommand } from "../entry.js";
@@ -14,24 +15,33 @@ import { formatReport } from "./report.js";
14
15
  import { runConformance } from "./runner.js";
15
16
  /** Writes text and settles once the stream has taken it, so an exit after it cuts nothing off. */
16
17
  const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
17
- const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--json]
18
+ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--json]
18
19
  --provider a computer in the registry (${providerIds.join(", ")}), or a module path: a provider file that exports
19
20
  create(options), or a conformance module that exports createProvider() (and, for the drift case,
20
21
  createDriftedProvider(); for the mount cases, mountFor(kind), a fresh run folder for that mount kind)
21
22
  --image the image every computer starts from (default the module's conformanceImage(), else debian:bookworm-slim)
22
23
  --only run only these groups (health, exec, files, process, provider, drift, mount, screen, input, touch,
23
- apps, lifetime; browser, run alone for a provider of kind browser) or case ids; a run that leaves Core cases out is partial: no Core verdict, and exit 3 when
24
+ apps, lifetime, gpu; browser, run alone for a provider of kind browser) or case ids; a run that leaves Core cases out is partial: no Core verdict, and exit 3 when
24
25
  every case that ran passed
25
26
  --kind run a setting kind's cases (sandbox, desktop, phone, browser) and exit on its verdict: the provider passes the kind only
26
27
  when it serves it and every case of each required group passes; not with --only
27
28
  --fixture the fixture the screen, input, touch and apps cases check effects with: computerd-fixture for a
28
29
  desktop, the fixture APK for an Android phone
30
+ --gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
31
+ as T4 or H100:2; it bills by the second, so without it the gpu case skips
29
32
  --json print the report as JSON
30
33
  exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
31
34
  0 the provider passes the kind, 1 it does not`;
32
35
  const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
33
36
  class Usage extends Error {
34
37
  }
38
+ /** --gpu's value: a type, then :count (default 1), such as T4 or H100:2; whether the provider offers it is check()'s. */
39
+ function gpuOf(text) {
40
+ const match = /^([^:\s]+)(?::([1-9][0-9]*))?$/.exec(text);
41
+ if (match === null)
42
+ throw new Usage(`--gpu: ${JSON.stringify(text)} is not <type>[:<count>], such as T4 or H100:2`);
43
+ return { type: match[1], count: match[2] === undefined ? 1 : Number(match[2]) };
44
+ }
35
45
  function parse(argv, cases) {
36
46
  const args = { json: false, help: false };
37
47
  for (let i = 0; i < argv.length; i++) {
@@ -59,6 +69,8 @@ function parse(argv, cases) {
59
69
  }
60
70
  else if (flag === "--fixture")
61
71
  args.fixture = value();
72
+ else if (flag === "--gpu")
73
+ args.gpu = gpuOf(value());
62
74
  else if (flag === "--json")
63
75
  args.json = true;
64
76
  else if (flag === "--help" || flag === "-h")
@@ -84,6 +96,7 @@ function parse(argv, cases) {
84
96
  ...(args.only ? { only: args.only } : {}),
85
97
  ...(args.kind ? { kind: args.kind } : {}),
86
98
  ...(args.fixture ? { fixture: args.fixture } : {}),
99
+ ...(args.gpu ? { gpu: args.gpu } : {}),
87
100
  json: args.json,
88
101
  help: false,
89
102
  };
@@ -98,6 +111,13 @@ const BARE = /^[A-Za-z][A-Za-z0-9-]*$/;
98
111
  * reads no environment), with no drifted twin.
99
112
  */
100
113
  async function conformanceModule(name, cwd) {
114
+ const found = await moduleFor(name, cwd);
115
+ // What the provider file declares of itself (its CAPABILITIES; its descriptor once that lands), kept across the switch
116
+ // to its conformance module, for health.declared.
117
+ const declared = found.file.CAPABILITIES;
118
+ return { label: found.label, module: found.module, ...(Array.isArray(declared) ? { declared: declared } : {}) };
119
+ }
120
+ async function moduleFor(name, cwd) {
101
121
  let label = name;
102
122
  let module;
103
123
  if (isProviderId(name)) {
@@ -116,7 +136,7 @@ async function conformanceModule(name, cwd) {
116
136
  }
117
137
  }
118
138
  if (typeof module.conformance === "function")
119
- return { label, module: await module.conformance() };
139
+ return { label, module: await module.conformance(), file: module };
120
140
  if (typeof module.createProvider !== "function" && typeof module.create === "function") {
121
141
  const create = module.create;
122
142
  return {
@@ -127,15 +147,18 @@ async function conformanceModule(name, cwd) {
127
147
  return create(rest);
128
148
  },
129
149
  },
150
+ file: module,
130
151
  };
131
152
  }
132
- return { label, module: module };
153
+ return { label, module: module, file: module };
133
154
  }
155
+ /** A name of a module's ENV that holds a secret: an API key, a token, a token's secret. */
156
+ const SECRET_NAME = /(^|_)(KEY|TOKEN|SECRET)(_|$)/;
134
157
  /**
135
158
  * The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
136
159
  * it says of its run: conformanceImage(), the image when --image names none, and conformanceNotes, strings for the report.
137
160
  */
138
- async function load(label, module, options) {
161
+ async function load(label, module, options, declared) {
139
162
  const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
140
163
  if (typeof createProvider !== "function")
141
164
  throw new Usage(`${label} does not export createProvider() or create()`);
@@ -147,6 +170,19 @@ async function load(label, module, options) {
147
170
  const target = { provider };
148
171
  if (typeof createDriftedProvider === "function")
149
172
  target.drifted = async () => (await createDriftedProvider(options));
173
+ // The provider file's own declaration; without it, the runner takes the kind registry's entry for the provider's id.
174
+ if (declared !== undefined)
175
+ target.declared = declared;
176
+ // The same provider built with a planted value in each name of its ENV that holds a secret: a fresh one each time.
177
+ const secretNames = Object.values(module.ENV ?? {}).filter((name) => typeof name === "string" && SECRET_NAME.test(name));
178
+ if (secretNames.length > 0) {
179
+ target.planted = async () => {
180
+ const secrets = secretNames.map(() => `agentrun-planted-${randomBytes(12).toString("hex")}`);
181
+ const given = options.env ?? process.env;
182
+ const env = { ...given, ...Object.fromEntries(secretNames.map((name, i) => [name, secrets[i]])) };
183
+ return { provider: (await createProvider({ ...options, env })), secrets };
184
+ };
185
+ }
150
186
  if (typeof mountFor === "function")
151
187
  target.mountFor = (kind) => mountFor(kind, options);
152
188
  if (conformanceImage !== undefined) {
@@ -184,8 +220,8 @@ export async function main(argv, io = {}) {
184
220
  const options = { ...(io.providerOptions ?? {}), onNote: (note) => providerNotes.push({ computer: note.computer, note: note.note }) };
185
221
  let target;
186
222
  try {
187
- const { label, module } = await conformanceModule(args.provider, cwd);
188
- target = await load(label, module, options);
223
+ const { label, module, declared } = await conformanceModule(args.provider, cwd);
224
+ target = await load(label, module, options, declared);
189
225
  }
190
226
  catch (error) {
191
227
  await write(stderr, `${error.message}\n`);
@@ -204,8 +240,11 @@ export async function main(argv, io = {}) {
204
240
  ...(args.only ? { only: args.only } : {}),
205
241
  ...(args.kind ? { kind: args.kind } : {}),
206
242
  ...(args.fixture ? { fixture: resolve(cwd, args.fixture) } : {}),
243
+ ...(args.gpu ? { gpu: args.gpu } : {}),
207
244
  ...(signal ? { signal } : {}),
208
245
  ...(target.drifted ? { drifted: target.drifted } : {}),
246
+ ...(target.declared ? { declared: target.declared } : {}),
247
+ ...(target.planted ? { planted: target.planted } : {}),
209
248
  ...(target.mountFor ? { mountFor: target.mountFor } : {}),
210
249
  ...(onResult ? { onResult } : {}),
211
250
  ...(io.cdp ? { cdp: io.cdp } : {}),
@@ -0,0 +1,30 @@
1
+ import { type LocalBrowserOptions, type LocalBrowserProvider } from "../local.js";
2
+ /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
3
+ export declare const LOCAL_ENV: {
4
+ readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL";
5
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
6
+ readonly chrome: "COMPUTER_LOCAL_CHROME";
7
+ /** headed: "1" shows the window. */
8
+ readonly headed: "COMPUTER_LOCAL_HEADED";
9
+ };
10
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
11
+ export declare const ENV: {
12
+ readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL";
13
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
14
+ readonly chrome: "COMPUTER_LOCAL_CHROME";
15
+ /** headed: "1" shows the window. */
16
+ readonly headed: "COMPUTER_LOCAL_HEADED";
17
+ };
18
+ export type LocalSettings = Pick<LocalBrowserOptions, "executablePath" | "headed" | "env">;
19
+ /** The provider's options this module reads from env, each only when its name is set; PATH goes in as the provider's env, to find a Chrome on it. */
20
+ export declare function settingsFromEnv(env?: Record<string, string | undefined>): LocalSettings;
21
+ /** For the run's report: what this configuration means for the suite. */
22
+ export declare const conformanceNotes: string[];
23
+ export interface LocalModuleOptions {
24
+ /** Where the settings are read; default process.env. */
25
+ env?: Record<string, string | undefined>;
26
+ }
27
+ /** The image every computer of the run asks for: this machine's Chrome. */
28
+ export declare function conformanceImage(): string;
29
+ /** The provider the CLI runs; throws in words without the live switch. */
30
+ export declare function createProvider({ env }?: LocalModuleOptions): Promise<LocalBrowserProvider>;
@@ -0,0 +1,36 @@
1
+ // The local browser for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider local`. It
2
+ // starts a real Chrome on this machine (nothing billed, no key), so it runs only with AGENTRUN_COMPUTER_LIVE_LOCAL=1. The
3
+ // provider reads no environment: this module reads its own COMPUTER_LOCAL_* names, and PATH to find a Chrome, and passes
4
+ // each to create() as its option.
5
+ import { BROWSER_IMAGE } from "../browser.js";
6
+ import { create } from "../local.js";
7
+ /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
8
+ export const LOCAL_ENV = {
9
+ live: "AGENTRUN_COMPUTER_LIVE_LOCAL",
10
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
11
+ chrome: "COMPUTER_LOCAL_CHROME",
12
+ /** headed: "1" shows the window. */
13
+ headed: "COMPUTER_LOCAL_HEADED",
14
+ };
15
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
16
+ export const ENV = LOCAL_ENV;
17
+ /** The provider's options this module reads from env, each only when its name is set; PATH goes in as the provider's env, to find a Chrome on it. */
18
+ export function settingsFromEnv(env = process.env) {
19
+ const executablePath = env[LOCAL_ENV.chrome] || undefined;
20
+ const headed = env[LOCAL_ENV.headed] === "1";
21
+ return { ...(executablePath === undefined ? {} : { executablePath }), ...(headed ? { headed } : {}), env: { PATH: env.PATH } };
22
+ }
23
+ /** For the run's report: what this configuration means for the suite. */
24
+ export const conformanceNotes = [
25
+ "local: this machine's Chrome, one browser for the whole run, deleted by its last case and again at the run's end. Its supervisor ends it at its deadline, which list reads.",
26
+ ];
27
+ /** The image every computer of the run asks for: this machine's Chrome. */
28
+ export function conformanceImage() {
29
+ return BROWSER_IMAGE;
30
+ }
31
+ /** The provider the CLI runs; throws in words without the live switch. */
32
+ export async function createProvider({ env = process.env } = {}) {
33
+ if (env[LOCAL_ENV.live] !== "1")
34
+ throw new Error(`the local conformance module starts a real Chrome on this machine: set ${LOCAL_ENV.live}=1 to run it`);
35
+ return create(settingsFromEnv(env));
36
+ }
@@ -1,4 +1,4 @@
1
- const GROUPS = ["health", "exec", "files", "process", "provider", "drift", "isolation", "mount", "screen", "input", "touch", "apps", "lifetime", "browser"];
1
+ const GROUPS = ["health", "exec", "files", "process", "provider", "drift", "isolation", "mount", "screen", "input", "touch", "apps", "lifetime", "browser", "gpu"];
2
2
  const NAMES_WIDTH = 44;
3
3
  const INDENT = " ".repeat("core ".length + "provider ".length + 1);
4
4
  /** The case names, wrapped to the column's width: the first line, then the rest. */
@@ -14,9 +14,11 @@ function wrap(names) {
14
14
  return lines;
15
15
  }
16
16
  export function formatReport(report) {
17
- const { daemon, results, cleanup } = report;
17
+ const { daemons, results, cleanup } = report;
18
18
  const answers = report.daemonMode === "none" ? "the provider" : "computerd";
19
- const reached = daemon ? `${answers} ${daemon.version} ${daemon.os}/${daemon.arch}` : report.daemonMode === "none" ? "no computer reached" : "no daemon reached";
19
+ const said = (daemon) => `${answers} ${daemon.version} ${daemon.os}/${daemon.arch}`;
20
+ const [first] = daemons;
21
+ const reached = first ? said(first) : report.daemonMode === "none" ? "no computer reached" : "no daemon reached";
20
22
  const lines = [`computer conformance · ${report.provider} · ${report.kind}, daemon ${report.daemonMode} · ${reached}`];
21
23
  // A Core case skipped for an optional group the computer does not declare is not Core for this kind of computer (a
22
24
  // linux computer is never held to screen): it is listed as optional, out of Core's lines and count.
@@ -54,10 +56,13 @@ export function formatReport(report) {
54
56
  const [first = "", ...rest] = wrap(notRun);
55
57
  lines.push(`core ${"not run".padEnd(9)} ${first}`, ...rest.map((more) => `${INDENT}${more}`));
56
58
  }
59
+ // Each computer's daemon, named with its role: computers of one run may answer differently (a GPU computer's fence).
60
+ for (const daemon of daemons)
61
+ lines.push(`daemon ${daemon.computer} (${daemon.role}): ${said(daemon)}${daemon.fence === undefined ? "" : ` · fence ${daemon.fence}`}`);
57
62
  for (const note of report.notes ?? [])
58
63
  lines.push(`note: ${note}`);
59
- for (const { computer, note } of report.computerNotes ?? [])
60
- lines.push(`note ${computer}: ${note}`);
64
+ for (const { computer, role, note } of report.computerNotes ?? [])
65
+ lines.push(`note ${computer} (${role}): ${note}`);
61
66
  // What a provider said through onNote, such as a release whose final sync or checkin did not go cleanly.
62
67
  for (const { computer, note } of report.providerNotes ?? [])
63
68
  lines.push(`provider note ${computer}: ${note}`);
@@ -3,6 +3,7 @@ import { randomBytes } from "node:crypto";
3
3
  import { setTimeout as sleep } from "node:timers/promises";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { sweep } from "../janitor.js";
6
+ import { PROVIDERS } from "../kinds.js";
6
7
  import { GROUPS } from "../protocol.js";
7
8
  import { fail, ok } from "../result.js";
8
9
  import { casesFor } from "./cases/index.js";
@@ -84,9 +85,11 @@ function whenAborted(signal) {
84
85
  */
85
86
  export async function runConformance(provider, options) {
86
87
  // Given no cases, the run takes its computer's suite: a browser's own cases, as the CLI does, else the suite's.
87
- const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture } = options;
88
+ const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu } = options;
88
89
  if (kind !== undefined && only !== undefined)
89
90
  throw new TypeError("a run takes kind and only apart: a kind runs its own cases");
91
+ // What the provider declares of itself: as given, else the kind registry's entry for its id (health.declared).
92
+ const declared = options.declared ?? PROVIDERS.find((entry) => entry.id === provider.id)?.capabilities;
90
93
  const kindProblem = kind === undefined ? undefined : kindRunProblem(kind);
91
94
  if (kindProblem !== undefined)
92
95
  throw new TypeError(kindProblem);
@@ -107,7 +110,7 @@ export async function runConformance(provider, options) {
107
110
  kind: capabilities.kind,
108
111
  daemonMode: capabilities.daemon,
109
112
  image,
110
- daemon: null,
113
+ daemons: [],
111
114
  ...(only === undefined ? {} : { only }),
112
115
  ...(only === undefined && kind === undefined ? {} : { coreNotRun: cases.filter((c) => c.level === "core" && !selected.includes(c)).map((c) => c.id) }),
113
116
  results: [],
@@ -150,24 +153,35 @@ export async function runConformance(provider, options) {
150
153
  report.cleanup.errors.push(words(error).startsWith(`release ${ref.name}`) ? words(error) : `release ${ref.name} threw: ${words(error)}`);
151
154
  }
152
155
  };
153
- /** Records the notes a create returned beside its ref, each naming the computer: never dropped with the ref. */
154
- const noteCreated = (created) => {
155
- if (!created.ok || !Array.isArray(created.value.notes))
156
+ /** Each computer the run made, by name: its role, "shared" or the id of the case that made it. */
157
+ const roles = new Map();
158
+ /**
159
+ * Records the computer's role, and the notes a create returned beside its ref, each naming the computer and its role:
160
+ * never dropped with the ref.
161
+ */
162
+ const noteCreated = (created, role) => {
163
+ if (!created.ok)
164
+ return;
165
+ roles.set(created.value.name, role);
166
+ if (!Array.isArray(created.value.notes))
156
167
  return;
157
168
  for (const note of created.value.notes)
158
- (report.computerNotes ??= []).push({ computer: created.value.name, note: String(note) });
169
+ (report.computerNotes ??= []).push({ computer: created.value.name, role, note: String(note) });
159
170
  };
160
171
  /** Deletes the computer a create gives after nobody waits for it any more, and names it in the report. */
161
172
  const lateCreate = (creating, what, by = provider) => keep(creating.then(async (created) => {
162
- noteCreated(created);
173
+ noteCreated(created, "shared");
163
174
  if (!created.ok)
164
175
  return;
165
176
  report.cleanup.late.push(created.value.name);
166
177
  await release(created.value, by);
167
178
  }, () => { }), what);
168
179
  const createError = (result) => result.ok ? "" : `create ${result.error.code === "refused" ? "was refused" : `failed (${result.error.code})`}: ${result.error.message}`;
169
- const sawHello = (hello) => {
170
- report.daemon ??= { version: hello.version, os: hello.os, arch: hello.arch };
180
+ /** Records a computer's first hello, naming the computer and its role: the one it was made for, else the connecting case's. */
181
+ const sawHello = (computer, hello, role) => {
182
+ if (report.daemons.some((daemon) => daemon.computer === computer))
183
+ return;
184
+ report.daemons.push({ computer, role: roles.get(computer) ?? role, version: hello.version, os: hello.os, arch: hello.arch, ...(hello.fence === undefined ? {} : { fence: hello.fence }) });
171
185
  };
172
186
  /** The run's shared computer, made the first time a case needs it or the daemon's hello. */
173
187
  let shared;
@@ -186,7 +200,7 @@ export async function runConformance(provider, options) {
186
200
  lateCreate(creating, "create (the run's computer)");
187
201
  return { error: words(error) };
188
202
  }
189
- noteCreated(created);
203
+ noteCreated(created, "shared");
190
204
  if (!created.ok)
191
205
  return { error: createError(created) };
192
206
  sharedRef = created.value;
@@ -202,7 +216,7 @@ export async function runConformance(provider, options) {
202
216
  if (!connected.ok)
203
217
  return { error: `connect: ${connected.error.code}: ${connected.error.message}` };
204
218
  await bounded(connected.value.close(), CLOSE_MS);
205
- sawHello(connected.value.hello);
219
+ sawHello(created.value.name, connected.value.hello, "shared");
206
220
  return { ref: created.value, hello: connected.value.hello };
207
221
  })().catch((error) => ({ error: `the provider threw: ${words(error)}` })));
208
222
  /** Why a case cannot run here, or undefined when everything it needs is declared. */
@@ -241,6 +255,12 @@ export async function runConformance(provider, options) {
241
255
  else if (need === "vendor-agent" && !Array.isArray(capabilities.vendorAgentPorts)) {
242
256
  return `the provider does not declare ${need} (capabilities().vendorAgentPorts): no vendor's agent runs beside its computers' programs`;
243
257
  }
258
+ else if (need === "secrets" && planted === undefined) {
259
+ return "the provider takes no secret: its conformance module's ENV names no key, token or secret";
260
+ }
261
+ else if (need === "gpu" && capabilities.gpu === undefined) {
262
+ return "the provider does not declare gpu (capabilities().gpu): it offers no GPU";
263
+ }
244
264
  }
245
265
  return undefined;
246
266
  };
@@ -314,13 +334,13 @@ export async function runConformance(provider, options) {
314
334
  });
315
335
  keep(connecting, `connect to ${ref.name} (${c.id})`);
316
336
  const once = unwrap(await connecting, `connect to ${ref.name}`);
317
- sawHello(once.hello);
337
+ sawHello(ref.name, once.hello, c.id);
318
338
  return once;
319
339
  };
320
340
  /** create through by, kept: what it gives is deleted when the case ends, or as it comes after that. */
321
341
  const attempt = (whole, by = provider) => {
322
342
  const creating = by.create(whole, { signal: caseSignal }).then((created) => {
323
- noteCreated(created);
343
+ noteCreated(created, c.id);
324
344
  if (created.ok)
325
345
  track(created.value, by);
326
346
  return created;
@@ -409,6 +429,12 @@ export async function runConformance(provider, options) {
409
429
  return t.skip("no drifted provider was given: a provider module exports createDriftedProvider() for the drift cases");
410
430
  return await drifted();
411
431
  },
432
+ declared,
433
+ async planted() {
434
+ if (planted === undefined)
435
+ return t.skip("no provider with planted secrets was given: the provider takes no secret, or its module lists none in ENV");
436
+ return await planted();
437
+ },
412
438
  async runFolder(kind) {
413
439
  const none = `the run was given no run folder for mount kind ${kind}`;
414
440
  if (mountFor === undefined)
@@ -422,6 +448,12 @@ export async function runConformance(provider, options) {
422
448
  folders.push(folder);
423
449
  return folder;
424
450
  },
451
+ gpu() {
452
+ // A GPU bills by the second: the run names the one it pays for, never a default.
453
+ if (gpu === undefined)
454
+ return t.skip("the run named no GPU: give --gpu <type>[:<count>] (or options.gpu), one the provider declares in capabilities().gpu");
455
+ return { type: gpu.type, count: gpu.count };
456
+ },
425
457
  async exec(argv, extra = {}, client = t.client) {
426
458
  const ran = unwrap(await client.call("exec.run", { argv, timeoutMs: patience, ...extra }, { signal: caseSignal }), `exec.run ${show(argv)}`);
427
459
  const decode = (base64) => Buffer.from(base64, "base64").toString("utf8");
@@ -1,23 +1,25 @@
1
1
  import type { MountKind, MountSpec } from "../mount.js";
2
- import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult } from "../protocol.js";
3
- import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode } from "../provider.js";
2
+ import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
3
+ import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode, GpuSpec } from "../provider.js";
4
4
  import type { ComputerError, ComputerErrorCode, Result } from "../result.js";
5
- import type { ComputerSettingKind } from "../kinds.js";
5
+ import type { ComputerSettingKind, KindCapabilities } from "../kinds.js";
6
6
  import type { CdpDialer, CdpSocket } from "./cdp.js";
7
7
  import type { StartedFixture } from "./fixture.js";
8
8
  import type { KindVerdict } from "./kind.js";
9
9
  /** Core: what a computer of its kind must do. Full: an optional capability, tested only where it is declared. */
10
10
  export type Level = "core" | "full";
11
11
  /** The suite's own grouping of its cases, the first part of each case id; not the protocol's Group. */
12
- export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser";
12
+ export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser" | "gpu";
13
13
  /**
14
14
  * What a case needs: a group (declared by both the provider's capabilities().groups and the computer's hello), a
15
15
  * network the provider declares, the janitor as the keeper of deadlines, a spec.user the provider takes, a release that
16
16
  * stops a computer and keeps it, a mount kind capabilities().mount declares, a provider method that is optional
17
- * (extend, stream), declared by being there, or the ports of a vendor's agent in the computer (vendor-agent: declared
18
- * by capabilities().vendorAgentPorts, an empty list included).
17
+ * (extend, stream), declared by being there, the ports of a vendor's agent in the computer (vendor-agent: declared
18
+ * by capabilities().vendorAgentPorts, an empty list included), a secret the provider takes (secrets: declared by the
19
+ * run's planted provider, which its conformance module's ENV makes possible), or GPUs (gpu: declared by
20
+ * capabilities().gpu).
19
21
  */
20
- export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent";
22
+ export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent" | "secrets" | "gpu";
21
23
  /**
22
24
  * A fresh run's folder for one mount kind, made by the provider's conformance module: the mount that reaches it, and its
23
25
  * outside, where a computer does not run (the folder on the host for a bind, the disk's file API for Archil).
@@ -86,8 +88,14 @@ export interface CaseContext {
86
88
  dir(): Promise<string>;
87
89
  /** The same provider with a daemon that reports another version; skips the case when none was given. */
88
90
  drifted(): Promise<ComputerProvider>;
91
+ /** What the provider declares of itself (ConformanceOptions.declared); undefined when the run was given none. */
92
+ readonly declared: readonly KindCapabilities[] | undefined;
93
+ /** The provider built with planted secrets (ConformanceOptions.planted); skips the case when none was given. */
94
+ planted(): Promise<PlantedProvider>;
89
95
  /** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
90
96
  runFolder(kind: MountKind): Promise<RunFolder>;
97
+ /** The GPU the run pays for (options.gpu, the CLI's --gpu); skips the case when the run names none. */
98
+ gpu(): GpuSpec;
91
99
  /**
92
100
  * Starts the run's fixture in the case's computer and waits until it is up: an app that logs each input event it
93
101
  * gets, so a case checks what an action did with no model. It is stopped when the case ends. Skips the case when the
@@ -158,12 +166,12 @@ export interface ConformanceReport {
158
166
  kind: ComputerKind;
159
167
  daemonMode: DaemonMode;
160
168
  image: string;
161
- /** What the run's computer said in hello; null when no computer could be made. */
162
- daemon: {
163
- version: string;
164
- os: string;
165
- arch: string;
166
- } | null;
169
+ /**
170
+ * What each computer of the run said in its first hello, one entry per computer in the order they answered, each
171
+ * naming the computer and its role, with the fence its programs are held behind when it says one; empty when no
172
+ * computer answered. Computers of one run may differ: a GPU computer's fence is not the run's computer's.
173
+ */
174
+ daemons: ComputerDaemon[];
167
175
  /** The groups or case ids the run was limited to, when it was. */
168
176
  only?: string[];
169
177
  /** When only or kind was given: the Core cases it left out, which did not run. */
@@ -193,9 +201,10 @@ export interface ConformanceReport {
193
201
  notes?: string[];
194
202
  /**
195
203
  * What create's read-back recorded of each computer the run made that does not refuse it (a probe target that
196
- * accepted and sent nothing back), one entry per note, naming the computer, in the order they came; absent when none.
204
+ * accepted and sent nothing back), one entry per note, naming the computer and its role, in the order they came;
205
+ * absent when none.
197
206
  */
198
- computerNotes?: ComputerNote[];
207
+ computerNotes?: CreatedNote[];
199
208
  /**
200
209
  * What the provider said through its onNote option during the run (a release that did not let an Archil folder go
201
210
  * cleanly), naming the computer, in the order it came: no failure of any case. The CLI gives the option and fills
@@ -203,11 +212,34 @@ export interface ConformanceReport {
203
212
  */
204
213
  providerNotes?: ComputerNote[];
205
214
  }
206
- /** One note a create returned: the computer's name and the note's words. */
215
+ /** One note about a computer: the computer's name and the note's words. */
207
216
  export interface ComputerNote {
208
217
  computer: string;
209
218
  note: string;
210
219
  }
220
+ /**
221
+ * What a computer is for in a run: "shared", the run's computer, which the cases that need no computer of their own
222
+ * share; else the id of the case that made it.
223
+ */
224
+ export type ComputerRole = string;
225
+ /** One note a create returned: the computer, its role, and the note's words. */
226
+ export interface CreatedNote extends ComputerNote {
227
+ role: ComputerRole;
228
+ }
229
+ /** What one computer's first hello said: the computer, its role, and the fence when it names one. */
230
+ export interface ComputerDaemon {
231
+ computer: string;
232
+ role: ComputerRole;
233
+ version: string;
234
+ os: string;
235
+ arch: string;
236
+ fence?: NetworkFence;
237
+ }
238
+ /** A provider built with planted secrets, and the values planted: none of them may show in anything it answers. */
239
+ export interface PlantedProvider {
240
+ provider: ComputerProvider;
241
+ secrets: string[];
242
+ }
211
243
  export interface ConformanceOptions {
212
244
  /** The image every computer of the run starts from. */
213
245
  image: string;
@@ -223,6 +255,16 @@ export interface ConformanceOptions {
223
255
  cases?: Case[];
224
256
  /** The same provider with a daemon that reports another version, for the drift cases. */
225
257
  drifted?: () => Promise<ComputerProvider> | ComputerProvider;
258
+ /**
259
+ * What the provider declares of itself, each configuration's kind and groups, for health.declared: its descriptor
260
+ * (until the descriptor lands, its PROVIDERS entry, or its module's CAPABILITIES). Without it, that case skips.
261
+ */
262
+ declared?: readonly KindCapabilities[];
263
+ /**
264
+ * The same provider built with a planted value in place of each of its secrets (an API key, a token), and those
265
+ * values, for health.no-key-in-errors. Without it (a provider that takes no secret), that case skips.
266
+ */
267
+ planted?: () => Promise<PlantedProvider> | PlantedProvider;
226
268
  /**
227
269
  * A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
228
270
  * the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
@@ -243,6 +285,11 @@ export interface ConformanceOptions {
243
285
  * fixture APK for an Android phone. Without it those cases skip, and Core cannot pass where kind requires them.
244
286
  */
245
287
  fixture?: string;
288
+ /**
289
+ * The GPU the gpu case asks for: a type the provider declares and a count. A GPU bills by the second, so the run names
290
+ * the one it pays for; without it the case skips in words.
291
+ */
292
+ gpu?: GpuSpec;
246
293
  /** fetch for screen.stream; default the global one. */
247
294
  fetch?: CaseContext["fetch"];
248
295
  /** How the browser cases open a CDP socket; default a WebSocket (dialCdp). Tests give a fake browser's. */
package/dist/daytona.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { KindCapabilities } from "./kinds.js";
2
2
  import { type MountKind } from "./mount.js";
3
3
  import { type ProviderNote } from "./mount-archil.js";
4
- import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
4
+ import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type GpuCapability, type NetworkForm, type NetworkPolicy, type NetworkSpec, type Refusal } from "./provider.js";
5
5
  import { type Result } from "./result.js";
6
6
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
7
  /** The longest each kind of call may take, and the pauses between polls and retries. */
@@ -87,7 +87,36 @@ export interface DaytonaProviderOptions {
87
87
  * the toolbox, from a snapshot of box/Dockerfile, with the daemon user agentrun-tool (daemonUser "2510:2510").
88
88
  */
89
89
  export declare const MOUNT: readonly MountKind[];
90
- /** The machine kind and groups of its one configuration: a linux computer. */
90
+ /** The network a Daytona computer's programs get: none, a network of their own (isolation.ts OWN_NETWORK_ONLY). */
91
+ export declare const NETWORK: readonly NetworkForm[];
92
+ /** The one region Daytona runs a GPU sandbox in, whatever the provider's target. */
93
+ export declare const DAYTONA_GPU_REGION = "earth";
94
+ /**
95
+ * The snapshot every GPU sandbox is made from: Daytona's general GPU snapshot, its default sandbox image (user daytona,
96
+ * passwordless sudo) with the CUDA toolkit, as Daytona's dashboard makes one (GET /snapshots/daytona-gpu, 11-11). A GPU
97
+ * spec names it, or "default"; no other snapshot is proven to give a GPU computer, so check() refuses one.
98
+ */
99
+ export declare const DAYTONA_GPU_SNAPSHOT = "daytona-gpu";
100
+ /**
101
+ * The GPU a snapshot gives every sandbox made from it. A Daytona snapshot carries its own resources, GPUs among them: a
102
+ * create that names a snapshot sends none (Daytona answers 400 "Cannot specify Sandbox resources when using a
103
+ * snapshot", live 11-11), so a GPU computer's type and count are its snapshot's, and the read-back is held to them.
104
+ */
105
+ export interface DaytonaSnapshotGpu {
106
+ type: string;
107
+ count: number;
108
+ }
109
+ /** daytona-gpu's GPU, as GET /snapshots/daytona-gpu declares it (gpu 1, gpuType H100; 11-11). */
110
+ export declare const DAYTONA_GPU_SNAPSHOT_GPU: Readonly<DaytonaSnapshotGpu>;
111
+ /**
112
+ * The GPUs Daytona offers, as capabilities().gpu and CAPABILITIES declare them: the GPU of its GPU snapshot, daytona-gpu,
113
+ * alone (another type needs a snapshot of its own), with its limits on a GPU sandbox: its stop deletes it (no pause, no
114
+ * snapshot: nothing is kept), it runs in region earth, it has the snapshot's 16 vCPUs, 100 GiB of memory and 400 GiB of
115
+ * disk, it may be preempted (daytona.io/pricing lists its GPUs as "Preemptible GPU prices", 11-10), and it takes no
116
+ * mount: daytona-gpu's user is daytona, not root, and it has no Archil client, so an Archil mount is refused in words.
117
+ */
118
+ export declare const DAYTONA_GPU: Readonly<GpuCapability>;
119
+ /** The machine kind, groups and GPUs of its one configuration: a linux computer, with GPUs when asked. */
91
120
  export declare const CAPABILITIES: readonly KindCapabilities[];
92
121
  /** What create() takes: the provider's options, the daemon optional (default this package's build for the arch). */
93
122
  export type DaytonaCreateOptions = Omit<DaytonaProviderOptions, "daemonPath"> & {
@@ -137,7 +166,7 @@ export declare class DaytonaProvider implements ComputerProvider {
137
166
  check(spec: ComputerSpec): Refusal[];
138
167
  create(spec: ComputerSpec, { signal }?: {
139
168
  signal?: AbortSignal;
140
- }): Promise<Result<ComputerRef>>;
169
+ }): Promise<Result<CreatedComputer>>;
141
170
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch); a sandbox has no screen. */
142
171
  watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
143
172
  connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;