@parcha/agentrun-computer 0.1.0-beta.45 → 0.1.0-beta.47

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 (50) hide show
  1. package/README.md +75 -7
  2. package/dist/attach.d.ts +23 -5
  3. package/dist/attach.js +83 -20
  4. package/dist/computerd-linux-amd64 +0 -0
  5. package/dist/computerd-linux-arm64 +0 -0
  6. package/dist/computerd.json +2 -2
  7. package/dist/conformance/agent37.js +2 -2
  8. package/dist/conformance/boxd.js +2 -3
  9. package/dist/conformance/cli.js +1 -1
  10. package/dist/conformance/cloudflare.d.ts +2 -0
  11. package/dist/conformance/cloudflare.js +4 -0
  12. package/dist/conformance/e2b.js +2 -3
  13. package/dist/conformance/fixture.js +1 -1
  14. package/dist/conformance/fly.d.ts +4 -0
  15. package/dist/conformance/fly.js +4 -0
  16. package/dist/conformance/kind.d.ts +8 -1
  17. package/dist/conformance/kind.js +6 -1
  18. package/dist/conformance/modal.d.ts +4 -0
  19. package/dist/conformance/modal.js +5 -1
  20. package/dist/conformance/smolcloud.d.ts +47 -0
  21. package/dist/conformance/smolcloud.js +73 -0
  22. package/dist/conformance/sweep.js +1 -1
  23. package/dist/conformance/types.d.ts +2 -1
  24. package/dist/daytona.d.ts +1 -1
  25. package/dist/daytona.js +5 -6
  26. package/dist/descriptor.d.ts +22 -3
  27. package/dist/descriptor.js +31 -2
  28. package/dist/descriptors/cloudflare.js +1 -1
  29. package/dist/descriptors/daytona.d.ts +5 -13
  30. package/dist/descriptors/daytona.js +6 -6
  31. package/dist/descriptors/fly.js +1 -1
  32. package/dist/descriptors/index.d.ts +22 -14
  33. package/dist/descriptors/index.js +3 -2
  34. package/dist/descriptors/smolcloud.d.ts +18 -0
  35. package/dist/descriptors/smolcloud.js +21 -0
  36. package/dist/hosted/provider.js +12 -28
  37. package/dist/hosted/rest.d.ts +2 -0
  38. package/dist/hosted/rest.js +1 -1
  39. package/dist/hosted/values.d.ts +0 -2
  40. package/dist/hosted/values.js +0 -2
  41. package/dist/index.d.ts +3 -2
  42. package/dist/index.js +4 -3
  43. package/dist/kinds.d.ts +11 -71
  44. package/dist/kinds.js +2 -9
  45. package/dist/modal.js +5 -4
  46. package/dist/setting-kinds.d.ts +19 -0
  47. package/dist/setting-kinds.js +9 -0
  48. package/dist/smolcloud.d.ts +21 -0
  49. package/dist/smolcloud.js +254 -0
  50. package/package.json +7 -2
@@ -18,6 +18,8 @@ export declare const MODAL_ENV: {
18
18
  readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
19
19
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
20
20
  readonly connect: "COMPUTER_MODAL_CONNECT";
21
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
22
+ readonly kind: "COMPUTER_MODAL_KIND";
21
23
  };
