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

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 (112) hide show
  1. package/README.md +308 -36
  2. package/dist/browser.d.ts +13 -14
  3. package/dist/browser.js +22 -17
  4. package/dist/browserbase.d.ts +3 -3
  5. package/dist/browserbase.js +16 -11
  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/browserbase.js +1 -1
  13. package/dist/conformance/cases/gpu.d.ts +2 -0
  14. package/dist/conformance/cases/gpu.js +108 -0
  15. package/dist/conformance/cases/health.js +83 -3
  16. package/dist/conformance/cases/index.js +2 -0
  17. package/dist/conformance/cases/mount.d.ts +8 -1
  18. package/dist/conformance/cases/mount.js +4 -3
  19. package/dist/conformance/cases/provider.js +92 -3
  20. package/dist/conformance/cli.js +46 -7
  21. package/dist/conformance/daytona.js +2 -1
  22. package/dist/conformance/e2b.js +2 -1
  23. package/dist/conformance/fixture.js +24 -2
  24. package/dist/conformance/kernel.js +1 -1
  25. package/dist/conformance/kind.js +2 -1
  26. package/dist/conformance/local-chrome.d.ts +30 -0
  27. package/dist/conformance/local-chrome.js +36 -0
  28. package/dist/conformance/orgo.d.ts +11 -5
  29. package/dist/conformance/orgo.js +37 -8
  30. package/dist/conformance/phone-harness.js +2 -1
  31. package/dist/conformance/report.js +13 -7
  32. package/dist/conformance/runner.js +68 -18
  33. package/dist/conformance/types.d.ts +78 -18
  34. package/dist/conformance/types.js +10 -0
  35. package/dist/conformance/windows-fixture.d.ts +1 -0
  36. package/dist/conformance/windows-fixture.js +37 -0
  37. package/dist/daytona.d.ts +4 -6
  38. package/dist/daytona.js +97 -52
  39. package/dist/descriptor.d.ts +94 -0
  40. package/dist/descriptor.js +81 -0
  41. package/dist/descriptors/browserbase.d.ts +24 -0
  42. package/dist/descriptors/browserbase.js +18 -0
  43. package/dist/descriptors/daytona.d.ts +62 -0
  44. package/dist/descriptors/daytona.js +49 -0
  45. package/dist/descriptors/docker.d.ts +12 -0
  46. package/dist/descriptors/docker.js +17 -0
  47. package/dist/descriptors/e2b.d.ts +22 -0
  48. package/dist/descriptors/e2b.js +19 -0
  49. package/dist/descriptors/index.d.ts +229 -0
  50. package/dist/descriptors/index.js +19 -0
  51. package/dist/descriptors/kernel.d.ts +20 -0
  52. package/dist/descriptors/kernel.js +15 -0
  53. package/dist/descriptors/local-chrome.d.ts +17 -0
  54. package/dist/descriptors/local-chrome.js +21 -0
  55. package/dist/descriptors/modal.d.ts +50 -0
  56. package/dist/descriptors/modal.js +38 -0
  57. package/dist/descriptors/orgo.d.ts +88 -0
  58. package/dist/descriptors/orgo.js +44 -0
  59. package/dist/descriptors/phone-harness.d.ts +28 -0
  60. package/dist/descriptors/phone-harness.js +20 -0
  61. package/dist/descriptors/shared.d.ts +7 -0
  62. package/dist/descriptors/shared.js +6 -0
  63. package/dist/desktop.d.ts +4 -4
  64. package/dist/desktop.js +4 -4
  65. package/dist/docker/egress.d.ts +1 -1
  66. package/dist/docker/image.js +17 -15
  67. package/dist/docker/inspect.d.ts +147 -0
  68. package/dist/docker/inspect.js +335 -0
  69. package/dist/docker.d.ts +6 -4
  70. package/dist/docker.js +53 -41
  71. package/dist/drift.d.ts +6 -146
  72. package/dist/drift.js +14 -334
  73. package/dist/e2b.d.ts +2 -6
  74. package/dist/e2b.js +19 -22
  75. package/dist/index.d.ts +9 -10
  76. package/dist/index.js +14 -10
  77. package/dist/isolation.d.ts +0 -2
  78. package/dist/isolation.js +2 -18
  79. package/dist/janitor.d.ts +18 -1
  80. package/dist/janitor.js +67 -19
  81. package/dist/kernel.d.ts +3 -3
  82. package/dist/kernel.js +19 -14
  83. package/dist/kinds.d.ts +56 -30
  84. package/dist/kinds.js +19 -97
  85. package/dist/labels.d.ts +18 -0
  86. package/dist/labels.js +65 -2
  87. package/dist/local-chrome.d.ts +86 -0
  88. package/dist/local-chrome.js +475 -0
  89. package/dist/local-supervisor.d.ts +51 -0
  90. package/dist/local-supervisor.js +221 -0
  91. package/dist/modal.d.ts +15 -7
  92. package/dist/modal.js +83 -39
  93. package/dist/mount-archil.js +4 -4
  94. package/dist/orgo-channel.js +16 -13
  95. package/dist/orgo-desktop.d.ts +153 -0
  96. package/dist/orgo-desktop.js +1614 -0
  97. package/dist/orgo-names.d.ts +52 -0
  98. package/dist/orgo-names.js +84 -0
  99. package/dist/orgo.d.ts +18 -13
  100. package/dist/orgo.js +54 -128
  101. package/dist/phone-harness.d.ts +4 -8
  102. package/dist/phone-harness.js +48 -46
  103. package/dist/protocol.d.ts +20 -0
  104. package/dist/protocol.js +9 -0
  105. package/dist/provider.d.ts +151 -10
  106. package/dist/provider.js +70 -0
  107. package/dist/providers.d.ts +22 -17
  108. package/dist/providers.js +14 -16
  109. package/dist/result.d.ts +11 -1
  110. package/dist/result.js +11 -0
  111. package/dist/test-connection.js +2 -2
  112. package/package.json +42 -2
