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

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 (131) hide show
  1. package/README.md +187 -62
  2. package/box/Dockerfile +4 -3
  3. package/box/install.sh +57 -11
  4. package/dist/agent37.js +6 -9
  5. package/dist/attach.d.ts +24 -4
  6. package/dist/attach.js +50 -19
  7. package/dist/boxd.js +22 -9
  8. package/dist/browserbase.d.ts +6 -2
  9. package/dist/browserbase.js +50 -7
  10. package/dist/child-env.d.ts +11 -0
  11. package/dist/child-env.js +22 -0
  12. package/dist/chrome.d.ts +5 -2
  13. package/dist/chrome.js +5 -2
  14. package/dist/cloudflare.d.ts +2 -0
  15. package/dist/cloudflare.js +5 -3
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +1 -1
  19. package/dist/conformance/agent37.d.ts +10 -38
  20. package/dist/conformance/agent37.js +25 -113
  21. package/dist/conformance/archil.d.ts +13 -3
  22. package/dist/conformance/archil.js +22 -17
  23. package/dist/conformance/boxd.d.ts +8 -31
  24. package/dist/conformance/boxd.js +19 -74
  25. package/dist/conformance/browserbase.d.ts +3 -6
  26. package/dist/conformance/browserbase.js +6 -17
  27. package/dist/conformance/cases/health.js +6 -3
  28. package/dist/conformance/cli.d.ts +3 -1
  29. package/dist/conformance/cli.js +69 -9
  30. package/dist/conformance/cloudflare.d.ts +3 -6
  31. package/dist/conformance/cloudflare.js +7 -15
  32. package/dist/conformance/daytona.d.ts +6 -20
  33. package/dist/conformance/daytona.js +22 -57
  34. package/dist/conformance/dial-only.d.ts +4 -3
  35. package/dist/conformance/dial-only.js +3 -3
  36. package/dist/conformance/docker.d.ts +4 -5
  37. package/dist/conformance/docker.js +8 -14
  38. package/dist/conformance/e2b.d.ts +10 -36
  39. package/dist/conformance/e2b.js +27 -84
  40. package/dist/conformance/fly.d.ts +3 -6
  41. package/dist/conformance/fly.js +2 -6
  42. package/dist/conformance/groundbox.d.ts +7 -23
  43. package/dist/conformance/groundbox.js +16 -56
  44. package/dist/conformance/index.d.ts +1 -0
  45. package/dist/conformance/index.js +1 -0
  46. package/dist/conformance/kernel.d.ts +3 -6
  47. package/dist/conformance/kernel.js +5 -15
  48. package/dist/conformance/kind.d.ts +0 -6
  49. package/dist/conformance/kind.js +0 -4
  50. package/dist/conformance/local-chrome.d.ts +5 -7
  51. package/dist/conformance/local-chrome.js +7 -11
  52. package/dist/conformance/modal.d.ts +10 -38
  53. package/dist/conformance/modal.js +27 -74
  54. package/dist/conformance/module-kit.d.ts +87 -0
  55. package/dist/conformance/module-kit.js +88 -0
  56. package/dist/conformance/morph.d.ts +7 -23
  57. package/dist/conformance/morph.js +20 -66
  58. package/dist/conformance/orgo.d.ts +5 -10
  59. package/dist/conformance/orgo.js +15 -27
  60. package/dist/conformance/phone-harness.d.ts +3 -5
  61. package/dist/conformance/phone-harness.js +3 -11
  62. package/dist/conformance/runner.d.ts +13 -3
  63. package/dist/conformance/runner.js +32 -11
  64. package/dist/conformance/smolcloud.d.ts +7 -23
  65. package/dist/conformance/smolcloud.js +16 -49
  66. package/dist/conformance/sweep.d.ts +10 -5
  67. package/dist/conformance/sweep.js +91 -38
  68. package/dist/conformance/tti.d.ts +69 -0
  69. package/dist/conformance/tti.js +205 -0
  70. package/dist/conformance/types.d.ts +9 -2
  71. package/dist/daytona.js +60 -20
  72. package/dist/descriptor.d.ts +10 -0
  73. package/dist/descriptor.js +7 -0
  74. package/dist/descriptors/browserbase.d.ts +3 -0
  75. package/dist/descriptors/browserbase.js +4 -0
  76. package/dist/descriptors/docker.d.ts +1 -0
  77. package/dist/descriptors/docker.js +3 -0
  78. package/dist/descriptors/env-names.d.ts +32 -0
  79. package/dist/descriptors/env-names.js +60 -0
  80. package/dist/descriptors/index.d.ts +9 -2
  81. package/dist/descriptors/kernel.d.ts +3 -0
  82. package/dist/descriptors/kernel.js +2 -0
  83. package/dist/descriptors/local-chrome.d.ts +1 -1
  84. package/dist/descriptors/local-chrome.js +5 -3
  85. package/dist/descriptors/phone-harness.d.ts +1 -1
  86. package/dist/descriptors/phone-harness.js +4 -2
  87. package/dist/docker/egress.d.ts +7 -0
  88. package/dist/docker/egress.js +8 -0
  89. package/dist/docker/image.d.ts +5 -1
  90. package/dist/docker/image.js +12 -8
  91. package/dist/docker.d.ts +52 -13
  92. package/dist/docker.js +166 -92
  93. package/dist/drift.js +6 -6
  94. package/dist/e2b.d.ts +2 -2
  95. package/dist/e2b.js +2 -3
  96. package/dist/groundbox.js +6 -6
  97. package/dist/host.d.ts +23 -0
  98. package/dist/hosted/download.d.ts +23 -0
  99. package/dist/hosted/download.js +144 -0
  100. package/dist/hosted/process.d.ts +5 -0
  101. package/dist/hosted/process.js +20 -0
  102. package/dist/hosted/provider.js +120 -48
  103. package/dist/hosted/rest.d.ts +19 -8
  104. package/dist/hosted/rest.js +47 -14
  105. package/dist/hosted/scripts.d.ts +10 -0
  106. package/dist/hosted/scripts.js +23 -2
  107. package/dist/index.d.ts +3 -1
  108. package/dist/index.js +3 -1
  109. package/dist/janitor.d.ts +7 -1
  110. package/dist/janitor.js +2 -2
  111. package/dist/kernel.js +1 -1
  112. package/dist/local-chrome.d.ts +5 -2
  113. package/dist/local-chrome.js +4 -2
  114. package/dist/local-supervisor.js +1 -0
  115. package/dist/modal.d.ts +6 -5
  116. package/dist/modal.js +7 -7
  117. package/dist/morph.js +5 -8
  118. package/dist/orgo-channel.d.ts +3 -2
  119. package/dist/orgo-channel.js +3 -3
  120. package/dist/orgo-desktop.js +2 -4
  121. package/dist/orgo.js +2 -4
  122. package/dist/phone-harness.d.ts +7 -5
  123. package/dist/phone-harness.js +60 -61
  124. package/dist/protocol.d.ts +10 -0
  125. package/dist/protocol.js +17 -0
  126. package/dist/provider.d.ts +6 -2
  127. package/dist/screen-watch.d.ts +6 -1
  128. package/dist/screen-watch.js +166 -12
  129. package/dist/vendor-sdk.d.ts +9 -0
  130. package/dist/vendor-sdk.js +26 -0
  131. package/package.json +8 -1