22
24
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
23
25
  export declare const ENV: {
@@ -31,6 +33,8 @@ export declare const ENV: {
31
33
  readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
32
34
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
33
35
  readonly connect: "COMPUTER_MODAL_CONNECT";
36
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
37
+ readonly kind: "COMPUTER_MODAL_KIND";
34
38
  };
35
39
  /** What this module reads from the environment: the token, the app, and the server when set. */
36
40
  export type ModalSettings = Pick<ModalCreateOptions, "tokenId" | "tokenSecret" | "app" | "serverUrl" | "connect">;
@@ -21,6 +21,7 @@ import { create, MODAL_DEFAULT_SERVER_URL } from "../modal.js";
21
21
  import { archilRunFolder, archilSettings } from "./archil.js";
22
22
  import { dialOnlyFromServer } from "./dial-only.js";
23
23
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
24
+ import { kindFrom } from "./kind.js";
24
25
  /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
25
26
  export { ARCHIL_ENV } from "./archil.js";
26
27
  /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
@@ -35,6 +36,8 @@ export const MODAL_ENV = {
35
36
  serverUrl: "COMPUTER_MODAL_SERVER_URL",
36
37
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
37
38
  connect: "COMPUTER_MODAL_CONNECT",
39
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
40
+ kind: "COMPUTER_MODAL_KIND",
38
41
  };
39
42
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
40
43
  export const ENV = MODAL_ENV;
@@ -69,7 +72,8 @@ function live(env) {
69
72
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
70
73
  export async function createProvider({ env = process.env, ModalClient, daemonPath, onNote, dial } = {}) {
71
74
  live(env);
72
- return create({ ...settingsFromEnv(env), ...(daemonPath === undefined ? {} : { daemonPath }), ...(ModalClient ? { ModalClient } : {}), ...(onNote ? { onNote } : {}), ...(dial ? { dial } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
75
+ // create() refuses desktop without dial in words.
76
+ return create({ ...settingsFromEnv(env), ...kindFrom(env, MODAL_ENV.kind), ...(daemonPath === undefined ? {} : { daemonPath }), ...(ModalClient ? { ModalClient } : {}), ...(onNote ? { onNote } : {}), ...(dial ? { dial } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
73
77
  }
74
78
  /**
75
79
  * The image every computer of the run starts from: on dial the box image, since only it holds agentrun-dial; on exec
@@ -0,0 +1,47 @@
1
+ import type { MachineHost } from "../host.js";
2
+ 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. */
4
+ export declare const SMOLCLOUD_ENV: {
5
+ readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
6
+ /** apiKey, required: the smol cloud API key. */
7
+ readonly key: "COMPUTER_SMOLCLOUD_API_KEY";
8
+ /** apiUrl: the REST API; default https://api.smolmachines.com. */
9
+ readonly apiUrl: "COMPUTER_SMOLCLOUD_API_URL";
10
+ /** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
11
+ readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
12
+ };
13
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
14
+ export declare const ENV: {
15
+ readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
16
+ /** apiKey, required: the smol cloud API key. */
17
+ readonly key: "COMPUTER_SMOLCLOUD_API_KEY";
18
+ /** apiUrl: the REST API; default https://api.smolmachines.com. */
19
+ readonly apiUrl: "COMPUTER_SMOLCLOUD_API_URL";
20
+ /** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
21
+ readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
22
+ };
23
+ /** 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. */
28
+ 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>;
34
+ }
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>;
39
+ /** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
40
+ 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;
@@ -0,0 +1,73 @@
1
+ // smol cloud for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider smolcloud`. It
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";
9
+ import { boxImageRef } from "../box-image.js";
10
+ 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. */
13
+ export const SMOLCLOUD_ENV = {
14
+ live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD",
15
+ /** apiKey, required: the smol cloud API key. */
16
+ key: "COMPUTER_SMOLCLOUD_API_KEY",
17
+ /** apiUrl: the REST API; default https://api.smolmachines.com. */
18
+ apiUrl: "COMPUTER_SMOLCLOUD_API_URL",
19
+ /** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
20
+ image: "COMPUTER_SMOLCLOUD_IMAGE",
21
+ };
22
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
23
+ export const ENV = SMOLCLOUD_ENV;
24
+ /** The provider's options this module reads from env; throws in words without the key, never echoing it. */
25
+ 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 }) };
31
+ }
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
+ export const conformanceNotes = [
36
+ "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
+ ];
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
+ }
57
+ /** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
58
+ export async function conformanceImage({ env = process.env } = {}) {
59
+ return env[SMOLCLOUD_ENV.image] || boxImageRef();
60
+ }
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
+ }
@@ -56,7 +56,7 @@ export async function sweepMachines(host, { labels = {}, before = new Set(), wai
56
56
  return ok({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere, leftAlone });
57
57
  }
58
58
  const USAGE = `usage: node packages/computer/dist/conformance/sweep.js --provider <id> --before <file> | --after <file>
59
- --provider <id> a provider on the shared machine-host adapter (e2b, agent37, morph, daytona, boxd)
59
+ --provider <id> a provider on the shared machine-host adapter (e2b, agent37, morph, daytona, boxd, smolcloud)
60
60
  --before <file> record the id of every machine the vendor lists with ${COMPUTER_LABEL}=1 into <file>
61
61
  --after <file> delete every machine listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
62
62
  each back until the vendor no longer has it (up to 60 s each), and print
@@ -2,7 +2,8 @@ import type { MountKind, MountSpec } from "../mount.js";
2
2
  import type { ComputerClient, ComputerKind, ComputerOs, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
3
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, KindCapabilities } from "../kinds.js";
5
+ import type { KindCapabilities } from "../kinds.js";
6
+ import type { ComputerSettingKind } from "../setting-kinds.js";
6
7
  import type { CdpDialer, CdpSocket } from "./cdp.js";
7
8
  import type { StartedFixture } from "./fixture.js";
8
9
  import type { KindVerdict } from "./kind.js";
package/dist/daytona.d.ts CHANGED
@@ -19,7 +19,7 @@ export type DaytonaTimeouts = HostedTimeouts & {
19
19
  };
20
20
  /**
21
21
  * The Daytona provider's options: the key and Daytona's own settings, then the shared adapter's (HostedOptions), kind
22
- * among them: a desktop on connect dial alone.
22
+ * among them: linux alone, kind desktop refused in its descriptor's unserved words (kindRefusal).
23
23
  */
24
24
  export interface DaytonaProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs" | "timeouts"> {
25
25
  /** The Daytona API key. The caller passes it; this provider never reads the environment and never puts it in a computer. */
package/dist/daytona.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // the computer is the shared machine-host adapter's (./hosted/provider.ts). Every Daytona fact used here is cited in the
8
8
  // README's Daytona section.
9
9
  import { randomBytes } from "node:crypto";
10
- import { connectOf, mountsOf } from "./descriptor.js";
10
+ import { connectOf, kindRefusal, mountsOf } from "./descriptor.js";
11
11
  import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
12
12
  import { COMPUTER_LABEL } from "./drift.js";
13
13
  import { HostError } from "./host.js";
@@ -16,7 +16,7 @@ import { HostedProvider, timeoutsOf } from "./hosted/provider.js";
16
16
  import { boundOf, orThrow, pause as sleep } from "./hosted/process.js";
17
17
  import { allPages, jsonOf, rest } from "./hosted/rest.js";
18
18
  import { shellLine } from "./hosted/scripts.js";
19
- import { dateOf, execDesktopRefusal, isWhole, sizeRefusals } from "./hosted/values.js";
19
+ import { dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
20
20
  import { MAX_LINE_BYTES } from "./protocol.js";
21
21
  import { checkGpu } from "./provider.js";
22
22
  import { ok, vendorFail } from "./result.js";
@@ -142,8 +142,6 @@ class DaytonaHost {
142
142
  maxLifetimeMs: MAX_LIFETIME_MS,
143
143
  arch: options.arch,
144
144
  vendorAgentPorts: [TOOLBOX_PORT],
145
- // A snapshot of box/Dockerfile has xfwm4 (box/install.sh's desktop step), for a desktop (connect dial alone).
146
- windowManager: true,
147
145
  ...(options.connect === "dial" ? { connect: options.connect } : {}),
148
146
  };
149
147
  if (options.connect === "exec") {
@@ -515,8 +513,9 @@ export class DaytonaProvider extends HostedProvider {
515
513
  constructor(options) {
516
514
  const { apiKey, apiUrl = DEFAULT_API_URL, arch = "amd64", sandboxClass = "container", target, gpuSnapshot, autoStopMinutes = 0, autoDeleteMinutes, connect, fetch: fetcher, webSocket, pause, timeouts = {}, ...hosted } = options ?? {};
517
515
  const via = connectOf(DAYTONA, { connect });
518
- if (hosted.kind === "desktop" && via === "exec")
519
- throw new Error(execDesktopRefusal("Daytona", "a snapshot of box/Dockerfile"));
516
+ const refused = kindRefusal(DAYTONA, { kind: hosted.kind, connect: via });
517
+ if (refused !== undefined)
518
+ throw new Error(refused);
520
519
  if (typeof apiKey !== "string" || apiKey === "")
521
520
  throw new Error("options.apiKey, the Daytona API key, is required: the provider reads no environment, so the caller passes it");
522
521
  const base = new URL(apiUrl);
@@ -1,7 +1,8 @@
1
- import type { ComputerSettingKind, KindCapabilities } from "./kinds.js";
1
+ import type { KindCapabilities } from "./kinds.js";
2
2
  import type { MountKind, Unmounted } from "./mount.js";
3
3
  import type { NetworkForm } from "./provider.js";
4
4
  import type { ProviderModule } from "./providers.js";
5
+ import { type ComputerSettingKind } from "./setting-kinds.js";
5
6
  /** One key a provider takes in Settings: its serve-side name, the create() option it fills, and whether it is needed. */
6
7
  export interface DescriptorKey {
7
8
  /** The name Settings stores it under and shows (DAYTONA_API_KEY); never a value. */
@@ -90,6 +91,12 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
90
91
  * options that build it (KindCapabilities).
91
92
  */
92
93
  readonly capabilities: readonly KindCapabilities[];
94
+ /**
95
+ * Setting kinds its capabilities don't serve though a caller would ask it for one, each with why, in words: serve
96
+ * refuses a setting of that kind on it with these words in place of servingRefusals' (Daytona's desktop: the window
97
+ * manager can't start in its sandboxes).
98
+ */
99
+ readonly unserved?: Readonly<Partial<Record<ComputerSettingKind, string>>>;
93
100
  /**
94
101
  * The image a computer of each setting kind starts from when its setting names none. A kind with no entry has no
95
102
  * default, and the caller refuses the setting in words (Docker's sandbox: the server builds its image, prepareImage).
@@ -159,6 +166,17 @@ export declare function descriptorProblems(value: unknown): string[];
159
166
  export declare function connectOf(descriptor: Pick<ProviderDescriptor, "label" | "connect">, options?: {
160
167
  readonly connect?: unknown;
161
168
  }): "exec" | "dial";
169
+ /**
170
+ * Why a provider made for machine kind `kind` over `connect` (connectOf's answer) gives no such computer, by its
171
+ * descriptor alone; undefined when it gives one, or `kind` is none of its configurations' (create() judges that). Its
172
+ * unserved words for the setting kind `kind` is: "<label> gives no <kind> computer: <why>". Else, where each configuration
173
+ * of `kind` names a connect of its own in its options and none is `connect`: the connect that makes one. A provider's
174
+ * constructor throws these words, so a kind rule is said once, in the descriptor.
175
+ */
176
+ export declare function kindRefusal(descriptor: Pick<ProviderDescriptor, "label" | "capabilities" | "unserved">, { kind, connect }: {
177
+ readonly kind?: string;
178
+ readonly connect: "exec" | "dial";
179
+ }): string | undefined;
162
180
  /**
163
181
  * Whether a configuration takes a synced folder: its groups have exec and files (all the runner reads and writes the
164
182
  * folder through), and its descriptor binds no host folder (a bind is the folder itself) nor says why it takes none
@@ -171,9 +189,10 @@ export declare function derivedMounts(descriptor: Pick<ProviderDescriptor, "moun
171
189
  * The mount kinds a provider's computers take, and why not the others, with the keys `set` says the operator has set: its
172
190
  * derived mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with
173
191
  * those keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's
174
- * folder.
192
+ * folder. With `dial`, its machines dial the server (connectOf's "dial"), and it takes no Archil mount: the helper's
193
+ * steps run as root through exec, which a machine that dials has none of.
175
194
  */
176
- export declare function mountsOf(descriptor: Pick<ProviderDescriptor, "mounts" | "unmounted" | "mountsWith" | "capabilities">, set: (name: string) => boolean): {
195
+ export declare function mountsOf(descriptor: Pick<ProviderDescriptor, "label" | "mounts" | "unmounted" | "mountsWith" | "capabilities">, set: (name: string) => boolean, dial?: boolean): {
177
196
  mounts: MountKind[];
178
197
  unmounted: Unmounted;
179
198
  };
@@ -1,3 +1,4 @@
1
+ import { SETTING_KIND_NAMES, SETTING_KINDS } from "./setting-kinds.js";
1
2
  const ID = /^[a-z0-9][a-z0-9-]*$/;
2
3
  /**
3
4
  * A descriptor, checked: its id's shape, its keys' and settings' names and options unique and non-empty, and one
@@ -10,6 +11,8 @@ export function defineProvider(descriptor) {
10
11
  throw new Error(`the provider descriptor ${JSON.stringify(descriptor?.id)}: ${problems.join("; ")}`);
11
12
  return descriptor;
12
13
  }
14
+ /** The setting kinds a descriptor's unserved may name: every one but none. */
15
+ const UNSERVABLE = SETTING_KIND_NAMES.filter((kind) => kind !== "none");
13
16
  /** What is wrong with a value offered as a descriptor, in words; none when it is one. */
14
17
  export function descriptorProblems(value) {
15
18
  if (typeof value !== "object" || value === null)
@@ -41,6 +44,8 @@ export function descriptorProblems(value) {
41
44
  else if (entries.some(([kind]) => typeof d.unmounted?.[kind] !== "string"))
42
45
  problems.push("each kind of mountsWith is in unmounted too, with why while its key is unset");
43
46
  }
47
+ if (d.unserved !== undefined && (typeof d.unserved !== "object" || d.unserved === null || Array.isArray(d.unserved) || Object.entries(d.unserved).some(([kind, why]) => !UNSERVABLE.includes(kind) || typeof why !== "string" || why.trim() === "")))
48
+ problems.push(`unserved maps setting kinds (${UNSERVABLE.join(", ")}) to why, in words`);
44
49
  if (!Array.isArray(d.network) || d.network.length === 0 || d.network.some((form) => form !== "none" && form !== "open" && form !== "allow"))
45
50
  problems.push("network is not a list of the network forms its computers make (none, open, allow)");
46
51
  if (!Array.isArray(d.capabilities) || d.capabilities.length === 0)
@@ -126,6 +131,25 @@ export function connectOf(descriptor, options = {}) {
126
131
  return connect ?? "exec";
127
132
  throw new Error(`connect is how ${descriptor.label} reaches its machines, "exec" (the default) or "dial", not ${JSON.stringify(connect)}`);
128
133
  }
134
+ /**
135
+ * Why a provider made for machine kind `kind` over `connect` (connectOf's answer) gives no such computer, by its
136
+ * descriptor alone; undefined when it gives one, or `kind` is none of its configurations' (create() judges that). Its
137
+ * unserved words for the setting kind `kind` is: "<label> gives no <kind> computer: <why>". Else, where each configuration
138
+ * of `kind` names a connect of its own in its options and none is `connect`: the connect that makes one. A provider's
139
+ * constructor throws these words, so a kind rule is said once, in the descriptor.
140
+ */
141
+ export function kindRefusal(descriptor, { kind, connect }) {
142
+ if (kind === undefined)
143
+ return undefined;
144
+ const setting = SETTING_KIND_NAMES.find((name) => SETTING_KINDS[name].machineKinds.includes(kind));
145
+ const why = setting === undefined ? undefined : descriptor.unserved?.[setting];
146
+ if (why !== undefined)
147
+ return `${descriptor.label} gives no ${setting} computer: ${why}`;
148
+ const connects = descriptor.capabilities.filter((one) => one.kind === kind).map((one) => one.options?.connect);
149
+ if (connects.length === 0 || connects.some((one) => one === undefined || one === connect))
150
+ return undefined;
151
+ return `${descriptor.label} gives a ${kind} computer on connect ${[...new Set(connects)].map((one) => JSON.stringify(one)).join(" or ")} alone, not ${JSON.stringify(connect)}`;
152
+ }
129
153
  /**
130
154
  * Whether a configuration takes a synced folder: its groups have exec and files (all the runner reads and writes the
131
155
  * folder through), and its descriptor binds no host folder (a bind is the folder itself) nor says why it takes none
@@ -143,11 +167,16 @@ export function derivedMounts(descriptor) {
143
167
  * The mount kinds a provider's computers take, and why not the others, with the keys `set` says the operator has set: its
144
168
  * derived mounts, and each kind of its mountsWith whose key is set, which leaves its unmounted. What a provider made with
145
169
  * those keys declares (capabilities().mount), and what a server reads to know whether that provider can mount a run's
146
- * folder.
170
+ * folder. With `dial`, its machines dial the server (connectOf's "dial"), and it takes no Archil mount: the helper's
171
+ * steps run as root through exec, which a machine that dials has none of.
147
172
  */
148
- export function mountsOf(descriptor, set) {
173
+ export function mountsOf(descriptor, set, dial = false) {
149
174
  const taken = Object.entries(descriptor.mountsWith ?? {}).flatMap(([kind, key]) => (typeof key === "string" && set(key) ? [kind] : []));
150
175
  const unmounted = Object.fromEntries(Object.entries(descriptor.unmounted ?? {}).filter(([kind]) => !taken.includes(kind)));
151
176
  const mounts = [...descriptor.mounts, ...taken.filter((kind) => !descriptor.mounts.includes(kind))];
177
+ if (dial) {
178
+ const archil = `${descriptor.label}'s machines dial this server, and a machine that dials takes no Archil mount`;
179
+ return { mounts: derivedMounts({ ...descriptor, mounts: mounts.filter((kind) => kind !== "archil") }), unmounted: { ...unmounted, archil } };
180
+ }
152
181
  return { mounts: derivedMounts({ ...descriptor, mounts }), unmounted };
153
182
  }
@@ -17,7 +17,7 @@ export const CLOUDFLARE = defineProvider({
17
17
  metered: true,
18
18
  // Its containers dial the server: Cloudflare has no REST call that reaches into one.
19
19
  connect: "dial",
20
- // None: a machine that dials takes no Archil mount yet (its helper's root steps run through exec, which it has none of).
20
+ // None: a machine that dials takes no Archil mount (mountsOf).
21
21
  mounts: [],
22
22
  // None: its programs run in init's network of their own, their loopback alone (isolation.ts). Open and a list: their
23
23
  // one way out is init's egress proxy (hosted/network.ts). The container itself always reaches out (enableInternet): it
@@ -1,4 +1,6 @@
1
1
  import type { GpuCapability } from "../provider.js";
2
+ /** Why Daytona gives no desktop (measured 11-19): PROVIDERS.md, Machines that dial in. The descriptor's unserved desktop. */
3
+ export declare const DAYTONA_NO_DESKTOP = "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
2
4
  /** The key that turns on a Daytona computer's Archil mount: the operator's Archil egress relay (archilEgress). */
3
5
  export declare const DAYTONA_ARCHIL_EGRESS = "DAYTONA_ARCHIL_EGRESS";
4
6
  /** Why a Daytona computer made with no Archil egress takes no Archil mount: check() refuses one in these words. */
@@ -89,20 +91,10 @@ export declare const DAYTONA: {
89
91
  };
90
92
  readonly image?: string;
91
93
  readonly options?: Readonly<Record<string, unknown>>;
92
- }, {
93
- readonly options: {
94
- readonly kind: "desktop";
95
- readonly connect: "dial";
96
- };
97
- readonly kind: import("../protocol.js").ComputerKind;
98
- readonly groups: import("../protocol.js").Group[];
99
- readonly gpu?: GpuCapability;
100
- readonly persistence?: {
101
- keepsState: true;
102
- resume: boolean;
103
- };
104
- readonly image?: string;
105
94
  }];
95
+ readonly unserved: {
96
+ readonly desktop: "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
97
+ };
106
98
  readonly defaultImage: {
107
99
  readonly sandbox: "default";
108
100
  };
@@ -1,7 +1,9 @@
1
1
  // Daytona's descriptor: a sandbox on Daytona's cloud, with GPUs when asked; the run's folder on an Archil disk only where
2
2
  // the operator gives an Archil egress relay (a self-hosted Daytona target), never on Daytona's hosted cloud.
3
3
  import { defineProvider } from "../descriptor.js";
4
- import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
4
+ import { SANDBOX } from "./shared.js";
5
+ /** Why Daytona gives no desktop (measured 11-19): PROVIDERS.md, Machines that dial in. The descriptor's unserved desktop. */
6
+ export const DAYTONA_NO_DESKTOP = "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
5
7
  /** The key that turns on a Daytona computer's Archil mount: the operator's Archil egress relay (archilEgress). */
6
8
  export const DAYTONA_ARCHIL_EGRESS = "DAYTONA_ARCHIL_EGRESS";
7
9
  /** Why a Daytona computer made with no Archil egress takes no Archil mount: check() refuses one in these words. */
@@ -90,11 +92,9 @@ export const DAYTONA = defineProvider({
90
92
  // its programs' one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts
91
93
  // alone (hosted/network.ts).
92
94
  network: ["none", "open", "allow"],
93
- // A linux computer, with GPUs when asked; or, on connect dial alone, a desktop with none: a snapshot of box/Dockerfile's
94
- // X server and xfwm4, started through computerd over the socket the sandbox dialed, at the snapshot's 2 CPUs and 4 GiB
95
- // (box/build-daytona.py). The desktop's configuration selects dial itself, whatever daytonaConnect says: a provider on
96
- // connect exec refuses kind desktop when it is made.
97
- capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }, { ...LINUX_DESKTOP, options: { kind: "desktop", connect: "dial" } }],
95
+ // A linux computer, with GPUs when asked. No desktop, on any connect (DAYTONA_NO_DESKTOP).
96
+ capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
97
+ unserved: { desktop: DAYTONA_NO_DESKTOP },
98
98
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
99
99
  // The operator's own snapshot for every Daytona computer, named here; the default snapshot stands while unset. A
100
100
  // computer with an Archil mount needs a snapshot of box/Dockerfile (box/build-daytona.py prints its name).
@@ -16,7 +16,7 @@ export const FLY = defineProvider({
16
16
  metered: true,
17
17
  // Its machines dial the server: Fly's exec answers only once the command ends, so nothing reaches into one.
18
18
  connect: "dial",
19
- // None: a machine that dials takes no Archil mount yet (its helper's root steps run through exec, which it has none of).
19
+ // None: a machine that dials takes no Archil mount (mountsOf).
20
20
  mounts: [],
21
21
  // None: its programs run in init's network of their own, their loopback alone (isolation.ts). Open and a list: their
22
22
  // one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts alone
@@ -12,6 +12,7 @@ import { MODAL } from "./modal.js";
12
12
  import { MORPH } from "./morph.js";
13
13
  import { ORGO } from "./orgo.js";
14
14
  import { PHONE_HARNESS } from "./phone-harness.js";
15
+ import { SMOLCLOUD } from "./smolcloud.js";
15
16
  export declare const DESCRIPTORS: readonly [{
16
17
  readonly id: "docker";
17
18
  readonly label: "Docker";
@@ -79,20 +80,10 @@ export declare const DESCRIPTORS: readonly [{
79
80
  };
80
81
  readonly image?: string;
81
82
  readonly options?: Readonly<Record<string, unknown>>;
82
- }, {
83
- readonly options: {
84
- readonly kind: "desktop";
85
- readonly connect: "dial";
86
- };
87
- readonly kind: import("../protocol.js").ComputerKind;
88
- readonly groups: import("../protocol.js").Group[];
89
- readonly gpu?: import("../provider.js").GpuCapability;
90
- readonly persistence?: {
91
- keepsState: true;
92
- resume: boolean;
93
- };
94
- readonly image?: string;
95
83
  }];
84
+ readonly unserved: {
85
+ readonly desktop: "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
86
+ };
96
87
  readonly defaultImage: {
97
88
  readonly sandbox: "default";
98
89
  };
@@ -464,8 +455,25 @@ export declare const DESCRIPTORS: readonly [{
464
455
  };
465
456
  readonly prepareImage: true;
466
457
  readonly load: () => Promise<typeof import("../boxd.js")>;
458
+ }, {
459
+ readonly id: "smolcloud";
460
+ readonly label: "smol cloud";
461
+ readonly keys: readonly [{
462
+ readonly name: "SMOLCLOUD_API_KEY";
463
+ readonly option: "apiKey";
464
+ readonly required: true;
465
+ }];
466
+ readonly metered: true;
467
+ readonly mounts: readonly [];
468
+ readonly unmounted: {
469
+ readonly sync: "smol cloud binds each machine's own storage disk at /workspace, and a synced folder can be held only where nothing is mounted there";
470
+ };
471
+ readonly network: readonly ["none", "open", "allow"];
472
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
473
+ readonly prepareImage: true;
474
+ readonly load: () => Promise<typeof import("../smolcloud.js")>;
467
475
  }];
468
- export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS };
476
+ export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
469
477
  export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
470
478
  export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
471
479
  export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
@@ -14,8 +14,9 @@ import { MODAL } from "./modal.js";
14
14
  import { MORPH } from "./morph.js";
15
15
  import { ORGO } from "./orgo.js";
16
16
  import { PHONE_HARNESS } from "./phone-harness.js";
17
- export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD];
18
- export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS };
17
+ import { SMOLCLOUD } from "./smolcloud.js";
18
+ export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD, SMOLCLOUD];
19
+ export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
19
20
  export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
20
21
  export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
21
22
  export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
@@ -0,0 +1,18 @@
1
+ export declare const SMOLCLOUD: {
2
+ readonly id: "smolcloud";
3
+ readonly label: "smol cloud";
4
+ readonly keys: readonly [{
5
+ readonly name: "SMOLCLOUD_API_KEY";
6
+ readonly option: "apiKey";
7
+ readonly required: true;
8
+ }];
9
+ readonly metered: true;
10
+ readonly mounts: readonly [];
11
+ readonly unmounted: {
12
+ readonly sync: "smol cloud binds each machine's own storage disk at /workspace, and a synced folder can be held only where nothing is mounted there";
13
+ };
14
+ readonly network: readonly ["none", "open", "allow"];
15
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
16
+ readonly prepareImage: true;
17
+ readonly load: () => Promise<typeof import("../smolcloud.js")>;
18
+ };
@@ -0,0 +1,21 @@
1
+ // smol cloud's descriptor: a Linux sandbox on a smol cloud machine (a microVM booted from an OCI image), started from
2
+ // our box image, the public registry tag its prepareImage() answers (box-image.ts), which smol cloud pulls at create. No
3
+ // mount yet: smol cloud binds the machine's own storage disk at /workspace, and the adapter holds a synced folder only
4
+ // where nothing is mounted there, so the run's folder can't be a synced folder on smol cloud.
5
+ import { defineProvider } from "../descriptor.js";
6
+ import { SANDBOX } from "./shared.js";
7
+ export const SMOLCLOUD = defineProvider({
8
+ id: "smolcloud",
9
+ label: "smol cloud",
10
+ keys: [{ name: "SMOLCLOUD_API_KEY", option: "apiKey", required: true }],
11
+ metered: true,
12
+ mounts: [],
13
+ unmounted: { sync: "smol cloud binds each machine's own storage disk at /workspace, and a synced folder can be held only where nothing is mounted there" },
14
+ // All three are ours: root in the guest makes a network namespace, so init's fence holds none and its egress proxy
15
+ // open and a list (hosted/network.ts).
16
+ network: ["none", "open", "allow"],
17
+ capabilities: [SANDBOX],
18
+ // No default image: every computer starts from the box image its prepareImage() answers, unless its spec names one.
19
+ prepareImage: true,
20
+ load: () => import("../smolcloud.js"),
21
+ });