@@ -0,0 +1,30 @@
1
+ import { type LocalBrowserOptions, type LocalBrowserProvider } from "../local-chrome.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_CHROME";
5
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
6
+ readonly chrome: "COMPUTER_LOCAL_CHROME_PATH";
7
+ /** headed: "1" shows the window. */
8
+ readonly headed: "COMPUTER_LOCAL_CHROME_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_CHROME";
13
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
14
+ readonly chrome: "COMPUTER_LOCAL_CHROME_PATH";
15
+ /** headed: "1" shows the window. */
16
+ readonly headed: "COMPUTER_LOCAL_CHROME_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
+ // Local Chrome for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider local-chrome`.
2
+ // It starts a real Chrome on this machine (nothing billed, no key), so it runs only with
3
+ // AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME=1. The provider reads no environment: this module reads its own
4
+ // COMPUTER_LOCAL_CHROME_* names, and PATH to find a Chrome, and passes each to create() as its option.
5
+ import { BROWSER_IMAGE } from "../descriptors/shared.js";
6
+ import { create } from "../local-chrome.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_CHROME",
10
+ /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
11
+ chrome: "COMPUTER_LOCAL_CHROME_PATH",
12
+ /** headed: "1" shows the window. */
13
+ headed: "COMPUTER_LOCAL_CHROME_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-chrome: 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 Chrome conformance module starts a real Chrome on this machine: set ${LOCAL_ENV.live}=1 to run it`);
35
+ return create(settingsFromEnv(env));
36
+ }
@@ -1,8 +1,9 @@
1
1
  import { type OrgoChannel, type OrgoProvider, type OrgoWebSocketFactory } from "../orgo.js";
2
+ import type { OrgoDesktopProvider } from "../orgo-desktop.js";
2
3
  /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
3
4
  export declare const ENV: {
4
5
  readonly live: "AGENTRUN_COMPUTER_LIVE_ORGO";
5
- /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). */
6
+ /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
6
7
  readonly template: "COMPUTER_ORGO_TEMPLATE";
7
8
  /** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
8
9
  readonly key: "COMPUTER_ORGO_API_KEY";
@@ -10,6 +11,8 @@ export declare const ENV: {
10
11
  readonly workspace: "COMPUTER_ORGO_WORKSPACE";
11
12
  /** Orgo's API; default https://www.orgo.ai/api. */
12
13
  readonly apiUrl: "COMPUTER_ORGO_API_URL";
14
+ /** The desktop: linux (default), windows or macos. */
15
+ readonly os: "COMPUTER_ORGO_OS";
13
16
  };