@@ -1,6 +1,11 @@
1
+ // Morph for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider morph`. It makes real
2
+ // instances, which bill until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_MORPH=1 and a key for an account you
3
+ // can bill, under COMPUTER_MORPH_API_KEY (never MORPH_API_KEY, which may hold another team's key). The box snapshot's
4
+ // first build in an account takes minutes. Every computer of a run lives at most 30 minutes, by Morph's TTL and init's
5
+ // deadline, and the run's sweep deletes what is left.
1
6
  import { accountOf, create } from "../morph.js";
2
- import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
3
- /** The environment this module reads, by name, each for the option its comment names, the live switch and the run's snapshot. */
7
+ import { hostedModule, lifetimeFromEnv, preparedImage, requiredSecret, setOptions } from "./module-kit.js";
8
+ export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
4
9
  export const MORPH_ENV = {
5
10
  live: "AGENTRUN_COMPUTER_LIVE_MORPH",
6
11
  /** apiKey, required: the account's API key. */
@@ -14,82 +19,31 @@ export const MORPH_ENV = {
14
19
  /** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
15
20
  maxLifetimeMs: "COMPUTER_MORPH_MAX_LIFETIME_MS",
16
21
  };
17
- /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
18
22
  export const ENV = MORPH_ENV;
19
23
  /** The provider's options this module reads from env, each only when its name is set; throws in words without a key, never echoing it. */
20
24
  export function settingsFromEnv(env = process.env) {
21
- const apiKey = env[MORPH_ENV.key];
22
- if (apiKey === undefined || apiKey === "")
23
- throw new Error(`set ${MORPH_ENV.key} to a Morph API key: the conformance module reads it there and nowhere else, never from MORPH_API_KEY`);
24
- const lifetime = env[MORPH_ENV.maxLifetimeMs] || undefined;
25
- if (lifetime !== undefined && !/^\d+$/.test(lifetime))
26
- throw new Error(`${MORPH_ENV.maxLifetimeMs} is a whole number of milliseconds, such as 86400000`);
27
- const apiUrl = env[MORPH_ENV.apiUrl] || undefined;
28
- const daemonPath = env[MORPH_ENV.daemon] || undefined;
29
- return {
30
- apiKey,
31
- ...(apiUrl === undefined ? {} : { apiUrl }),
32
- ...(daemonPath === undefined ? {} : { daemonPath }),
33
- ...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
34
- };
25
+ const apiKey = requiredSecret(env, MORPH_ENV.key, "a Morph API key");
26
+ const lifetime = lifetimeFromEnv(env, MORPH_ENV.maxLifetimeMs, "86400000");
27
+ return { apiKey, ...setOptions(env, { apiUrl: MORPH_ENV.apiUrl, daemonPath: MORPH_ENV.daemon }), ...lifetime };
35
28
  }
36
- /** The longest lifetime a computer of a run may ask for: Morph's TTL and init end it at its deadline, the sweep deletes it. */
37
- export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
38
- /** For the run's report: what this configuration means for the suite. */
39
29
  export const conformanceNotes = [
40
30
  "morph: every computer is a Morph instance started from a snapshot (the box snapshot, built in the key's account, unless COMPUTER_MORPH_SNAPSHOT names one), with a TTL whose action is stop, read back from Morph and probed from inside; the daemon is a child, started over SSH through Morph's gateway (ssh.cloud.morph.so, as the instance id with the instance's own key), and every command goes over that SSH. Morph has no egress control: network none, open and a list are all init's. No Archil mount yet and no desktop; no stream(), so screen.stream is skipped.",
41
31
  ];
42
- function live(env) {
43
- if (env[MORPH_ENV.live] !== "1") {
44
- throw new Error(`the Morph conformance module makes real instances, which bill until deleted: set ${MORPH_ENV.live}=1, with a key for an account you can bill, to run it`);
45
- }
46
- }
47
- /** The test doubles a caller hands in, each only when given. */
48
- const doubles = ({ ssh2, fetch, timeouts, onNote, sshHost, sshPort }) => ({
49
- ...(ssh2 ? { ssh2 } : {}),
50
- ...(fetch ? { fetch } : {}),
51
- ...(timeouts ? { timeouts } : {}),
52
- ...(onNote ? { onNote } : {}),
53
- ...(sshHost ? { sshHost } : {}),
54
- ...(sshPort ? { sshPort } : {}),
32
+ export const { createProvider, createDriftedProvider, createHost, sweepScope } = hostedModule({
33
+ live: { name: MORPH_ENV.live, what: "the Morph conformance module makes real instances, which bill until deleted", whose: "a key for an account you can bill" },
34
+ settingsFromEnv,
35
+ create,
36
+ host: ["ssh2", "fetch", "timeouts", "onNote", "sshHost", "sshPort"],
37
+ run: [],
38
+ runDefined: ["daemonPath"],
39
+ // One key is one account, and one listing covers all of it.
40
+ scope: ({ apiKey, apiUrl }) => accountOf(apiKey, apiUrl),
55
41
  });
56
- /** A run's cap: COMPUTER_MORPH_MAX_LIFETIME_MS when it is shorter, else CONFORMANCE_MAX_LIFETIME_MS. */
57
- const runCap = (settings) => Math.min(settings.maxLifetimeMs ?? CONFORMANCE_MAX_LIFETIME_MS, CONFORMANCE_MAX_LIFETIME_MS);
58
- /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
59
- export async function createProvider(options = {}) {
60
- const { env = process.env, daemonPath } = options;
61
- live(env);
62
- const settings = settingsFromEnv(env);
63
- return create({ ...settings, ...doubles(options), ...(daemonPath === undefined ? {} : { daemonPath }), maxLifetimeMs: runCap(settings) });
64
- }
65
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
66
- export async function createDriftedProvider(options = {}) {
67
- const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
68
- live(env);
69
- const settings = settingsFromEnv(env);
70
- const daemonPath = await buildDaemon(DRIFT_VERSION);
71
- return create({ ...settings, ...doubles(options), daemonPath, maxLifetimeMs: runCap(settings) });
72
- }
73
42
  /** The run's snapshot: COMPUTER_MORPH_SNAPSHOT, else the box snapshot, found or built in the key's account first (live). */
74
43
  export async function conformanceImage(options = {}, { signal } = {}) {
75
44
  const { env = process.env } = options;
76
45
  const named = env[MORPH_ENV.snapshot];
77
46
  if (named)
78
47
  return named;
79
- const ready = await (await createProvider(options)).prepareImage(signal ? { signal } : {});
80
- if (!ready.ok)
81
- throw new Error(`the Morph box snapshot: ${ready.error.message}`);
82
- return ready.value;
83
- }
84
- /**
85
- * The Morph host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
86
- * since the sweep makes nothing, and it calls nothing until the sweep does.
87
- */
88
- export async function createHost(options = {}) {
89
- return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
90
- }
91
- /** Where the host lists, in words: one key is one account, and one listing covers all of it. The key is named by its sha256 prefix alone. */
92
- export function sweepScope({ env = process.env } = {}) {
93
- const { apiKey, apiUrl } = settingsFromEnv(env);
94
- return accountOf(apiKey, apiUrl);
48
+ return preparedImage(await createProvider(options), signal, "the Morph box snapshot");
95
49
  }
@@ -1,6 +1,6 @@
1
1
  import { type OrgoChannel, type OrgoProvider, type OrgoWebSocketFactory } from "../orgo.js";
2
2
  import type { OrgoDesktopProvider } from "../orgo-desktop.js";
3
- /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
3
+ import { type Env, type HostedModuleOptions } from "./module-kit.js";
4
4
  export declare const ENV: {
5
5
  readonly live: "AGENTRUN_COMPUTER_LIVE_ORGO";
6
6
  /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
@@ -14,24 +14,19 @@ export declare const ENV: {
14
14
  /** The desktop: linux (default), windows or macos. */
15
15
  readonly os: "COMPUTER_ORGO_OS";
16
16
  };
17
- /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
17
+ /** Orgo's shortest end, 1 h. */
18
18
  export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
19
- /** For the run's report: what this configuration means for the suite. */
20
19
  export declare const conformanceNotes: string[];
21
- export interface OrgoModuleOptions {
22
- /** Where the settings are read; default process.env. */
23
- env?: Record<string, string | undefined>;
20
+ export interface OrgoModuleOptions extends HostedModuleOptions {
24
21
  /** For tests: the REST calls, the terminal socket, or the whole channel. */
25
22
  fetch?: typeof fetch;
26
23
  webSocket?: OrgoWebSocketFactory;
27
24
  channel?: OrgoChannel;
28
- /** The daemon to upload; default this package's dist/computerd-linux-amd64. */
25
+ /** The daemon to upload. */
29
26
  daemonPath?: string;
30
- /** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
31
- buildDaemon?: (version: string) => Promise<string>;
32
27
  }
33
28
  /** The provider's settings from COMPUTER_ORGO_* alone: the key, and the workspace and Orgo's API when named. No word holds the key. */
34
- export declare function settingsFromEnv(env?: Record<string, string | undefined>): {
29
+ export declare function settingsFromEnv(env?: Env): {
35
30
  apiKey: string;
36
31
  workspaceId?: string;
37
32
  apiUrl?: string;
@@ -1,18 +1,14 @@
1
1
  // Orgo for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider orgo [--image <template>]`.
2
- // It makes real Orgo desktops, so it runs only with AGENTRUN_COMPUTER_LIVE_ORGO=1 and a key for an account you can bill, under
3
- // COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names, or the key's account's one
4
- // workspace when it names none. The live switch is checked first, before any other setting is read.
5
- //
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).
2
+ // It makes real Orgo desktops, under COMPUTER_ORGO_API_KEY (never ORGO_API_KEY). COMPUTER_ORGO_OS picks the desktop:
3
+ // linux (the default), windows or macos; on Windows and macOS no daemon runs, and the provider answers over Orgo's API:
4
+ // the run's image is "windows" or "macos", and `--kind desktop` runs the desktop's cases, with the Windows fixture this
5
+ // package carries.
6
+ // Every computer of a run lives at most 1 h (on Linux and Windows Orgo's shortest end, ends_in_hours 1, deletes it then
7
+ // whatever happens to the run; macOS has no Orgo end, so the janitor alone ends it).
12
8
  import { ORGO_BASE_IMAGE, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE } from "../descriptors/orgo.js";
13
9
  import { create } from "../orgo.js";
14
10
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
15
- /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
11
+ import { requireLive, setOptions } from "./module-kit.js";
16
12
  export const ENV = {
17
13
  live: "AGENTRUN_COMPUTER_LIVE_ORGO",
18
14
  /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
@@ -26,34 +22,26 @@ export const ENV = {
26
22
  /** The desktop: linux (default), windows or macos. */
27
23
  os: "COMPUTER_ORGO_OS",
28
24
  };
29
- const ORGO_ENV = ENV;
30
- /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
25
+ /** Orgo's shortest end, 1 h. */
31
26
  export const CONFORMANCE_MAX_LIFETIME_MS = 60 * 60_000;
32
- /** For the run's report: what this configuration means for the suite. */
33
27
  export const conformanceNotes = [
34
28
  "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
29
  "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.",
36
30
  ];
37
- function live(env) {
38
- if (env[ORGO_ENV.live] !== "1") {
39
- throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key for an account you can bill, to run it`);
40
- }
41
- }
31
+ const live = (env) => requireLive(env, ENV.live, "the Orgo conformance module makes real computers", "a key for an account you can bill");
42
32
  /** The desktop COMPUTER_ORGO_OS names, linux when it names none; a throw in words for any other. */
43
33
  function osOf(env) {
44
- const os = env[ORGO_ENV.os] || "linux";
34
+ const os = env[ENV.os] || "linux";
45
35
  if (os !== "linux" && os !== "windows" && os !== "macos")
46
- throw new Error(`${ORGO_ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
36
+ throw new Error(`${ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
47
37
  return os;
48
38
  }
49
39
  /** The provider's settings from COMPUTER_ORGO_* alone: the key, and the workspace and Orgo's API when named. No word holds the key. */
50
40
  export function settingsFromEnv(env = process.env) {
51
- const apiKey = env[ORGO_ENV.key];
41
+ const apiKey = env[ENV.key];
52
42
  if (!apiKey)
53
- throw new Error(`set ${ORGO_ENV.key} to an Orgo API key: the Orgo module reads it there and nowhere else, never from ORGO_API_KEY`);
54
- const workspaceId = env[ORGO_ENV.workspace] || undefined;
55
- const apiUrl = env[ORGO_ENV.apiUrl] || undefined;
56
- return { apiKey, ...(workspaceId ? { workspaceId } : {}), ...(apiUrl ? { apiUrl } : {}) };
43
+ throw new Error(`set ${ENV.key} to an Orgo API key: the Orgo module reads it there and nowhere else, never from ORGO_API_KEY`);
44
+ return { apiKey, ...setOptions(env, { workspaceId: ENV.workspace, apiUrl: ENV.apiUrl }) };
57
45
  }
58
46
  /** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
59
47
  export function conformanceImage({ env = process.env } = {}) {
@@ -62,7 +50,7 @@ export function conformanceImage({ env = process.env } = {}) {
62
50
  return ORGO_WINDOWS_IMAGE;
63
51
  if (os === "macos")
64
52
  return ORGO_MACOS_IMAGE;
65
- return env[ORGO_ENV.template] || ORGO_BASE_IMAGE;
53
+ return env[ENV.template] || ORGO_BASE_IMAGE;
66
54
  }
67
55
  function build({ env = process.env, fetch, webSocket, channel }, daemonPath) {
68
56
  const os = osOf(env);
@@ -1,5 +1,5 @@
1
1
  import { type AdbTransport, type PhoneHarnessProvider, type PhoneLedger, type PhoneProviderOptions } from "../phone-harness.js";
2
- /** The environment this module reads, by name. */
2
+ import { type Env } from "./module-kit.js";
3
3
  export declare const PHONE_ENV: {
4
4
  /** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
5
5
  readonly key: "COMPUTER_PHONE_HARNESS_API_KEY";
@@ -12,7 +12,6 @@ export declare const PHONE_ENV: {
12
12
  /** 1 to rent phones at all: each one is billed by the minute. */
13
13
  readonly live: "AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS";
14
14
  };
15
- /** The names this module reads, under the conformance modules' common name. */
16
15
  export declare const ENV: {
17
16
  /** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
18
17
  readonly key: "COMPUTER_PHONE_HARNESS_API_KEY";
@@ -32,7 +31,7 @@ export interface PhoneSettings {
32
31
  ledgerPath?: string;
33
32
  }
34
33
  /** The provider's settings this module reads from env, each only when its name is set. */
35
- export declare function settingsFromEnv(env?: Record<string, string | undefined>): PhoneSettings;
34
+ export declare function settingsFromEnv(env?: Env): PhoneSettings;
36
35
  /**
37
36
  * A ledger in a JSON file (mode 0600), read whole on each call and written whole by rename, so a reader never sees half
38
37
  * a file. Writes (put, remove) are one at a time across processes: in this process through one queue, and between
@@ -49,8 +48,7 @@ export declare function fileLedger(path: string, { waitMs }?: {
49
48
  /** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
50
49
  export declare const UI_FIXTURE_APK: string;
51
50
  export interface PhoneModuleOptions extends Pick<PhoneProviderOptions, "fetch" | "now" | "sleep" | "baseUrl" | "phoned"> {
52
- /** Where the settings are read; default process.env. */
53
- env?: Record<string, string | undefined>;
51
+ env?: Env;
54
52
  /** The adb runner; default the CLI the settings name. */
55
53
  adb?: AdbTransport | string;
56
54
  /** The ui fixture's APK; default UI_FIXTURE_APK. Installed on each phone when it is there. */
@@ -3,7 +3,6 @@
3
3
  // another process sees the run's phones, and its drifted twin, which expects phoned to report another version. A phone is
4
4
  // rented by the minute, so nothing is built without AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS=1, and a run's phones live at
5
5
  // most 10 min.
6
- // The provider reads no environment: this module reads these names and passes them in as options.
7
6
  import { createHash, randomBytes } from "node:crypto";
8
7
  import { existsSync, linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
9
8
  import { tmpdir } from "node:os";
@@ -11,7 +10,7 @@ import { dirname, join } from "node:path";
11
10
  import { fileURLToPath } from "node:url";
12
11
  import { PHONE_IMAGE } from "../descriptors/phone-harness.js";
13
12
  import { adbCli, create } from "../phone-harness.js";
14
- /** The environment this module reads, by name. */
13
+ import { requireLive, setOptions } from "./module-kit.js";
15
14
  export const PHONE_ENV = {
16
15
  /** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
17
16
  key: "COMPUTER_PHONE_HARNESS_API_KEY",
@@ -24,18 +23,12 @@ export const PHONE_ENV = {
24
23
  /** 1 to rent phones at all: each one is billed by the minute. */
25
24
  live: "AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS",
26
25
  };
27
- /** The names this module reads, under the conformance modules' common name. */
28
26
  export const ENV = PHONE_ENV;
29
27
  /** A conformance run's phones live at most this long. */
30
28
  const RUN_MAX_LIFETIME_MS = 10 * 60_000;
31
29
  /** The provider's settings this module reads from env, each only when its name is set. */
32
30
  export function settingsFromEnv(env = process.env) {
33
- return {
34
- ...(env[PHONE_ENV.key] ? { apiKey: env[PHONE_ENV.key] } : {}),
35
- ...(env[PHONE_ENV.platform] ? { platform: env[PHONE_ENV.platform] } : {}),
36
- ...(env[PHONE_ENV.adb] ? { adb: env[PHONE_ENV.adb] } : {}),
37
- ...(env[PHONE_ENV.ledger] ? { ledgerPath: env[PHONE_ENV.ledger] } : {}),
38
- };
31
+ return setOptions(env, { apiKey: PHONE_ENV.key, platform: PHONE_ENV.platform, adb: PHONE_ENV.adb, ledgerPath: PHONE_ENV.ledger });
39
32
  }
40
33
  /** How long a writer waits for a live writer's lock on the ledger. A write holds it for well under a millisecond. */
41
34
  const LOCK_WAIT_MS = 10_000;
@@ -219,8 +212,7 @@ export function fileLedger(path, { waitMs = LOCK_WAIT_MS } = {}) {
219
212
  /** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
220
213
  export const UI_FIXTURE_APK = fileURLToPath(new URL("../ui-fixture.apk", import.meta.url));
221
214
  function optionsOf({ env = process.env, adb, uiFixture = UI_FIXTURE_APK, ...rest }) {
222
- if (env[PHONE_ENV.live] !== "1")
223
- throw new Error(`a conformance run rents a cloud phone, billed by the minute: set ${PHONE_ENV.live}=1 to run it`);
215
+ requireLive(env, PHONE_ENV.live, "a conformance run rents a cloud phone, billed by the minute");
224
216
  const settings = settingsFromEnv(env);
225
217
  if (!settings.apiKey)
226
218
  throw new Error(`set ${PHONE_ENV.key} to the phone harness API key`);
@@ -3,9 +3,19 @@ import { type ConformanceOptions, type ConformanceReport } from "./types.js";
3
3
  /** The label every computer of a run carries, with the run's id. */
4
4
  export declare const RUN_LABEL = "agentrun.conformance";
5
5
  /**
6
- * Runs the cases against the provider and reports each one. Every computer carries the run's label; each one a case
7
- * makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is swept by the label
8
- * and the label is listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
6
+ * The label every computer of a run also carries, with an id minted by each runConformance call, never given. Several
7
+ * runners may share one run's id (two processes given one before file's --run), so the runner's own end-of-run sweeps
8
+ * go by this label too: the first runner to end deletes its own computers, never another runner's live ones. The live
9
+ * sweep's --after goes by RUN_LABEL alone, so it still takes every runner's leftovers.
10
+ */
11
+ export declare const RUNNER_LABEL = "agentrun.conformance.runner";
12
+ /** A run's id: 12 hex characters, minted by the run itself or by the live sweep's --before (sweep.ts) for the run it wraps. */
13
+ export declare const RUN_ID: RegExp;
14
+ export declare const newRunId: () => string;
15
+ /**
16
+ * Runs the cases against the provider and reports each one. Every computer carries the run's label and the runner's;
17
+ * each one a case makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is
18
+ * swept by both labels and they are listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
9
19
  * or is named in the cleanup, and a computer that arrives after its case ended is deleted when it arrives.
10
20
  */
11
21
  export declare function runConformance(provider: ComputerProvider, options: ConformanceOptions): Promise<ConformanceReport>;
@@ -13,6 +13,16 @@ import { kindCases, kindRunProblem, kindVerdict } from "./kind.js";
13
13
  import { caseOs, coreGroups, } from "./types.js";
14
14
  /** The label every computer of a run carries, with the run's id. */
15
15
  export const RUN_LABEL = "agentrun.conformance";
16
+ /**
17
+ * The label every computer of a run also carries, with an id minted by each runConformance call, never given. Several
18
+ * runners may share one run's id (two processes given one before file's --run), so the runner's own end-of-run sweeps
19
+ * go by this label too: the first runner to end deletes its own computers, never another runner's live ones. The live
20
+ * sweep's --after goes by RUN_LABEL alone, so it still takes every runner's leftovers.
21
+ */
22
+ export const RUNNER_LABEL = "agentrun.conformance.runner";
23
+ /** A run's id: 12 hex characters, minted by the run itself or by the live sweep's --before (sweep.ts) for the run it wraps. */
24
+ export const RUN_ID = /^[0-9a-f]{12}$/;
25
+ export const newRunId = () => randomBytes(6).toString("hex");
16
26
  /** The lifetime a run's computers ask for, at most the provider's own cap: a metered phone's cap is its hard stop. */
17
27
  const LIFETIME_MS = 30 * 60_000;
18
28
  const GROUP_NAMES = new Set(GROUPS);
@@ -78,9 +88,9 @@ function whenAborted(signal) {
78
88
  });
79
89
  }
80
90
  /**
81
- * Runs the cases against the provider and reports each one. Every computer carries the run's label; each one a case
82
- * makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is swept by the label
83
- * and the label is listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
91
+ * Runs the cases against the provider and reports each one. Every computer carries the run's label and the runner's;
92
+ * each one a case makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is
93
+ * swept by both labels and they are listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
84
94
  * or is named in the cleanup, and a computer that arrives after its case ended is deleted when it arrives.
85
95
  */
86
96
  export async function runConformance(provider, options) {
@@ -100,8 +110,14 @@ export async function runConformance(provider, options) {
100
110
  throw new TypeError(kindProblem);
101
111
  const fetcher = options.fetch ?? ((url, init) => fetch(url, init));
102
112
  const dialer = options.cdp ?? dialCdp;
103
- const run = randomBytes(6).toString("hex");
104
- const runLabels = { [RUN_LABEL]: run };
113
+ if (options.run !== undefined && !RUN_ID.test(options.run))
114
+ throw new TypeError(`options.run is a run id the live sweep's --before mints, 12 hex characters; got ${JSON.stringify(options.run)}`);
115
+ const run = options.run ?? newRunId();
116
+ // This runner's own id: its create requests are named by it, not by the run's, since a provider makes one computer
117
+ // per request name, and another runner given the same run must never find this one's.
118
+ const runner = newRunId();
119
+ // The cases list and attach by both, and the cleanup sweeps by both: this runner's computers alone.
120
+ const runLabels = { [RUN_LABEL]: run, [RUNNER_LABEL]: runner };
105
121
  const capabilities = provider.capabilities();
106
122
  // A provider of the shape before groups declares none, so its kind-consistent case fails in words, not the run.
107
123
  const groups = Array.isArray(capabilities.groups) ? capabilities.groups : [];
@@ -295,7 +311,7 @@ export async function runConformance(provider, options) {
295
311
  // after it is deleted as it lands (lateCreate).
296
312
  const stop = new AbortController();
297
313
  const both = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
298
- const requestId = `${run}/shared${++made > 1 ? `/${made}` : ""}`;
314
+ const requestId = `${runner}/shared${++made > 1 ? `/${made}` : ""}`;
299
315
  const creating = capped(requestId, "shared", both, () => provider.create(spec(), { signal: both, requestId }));
300
316
  let created;
301
317
  try {
@@ -459,7 +475,7 @@ export async function runConformance(provider, options) {
459
475
  * create through by, kept: what it gives is deleted when the case ends, or as it comes after that. A create with
460
476
  * planted secrets is outside the cap: it can't use the account, so it holds no room (one it makes anyway fails its case).
461
477
  */
462
- const attempt = (whole, by = provider, requestId = `${run}/${c.id}/${++creates}`) => {
478
+ const attempt = (whole, by = provider, requestId = `${runner}/${c.id}/${++creates}`) => {
463
479
  const make = () => by.create(whole, { signal: caseSignal, requestId });
464
480
  const creating = (plantedBy.has(by) ? make() : capped(requestId, c.id, caseSignal, make)).then((created) => {
465
481
  noteCreated(created, c.id);
@@ -531,7 +547,8 @@ export async function runConformance(provider, options) {
531
547
  return home.replace(/\/+$/, "") || "/";
532
548
  },
533
549
  async dir() {
534
- const path = `${await t.home()}/agentrun-conformance-${run}/${c.id.replace(/[^a-z0-9-]/gi, "-")}-${++dirs}`;
550
+ // The runner's id, not the run's: a computer whose home is a host's own may serve two runners of one run.
551
+ const path = `${await t.home()}/agentrun-conformance-${runner}/${c.id.replace(/[^a-z0-9-]/gi, "-")}-${++dirs}`;
535
552
  await t.call("files.mkdir", { path, parents: true });
536
553
  return path;
537
554
  },
@@ -735,7 +752,10 @@ export async function runConformance(provider, options) {
735
752
  report.kindVerdict = kindVerdict(kind, capabilities, report, selected);
736
753
  return report;
737
754
  }
738
- /** Sweeps a janitor provider by the run's label, past every deadline, and lists the label to show nothing is left. */
755
+ /**
756
+ * Sweeps a janitor provider by the runner's labels (RUN_LABEL and RUNNER_LABEL), past every deadline, and lists them to
757
+ * show nothing of its own is left: another runner given the same run keeps its computers.
758
+ */
739
759
  async function cleanup(provider, lifetime, labels, report, deleted, ms) {
740
760
  try {
741
761
  if (lifetime === "janitor") {
@@ -756,12 +776,13 @@ async function cleanup(provider, lifetime, labels, report, deleted, ms) {
756
776
  else
757
777
  report.cleanup.errors.push(`list ${JSON.stringify(labels)}: ${listed.error.code}: ${listed.error.message}`);
758
778
  // Nothing left behind, read from the vendor itself: a provider on the shared machine-host adapter is swept by the
759
- // run's label through its host, as the live sweep (sweep.ts) does, and every machine it finds must be gone.
779
+ // runner's labels through its host, as the live sweep (sweep.ts) does by the run's, and every machine it finds must
780
+ // be gone.
760
781
  const host = provider.host;
761
782
  if (host !== undefined && typeof host.list === "function") {
762
783
  const { sweepMachines } = await import("./sweep.js");
763
784
  const said = [];
764
- const swept = await within(sweepMachines(host, { labels, waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
785
+ const swept = await within(sweepMachines(host, { labels, run: labels[RUN_LABEL], waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
765
786
  report.cleanup.errors.push(...said.map((words) => `sweep: ${words}`));
766
787
  if (!swept.ok)
767
788
  report.cleanup.errors.push(`sweep: ${swept.error.code}: ${swept.error.message}`);
@@ -1,6 +1,6 @@
1
- import type { MachineHost } from "../host.js";
2
1
  import { type SmolcloudProvider, type SmolcloudProviderOptions } from "../smolcloud.js";
3
- /** The environment this module reads, by name, each for the option its comment names, the live switch and the run's image. */
2
+ import { type Env, type HostedModuleOptions } from "./module-kit.js";
3
+ export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
4
4
  export declare const SMOLCLOUD_ENV: {
5
5
  readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
6
6
  /** apiKey, required: the smol cloud API key. */
@@ -10,7 +10,6 @@ export declare const SMOLCLOUD_ENV: {
10
10
  /** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
11
11
  readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
12
12
  };
13
- /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
14
13
  export declare const ENV: {
15
14
  readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
16
15
  /** apiKey, required: the smol cloud API key. */
@@ -21,27 +20,12 @@ export declare const ENV: {
21
20
  readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
22
21
  };
23
22
  /** The provider's options this module reads from env; throws in words without the key, never echoing it. */
24
- export declare function settingsFromEnv(env?: Record<string, string | undefined>): Pick<SmolcloudProviderOptions, "apiKey" | "apiUrl">;
25
- /** The longest lifetime a computer of a run may ask for. */
26
- export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
27
- /** For the run's report: what this configuration means for the suite. */
23
+ export declare function settingsFromEnv(env?: Env): Pick<SmolcloudProviderOptions, "apiKey" | "apiUrl">;
28
24
  export declare const conformanceNotes: string[];
29
- export interface SmolcloudModuleOptions extends Pick<SmolcloudProviderOptions, "fetch" | "daemonPath" | "timeouts"> {
30
- /** Where the settings are read; default process.env. */
31
- env?: Record<string, string | undefined>;
32
- /** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
33
- buildDaemon?: (version: string) => Promise<string>;
25
+ export interface SmolcloudModuleOptions extends HostedModuleOptions, Pick<SmolcloudProviderOptions, "fetch" | "daemonPath" | "timeouts" | "onNote"> {
34
26
  }
35
- /** The provider the CLI runs; throws in words without the live switch or the key. */
36
- export declare function createProvider(options?: SmolcloudModuleOptions): Promise<SmolcloudProvider>;
37
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
38
- export declare function createDriftedProvider(options?: SmolcloudModuleOptions): Promise<SmolcloudProvider>;
27
+ export declare const createProvider: (options?: SmolcloudModuleOptions | undefined) => Promise<SmolcloudProvider>, createDriftedProvider: (options?: SmolcloudModuleOptions | undefined) => Promise<SmolcloudProvider>, createHost: (options?: SmolcloudModuleOptions | undefined) => Promise<import("../host.js").MachineHost>, sweepScope: (options?: {
28
+ env?: Env;
29
+ }) => string;
39
30
  /** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
40
31
  export declare function conformanceImage({ env }?: Pick<SmolcloudModuleOptions, "env">): Promise<string>;
41
- /**
42
- * The smol cloud host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
43
- * switch, since the sweep makes nothing, and it calls nothing until the sweep does.
44
- */
45
- export declare function createHost(options?: Pick<SmolcloudModuleOptions, "env" | "fetch">): Promise<MachineHost>;
46
- /** Where the sweep lists, in words: the key's account, the key named by its sha256 prefix alone. */
47
- export declare function sweepScope({ env }?: Pick<SmolcloudModuleOptions, "env">): string;
@@ -1,15 +1,12 @@
1
1
  // smol cloud for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider smolcloud`. It
2
2
  // makes real machines, which bill until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_SMOLCLOUD=1 and your own
3
- // key, under COMPUTER_SMOLCLOUD_API_KEY. The provider reads no environment: this module reads its own COMPUTER_SMOLCLOUD_*
4
- // names (never SMOLCLOUD_API_KEY, which may hold another account's key) and passes each to create() as its option. The
5
- // live sweep (sweep.ts, --provider smolcloud) reads the same names through createHost, which needs no live switch: it
6
- // makes nothing. Every computer of a run has a deadline of at most 30 minutes, and smol cloud's delete timer is set
7
- // 5 minutes past it.
8
- import { createHash } from "node:crypto";
3
+ // key, under COMPUTER_SMOLCLOUD_API_KEY (never SMOLCLOUD_API_KEY, which may hold another account's key). Every computer
4
+ // of a run has a deadline of at most 30 minutes, and smol cloud's delete timer is set 5 minutes past it.
9
5
  import { boxImageRef } from "../box-image.js";
6
+ import { httpsBase } from "../hosted/rest.js";
10
7
  import { create } from "../smolcloud.js";
11
- import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
12
- /** The environment this module reads, by name, each for the option its comment names, the live switch and the run's image. */
8
+ import { hostedModule, keyPrint, requiredSecret, setOptions } from "./module-kit.js";
9
+ export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
13
10
  export const SMOLCLOUD_ENV = {
14
11
  live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD",
15
12
  /** apiKey, required: the smol cloud API key. */
@@ -19,55 +16,25 @@ export const SMOLCLOUD_ENV = {
19
16
  /** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
20
17
  image: "COMPUTER_SMOLCLOUD_IMAGE",
21
18
  };
22
- /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
23
19
  export const ENV = SMOLCLOUD_ENV;
24
20
  /** The provider's options this module reads from env; throws in words without the key, never echoing it. */
25
21
  export function settingsFromEnv(env = process.env) {
26
- const apiKey = env[SMOLCLOUD_ENV.key];
27
- if (apiKey === undefined || apiKey === "")
28
- throw new Error(`set ${SMOLCLOUD_ENV.key} to a smol cloud API key: the conformance module reads it there and nowhere else, never from SMOLCLOUD_API_KEY`);
29
- const apiUrl = env[SMOLCLOUD_ENV.apiUrl] || undefined;
30
- return { apiKey, ...(apiUrl === undefined ? {} : { apiUrl }) };
22
+ const apiKey = requiredSecret(env, SMOLCLOUD_ENV.key, "a smol cloud API key");
23
+ return { apiKey, ...setOptions(env, { apiUrl: SMOLCLOUD_ENV.apiUrl }) };
31
24
  }
32
- /** The longest lifetime a computer of a run may ask for. */
33
- export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
34
- /** For the run's report: what this configuration means for the suite. */
35
25
  export const conformanceNotes = [
36
26
  "smolcloud: every computer is a smol cloud machine (a microVM on an amd64 node) with its idle stop off and its delete timer at the adapter's backstop; the daemon is a child of a resumable interactive exec, its stdio the exec's long-polled output and numbered stdin frames; lifetime is the janitor's, by the deadline label, capped at 30 minutes for the run. Network none, open and a list are init's. No mount (smol cloud binds its storage disk at /workspace) and no desktop.",
37
27
  ];
38
- function live(env) {
39
- if (env[SMOLCLOUD_ENV.live] !== "1")
40
- throw new Error(`the smol cloud conformance module makes real machines, which bill until deleted: set ${SMOLCLOUD_ENV.live}=1, with your own key, to run it`);
41
- }
42
- /** The test doubles a caller hands in, each only when given. */
43
- const doubles = ({ fetch, daemonPath, timeouts }) => ({ ...(fetch ? { fetch } : {}), ...(daemonPath ? { daemonPath } : {}), ...(timeouts ? { timeouts } : {}) });
44
- /** The provider the CLI runs; throws in words without the live switch or the key. */
45
- export async function createProvider(options = {}) {
46
- const { env = process.env } = options;
47
- live(env);
48
- return create({ ...settingsFromEnv(env), ...doubles(options), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
49
- }
50
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
51
- export async function createDriftedProvider(options = {}) {
52
- const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
53
- live(env);
54
- const settings = settingsFromEnv(env);
55
- return create({ ...settings, ...doubles(options), daemonPath: await buildDaemon(DRIFT_VERSION), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
56
- }
28
+ export const { createProvider, createDriftedProvider, createHost, sweepScope } = hostedModule({
29
+ live: { name: SMOLCLOUD_ENV.live, what: "the smol cloud conformance module makes real machines, which bill until deleted", whose: "your own key" },
30
+ settingsFromEnv,
31
+ create,
32
+ host: ["fetch", "daemonPath", "timeouts"],
33
+ run: ["onNote"],
34
+ // The key's account, the key named by its sha256 prefix alone.
35
+ scope: ({ apiKey, apiUrl }) => `the smol cloud account of the key ${keyPrint(apiKey)} at ${httpsBase(apiUrl ?? "https://api.smolmachines.com", `the smol cloud API URL (${SMOLCLOUD_ENV.apiUrl})`)}`,
36
+ });
57
37
  /** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
58
38
  export async function conformanceImage({ env = process.env } = {}) {
59
39
  return env[SMOLCLOUD_ENV.image] || boxImageRef();
60
40
  }
61
- /**
62
- * The smol cloud host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
63
- * switch, since the sweep makes nothing, and it calls nothing until the sweep does.
64
- */
65
- export async function createHost(options = {}) {
66
- return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
67
- }
68
- /** Where the sweep lists, in words: the key's account, the key named by its sha256 prefix alone. */
69
- export function sweepScope({ env = process.env } = {}) {
70
- const { apiKey, apiUrl } = settingsFromEnv(env);
71
- const key = createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12);
72
- return `the smol cloud account of the key sha256:${key} at ${apiUrl ?? "https://api.smolmachines.com"}`;
73
- }