14
17
  /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
15
18
  export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
@@ -33,9 +36,12 @@ export declare function settingsFromEnv(env?: Record<string, string | undefined>
33
36
  workspaceId: string;
34
37
  apiUrl?: string;
35
38
  };
36
- /** The image every computer of the run starts from: COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
39
+ /** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
37
40
  export declare function conformanceImage({ env }?: Pick<OrgoModuleOptions, "env">): string;
38
41
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
39
- export declare function createProvider(options?: OrgoModuleOptions): Promise<OrgoProvider>;
40
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
41
- export declare function createDriftedProvider({ buildDaemon, ...options }?: OrgoModuleOptions): Promise<OrgoProvider>;
42
+ export declare function createProvider(options?: OrgoModuleOptions): Promise<OrgoProvider | OrgoDesktopProvider>;
43
+ /**
44
+ * The same provider uploading a daemon that reports version <version>-drift, for the drift.version case; on Windows and
45
+ * macOS, where no daemon runs, the provider whose computer's hello reports that version.
46
+ */
47
+ export declare function createDriftedProvider({ buildDaemon, ...options }?: OrgoModuleOptions): Promise<OrgoProvider | OrgoDesktopProvider>;
@@ -3,15 +3,19 @@
3
3
  // COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names. The live switch is checked
4
4
  // first, before any other setting is read.
5
5
  //
6
- // The daemon is uploaded into each computer (dist/computerd-linux-amd64, `npm run build:daemon`); the drifted provider
7
- // uploads one built with Go as version <version>-drift. Every computer of a run lives at most 1 h, Orgo's shortest end
8
- // (ends_in_hours 1): Orgo deletes it then whatever happens to the run.
9
- import { create, ORGO_BASE_IMAGE } from "../orgo.js";
6
+ // COMPUTER_ORGO_OS picks the desktop: linux (the default), windows or macos. On Linux the daemon is uploaded into each
7
+ // computer (dist/computerd-linux-amd64, `npm run build:daemon`); the drifted provider uploads one built with Go as
8
+ // version <version>-drift. On Windows and macOS no daemon runs: the provider answers over Orgo's API (daemon none), the
9
+ // run's image is "windows" or "macos", and `--kind desktop` runs the desktop's cases, with the Windows fixture this
10
+ // package carries. Every computer of a run lives at most 1 h (on Linux and Windows Orgo's shortest end, ends_in_hours
11
+ // 1, deletes it then whatever happens to the run; macOS has no Orgo end, so the janitor alone ends it).
12
+ import { ORGO_BASE_IMAGE, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE } from "../descriptors/orgo.js";
13
+ import { create } from "../orgo.js";
10
14
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
11
15
  /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
12
16
  export const ENV = {
13
17
  live: "AGENTRUN_COMPUTER_LIVE_ORGO",
14
- /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). */
18
+ /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
15
19
  template: "COMPUTER_ORGO_TEMPLATE",
16
20
  /** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
17
21
  key: "COMPUTER_ORGO_API_KEY",
@@ -19,6 +23,8 @@ export const ENV = {
19
23
  workspace: "COMPUTER_ORGO_WORKSPACE",
20
24
  /** Orgo's API; default https://www.orgo.ai/api. */
21
25
  apiUrl: "COMPUTER_ORGO_API_URL",
26
+ /** The desktop: linux (default), windows or macos. */
27
+ os: "COMPUTER_ORGO_OS",
22
28
  };
23
29
  const ORGO_ENV = ENV;
24
30
  /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
@@ -26,12 +32,20 @@ export const CONFORMANCE_MAX_LIFETIME_MS = 60 * 60_000;
26
32
  /** For the run's report: what this configuration means for the suite. */
27
33
  export const conformanceNotes = [
28
34
  "orgo: a Linux desktop on Orgo with computerd inside, on Orgo's own X display :99, its tools as 2510:2510; janitor-ended at the exact deadline its name carries, and within 1 h whatever happens (Orgo deletes it at ends_in_hours 1, the backstop); network none is init's own namespace (--own-network), probed from inside at the outside and at every port root listens on, since Orgo has no egress control; the desktop's path sockets are root's alone but the display's; no mount.",
35
+ "orgo windows and macos (COMPUTER_ORGO_OS): daemon none, the provider answering over Orgo's REST API: the screen from its screenshot, the pointer and keys from its click, drag, scroll, type and key calls, exec from its bash call (PowerShell on Windows), files through PowerShell on Windows; network open, since Orgo has no egress control and no daemon runs inside to hold one; the cases written for Linux (sh, /proc) are skipped in words.",
29
36
  ];
30
37
  function live(env) {
31
38
  if (env[ORGO_ENV.live] !== "1") {
32
39
  throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key the lead has OKed, to run it`);
33
40
  }
34
41
  }
42
+ /** The desktop COMPUTER_ORGO_OS names, linux when it names none; a throw in words for any other. */
43
+ function osOf(env) {
44
+ const os = env[ORGO_ENV.os] || "linux";
45
+ if (os !== "linux" && os !== "windows" && os !== "macos")
46
+ throw new Error(`${ORGO_ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
47
+ return os;
48
+ }
35
49
  /** The provider's settings from COMPUTER_ORGO_* alone: the key, the workspace, and Orgo's API when named. No word holds the key. */
36
50
  export function settingsFromEnv(env = process.env) {
37
51
  const apiKey = env[ORGO_ENV.key];
@@ -43,11 +57,19 @@ export function settingsFromEnv(env = process.env) {
43
57
  const apiUrl = env[ORGO_ENV.apiUrl] || undefined;
44
58
  return { apiKey, workspaceId, ...(apiUrl ? { apiUrl } : {}) };
45
59
  }
46
- /** The image every computer of the run starts from: COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
60
+ /** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
47
61
  export function conformanceImage({ env = process.env } = {}) {
62
+ const os = osOf(env);
63
+ if (os === "windows")
64
+ return ORGO_WINDOWS_IMAGE;
65
+ if (os === "macos")
66
+ return ORGO_MACOS_IMAGE;
48
67
  return env[ORGO_ENV.template] || ORGO_BASE_IMAGE;
49
68
  }
50
69
  function build({ env = process.env, fetch, webSocket, channel }, daemonPath) {
70
+ const os = osOf(env);
71
+ if (os !== "linux")
72
+ return create({ os, ...settingsFromEnv(env), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS, ...(fetch ? { fetch } : {}) });
51
73
  return create({
52
74
  ...settingsFromEnv(env),
53
75
  maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS,
@@ -62,8 +84,15 @@ export async function createProvider(options = {}) {
62
84
  live(options.env ?? process.env);
63
85
  return build(options, options.daemonPath);
64
86
  }
65
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
87
+ /**
88
+ * The same provider uploading a daemon that reports version <version>-drift, for the drift.version case; on Windows and
89
+ * macOS, where no daemon runs, the provider whose computer's hello reports that version.
90
+ */
66
91
  export async function createDriftedProvider({ buildDaemon = (version) => buildDriftDaemon("amd64", version), ...options } = {}) {
67
- live(options.env ?? process.env);
92
+ const env = options.env ?? process.env;
93
+ live(env);
94
+ const os = osOf(env);
95
+ if (os !== "linux")
96
+ return create({ os, ...settingsFromEnv(env), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS, daemonVersion: DRIFT_VERSION, ...(options.fetch ? { fetch: options.fetch } : {}) });
68
97
  return build(options, await buildDaemon(DRIFT_VERSION));
69
98
  }
@@ -8,7 +8,8 @@ import { randomBytes } from "node:crypto";
8
8
  import { linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
9
9
  import { tmpdir } from "node:os";
10
10
  import { dirname, join } from "node:path";
11
- import { adbCli, create, PHONE_IMAGE } from "../phone-harness.js";
11
+ import { PHONE_IMAGE } from "../descriptors/phone-harness.js";
12
+ import { adbCli, create } from "../phone-harness.js";
12
13
  /** The environment this module reads, by name. */
13
14
  export const PHONE_ENV = {
14
15
  /** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
@@ -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,13 +14,16 @@ 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
- // linux computer is never held to screen): it is listed as optional, out of Core's lines and count.
23
- const optional = (r) => r.status === "skip" && r.undeclared !== undefined;
24
+ // linux computer is never held to screen), nor one written for another system: it is listed as optional, out of
25
+ // Core's lines and count, its reason kept.
26
+ const optional = (r) => r.status === "skip" && (r.undeclared !== undefined || r.os !== undefined);
24
27
  const levelOf = (r) => (r.level === "core" && optional(r) ? "optional" : r.level);
25
28
  for (const level of ["core", "full", "optional"]) {
26
29
  for (const group of GROUPS) {
@@ -54,10 +57,13 @@ export function formatReport(report) {
54
57
  const [first = "", ...rest] = wrap(notRun);
55
58
  lines.push(`core ${"not run".padEnd(9)} ${first}`, ...rest.map((more) => `${INDENT}${more}`));
56
59
  }
60
+ // Each computer's daemon, named with its role: computers of one run may answer differently (a GPU computer's fence).
61
+ for (const daemon of daemons)
62
+ lines.push(`daemon ${daemon.computer} (${daemon.role}): ${said(daemon)}${daemon.fence === undefined ? "" : ` · fence ${daemon.fence}`}`);
57
63
  for (const note of report.notes ?? [])
58
64
  lines.push(`note: ${note}`);
59
- for (const { computer, note } of report.computerNotes ?? [])
60
- lines.push(`note ${computer}: ${note}`);
65
+ for (const { computer, role, note } of report.computerNotes ?? [])
66
+ lines.push(`note ${computer} (${role}): ${note}`);
61
67
  // What a provider said through onNote, such as a release whose final sync or checkin did not go cleanly.
62
68
  for (const { computer, note } of report.providerNotes ?? [])
63
69
  lines.push(`provider note ${computer}: ${note}`);
@@ -3,13 +3,14 @@ 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";
9
10
  import { dialCdp } from "./cdp.js";
10
11
  import { startFixture } from "./fixture.js";
11
12
  import { kindCases, kindRunProblem, kindVerdict } from "./kind.js";
12
- import { coreGroups, } from "./types.js";
13
+ import { caseOs, coreGroups, } from "./types.js";
13
14
  /** The label every computer of a run carries, with the run's id. */
14
15
  export const RUN_LABEL = "agentrun.conformance";
15
16
  /** The lifetime a run's computers ask for, at most the provider's own cap: a metered phone's cap is its hard stop. */
@@ -84,9 +85,13 @@ 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), its
92
+ // parked configurations with its offered ones: a parked one built for the suite is held to its own declaration.
93
+ const entry = PROVIDERS.find((one) => one.id === provider.id);
94
+ const declared = options.declared ?? (entry ? [...entry.capabilities, ...(entry.parked ?? [])] : undefined);
90
95
  const kindProblem = kind === undefined ? undefined : kindRunProblem(kind);
91
96
  if (kindProblem !== undefined)
92
97
  throw new TypeError(kindProblem);
@@ -107,7 +112,7 @@ export async function runConformance(provider, options) {
107
112
  kind: capabilities.kind,
108
113
  daemonMode: capabilities.daemon,
109
114
  image,
110
- daemon: null,
115
+ daemons: [],
111
116
  ...(only === undefined ? {} : { only }),
112
117
  ...(only === undefined && kind === undefined ? {} : { coreNotRun: cases.filter((c) => c.level === "core" && !selected.includes(c)).map((c) => c.id) }),
113
118
  results: [],
@@ -150,24 +155,35 @@ export async function runConformance(provider, options) {
150
155
  report.cleanup.errors.push(words(error).startsWith(`release ${ref.name}`) ? words(error) : `release ${ref.name} threw: ${words(error)}`);
151
156
  }
152
157
  };
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))
158
+ /** Each computer the run made, by name: its role, "shared" or the id of the case that made it. */
159
+ const roles = new Map();
160
+ /**
161
+ * Records the computer's role, and the notes a create returned beside its ref, each naming the computer and its role:
162
+ * never dropped with the ref.
163
+ */
164
+ const noteCreated = (created, role) => {
165
+ if (!created.ok)
166
+ return;
167
+ roles.set(created.value.name, role);
168
+ if (!Array.isArray(created.value.notes))
156
169
  return;
157
170
  for (const note of created.value.notes)
158
- (report.computerNotes ??= []).push({ computer: created.value.name, note: String(note) });
171
+ (report.computerNotes ??= []).push({ computer: created.value.name, role, note: String(note) });
159
172
  };
160
173
  /** Deletes the computer a create gives after nobody waits for it any more, and names it in the report. */
161
174
  const lateCreate = (creating, what, by = provider) => keep(creating.then(async (created) => {
162
- noteCreated(created);
175
+ noteCreated(created, "shared");
163
176
  if (!created.ok)
164
177
  return;
165
178
  report.cleanup.late.push(created.value.name);
166
179
  await release(created.value, by);
167
180
  }, () => { }), what);
168
181
  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 };
182
+ /** Records a computer's first hello, naming the computer and its role: the one it was made for, else the connecting case's. */
183
+ const sawHello = (computer, hello, role) => {
184
+ if (report.daemons.some((daemon) => daemon.computer === computer))
185
+ return;
186
+ 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
187
  };
172
188
  /** The run's shared computer, made the first time a case needs it or the daemon's hello. */
173
189
  let shared;
@@ -186,7 +202,7 @@ export async function runConformance(provider, options) {
186
202
  lateCreate(creating, "create (the run's computer)");
187
203
  return { error: words(error) };
188
204
  }
189
- noteCreated(created);
205
+ noteCreated(created, "shared");
190
206
  if (!created.ok)
191
207
  return { error: createError(created) };
192
208
  sharedRef = created.value;
@@ -202,7 +218,7 @@ export async function runConformance(provider, options) {
202
218
  if (!connected.ok)
203
219
  return { error: `connect: ${connected.error.code}: ${connected.error.message}` };
204
220
  await bounded(connected.value.close(), CLOSE_MS);
205
- sawHello(connected.value.hello);
221
+ sawHello(created.value.name, connected.value.hello, "shared");
206
222
  return { ref: created.value, hello: connected.value.hello };
207
223
  })().catch((error) => ({ error: `the provider threw: ${words(error)}` })));
208
224
  /** Why a case cannot run here, or undefined when everything it needs is declared. */
@@ -238,9 +254,18 @@ export async function runConformance(provider, options) {
238
254
  else if (need === "release:stop" && !(Array.isArray(capabilities.release) && capabilities.release.includes("stop"))) {
239
255
  return `the provider does not declare ${need}`;
240
256
  }
257
+ else if (need === "persistence" && capabilities.persistence === undefined) {
258
+ return `the provider does not declare ${need}: it keeps no computer for an agent`;
259
+ }
241
260
  else if (need === "vendor-agent" && !Array.isArray(capabilities.vendorAgentPorts)) {
242
261
  return `the provider does not declare ${need} (capabilities().vendorAgentPorts): no vendor's agent runs beside its computers' programs`;
243
262
  }
263
+ else if (need === "secrets" && planted === undefined) {
264
+ return "the provider takes no secret: its conformance module's ENV names no key, token or secret";
265
+ }
266
+ else if (need === "gpu" && capabilities.gpu === undefined) {
267
+ return "the provider does not declare gpu (capabilities().gpu): it offers no GPU";
268
+ }
244
269
  }
245
270
  return undefined;
246
271
  };
@@ -275,6 +300,10 @@ export async function runConformance(provider, options) {
275
300
  report.undeclared.push(need);
276
301
  return { ...result("skip", why), undeclared: lacking };
277
302
  }
303
+ // A case written for other systems (a POSIX program, /proc) is not this computer's to pass or fail: skipped in words.
304
+ const systems = caseOs(c);
305
+ if (systems !== undefined && !systems.includes(capabilities.os))
306
+ return { ...result("skip", `the case is written for ${systems.join(" or ")}, and this computer runs ${capabilities.os}`), os: systems };
278
307
  // The shared computer is made, bounded on its own, before the case's time starts.
279
308
  const sharedComputer = (c.computer ?? "shared") === "shared" ? await getShared() : undefined;
280
309
  const timeoutMs = c.timeoutMs ?? caseTimeoutMs;
@@ -314,13 +343,13 @@ export async function runConformance(provider, options) {
314
343
  });
315
344
  keep(connecting, `connect to ${ref.name} (${c.id})`);
316
345
  const once = unwrap(await connecting, `connect to ${ref.name}`);
317
- sawHello(once.hello);
346
+ sawHello(ref.name, once.hello, c.id);
318
347
  return once;
319
348
  };
320
349
  /** create through by, kept: what it gives is deleted when the case ends, or as it comes after that. */
321
350
  const attempt = (whole, by = provider) => {
322
351
  const creating = by.create(whole, { signal: caseSignal }).then((created) => {
323
- noteCreated(created);
352
+ noteCreated(created, c.id);
324
353
  if (created.ok)
325
354
  track(created.value, by);
326
355
  return created;
@@ -374,6 +403,13 @@ export async function runConformance(provider, options) {
374
403
  track,
375
404
  connect: (ref) => connect(ref ?? needComputer().ref),
376
405
  async home() {
406
+ if (capabilities.os === "windows") {
407
+ // Windows has no HOME: the profile folder is USERPROFILE, read through PowerShell's own environment.
408
+ const profile = (await t.exec(["powershell.exe", "-NoProfile", "-Command", "[Console]::Out.Write($env:USERPROFILE)"])).out.trim();
409
+ if (!/^[A-Za-z]:[\\/]/.test(profile))
410
+ throw new Error(`USERPROFILE in the computer is ${show(profile)}, not an absolute path`);
411
+ return profile.replace(/[\\/]+$/, "");
412
+ }
377
413
  const env = await t.exec(["env"]);
378
414
  const home = /^HOME=(.*)$/m.exec(env.out)?.[1];
379
415
  if (home === undefined || !home.startsWith("/"))
@@ -386,10 +422,11 @@ export async function runConformance(provider, options) {
386
422
  return path;
387
423
  },
388
424
  fixture() {
389
- if (fixture === undefined) {
425
+ // A Windows desktop's fixture is a PowerShell script this package carries (windows-fixture.ts): no file to name.
426
+ if (fixture === undefined && !(capabilities.kind === "desktop" && capabilities.os === "windows")) {
390
427
  return t.skip("no fixture was given: --fixture names computerd-fixture for a desktop, or the fixture APK for an Android phone");
391
428
  }
392
- started ??= startFixture(t, fixture, (stop) => {
429
+ started ??= startFixture(t, fixture ?? "", (stop) => {
393
430
  stopFixture = stop;
394
431
  });
395
432
  return started;
@@ -409,6 +446,12 @@ export async function runConformance(provider, options) {
409
446
  return t.skip("no drifted provider was given: a provider module exports createDriftedProvider() for the drift cases");
410
447
  return await drifted();
411
448
  },
449
+ declared,
450
+ async planted() {
451
+ if (planted === undefined)
452
+ return t.skip("no provider with planted secrets was given: the provider takes no secret, or its module lists none in ENV");
453
+ return await planted();
454
+ },
412
455
  async runFolder(kind) {
413
456
  const none = `the run was given no run folder for mount kind ${kind}`;
414
457
  if (mountFor === undefined)
@@ -422,6 +465,12 @@ export async function runConformance(provider, options) {
422
465
  folders.push(folder);
423
466
  return folder;
424
467
  },
468
+ gpu() {
469
+ // A GPU bills by the second: the run names the one it pays for, never a default.
470
+ if (gpu === undefined)
471
+ return t.skip("the run named no GPU: give --gpu <type>[:<count>] (or options.gpu), one the provider declares in capabilities().gpu");
472
+ return { type: gpu.type, count: gpu.count };
473
+ },
425
474
  async exec(argv, extra = {}, client = t.client) {
426
475
  const ran = unwrap(await client.call("exec.run", { argv, timeoutMs: patience, ...extra }, { signal: caseSignal }), `exec.run ${show(argv)}`);
427
476
  const decode = (base64) => Buffer.from(base64, "base64").toString("utf8");
@@ -545,8 +594,9 @@ export async function runConformance(provider, options) {
545
594
  }
546
595
  await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs);
547
596
  }
548
- // A Core case skipped for an optional group the computer does not declare is not part of Core's verdict.
549
- const core = report.results.filter((r) => r.level === "core" && !(r.status === "skip" && r.undeclared !== undefined));
597
+ // A Core case skipped for an optional group the computer does not declare, or written for another system, is not part
598
+ // of Core's verdict.
599
+ const core = report.results.filter((r) => r.level === "core" && !(r.status === "skip" && (r.undeclared !== undefined || r.os !== undefined)));
550
600
  const clean = report.cleanup.left.length === 0 && report.cleanup.errors.length === 0;
551
601
  const corePassed = core.every((r) => r.status === "pass") && clean;
552
602
  if ((report.coreNotRun ?? []).length === 0)