@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.38

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 (155) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +547 -478
  3. package/box/Dockerfile +18 -1
  4. package/box/README.md +13 -0
  5. package/box/build-agent37.mjs +158 -0
  6. package/box/build-daytona.py +2 -2
  7. package/box/build-e2b.mjs +41 -18
  8. package/box/recipe.mjs +43 -0
  9. package/dist/agent37-ssh.d.ts +89 -0
  10. package/dist/agent37-ssh.js +445 -0
  11. package/dist/agent37.d.ts +104 -0
  12. package/dist/agent37.js +402 -0
  13. package/dist/attach.d.ts +146 -0
  14. package/dist/attach.js +469 -0
  15. package/dist/browserbase.d.ts +2 -10
  16. package/dist/browserbase.js +3 -6
  17. package/dist/client.d.ts +45 -4
  18. package/dist/client.js +92 -4
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/computerd.json +4 -0
  22. package/dist/conformance/agent37.d.ts +96 -0
  23. package/dist/conformance/agent37.js +154 -0
  24. package/dist/conformance/cases/apps.d.ts +11 -0
  25. package/dist/conformance/cases/apps.js +173 -73
  26. package/dist/conformance/cases/health.js +14 -0
  27. package/dist/conformance/cases/index.js +2 -0
  28. package/dist/conformance/cases/isolation.d.ts +7 -5
  29. package/dist/conformance/cases/isolation.js +44 -14
  30. package/dist/conformance/cases/mount.js +1 -1
  31. package/dist/conformance/cases/provider.js +27 -1
  32. package/dist/conformance/cases/screen.d.ts +3 -0
  33. package/dist/conformance/cases/screen.js +18 -0
  34. package/dist/conformance/cases/settings.d.ts +29 -23
  35. package/dist/conformance/cases/settings.js +76 -58
  36. package/dist/conformance/cases/touch.js +19 -17
  37. package/dist/conformance/cases/ui.d.ts +2 -0
  38. package/dist/conformance/cases/ui.js +475 -0
  39. package/dist/conformance/cli.d.ts +9 -0
  40. package/dist/conformance/cli.js +94 -9
  41. package/dist/conformance/daytona.d.ts +9 -20
  42. package/dist/conformance/daytona.js +12 -21
  43. package/dist/conformance/e2b.d.ts +6 -0
  44. package/dist/conformance/e2b.js +9 -2
  45. package/dist/conformance/exec-stream.d.ts +45 -0
  46. package/dist/conformance/exec-stream.js +486 -0
  47. package/dist/conformance/fixture.d.ts +1 -1
  48. package/dist/conformance/fixture.js +25 -1
  49. package/dist/conformance/modal.d.ts +17 -13
  50. package/dist/conformance/modal.js +18 -9
  51. package/dist/conformance/orgo.d.ts +3 -3
  52. package/dist/conformance/orgo.js +6 -8
  53. package/dist/conformance/phone-harness.d.ts +6 -2
  54. package/dist/conformance/phone-harness.js +21 -4
  55. package/dist/conformance/report.js +1 -1
  56. package/dist/conformance/runner.js +23 -4
  57. package/dist/conformance/sweep.d.ts +50 -0
  58. package/dist/conformance/sweep.js +187 -0
  59. package/dist/conformance/types.d.ts +13 -5
  60. package/dist/conformance/ui-fixture.d.ts +56 -0
  61. package/dist/conformance/ui-fixture.js +43 -0
  62. package/dist/create-requests.d.ts +51 -0
  63. package/dist/create-requests.js +121 -0
  64. package/dist/daytona.d.ts +20 -133
  65. package/dist/daytona.js +405 -1449
  66. package/dist/descriptor.d.ts +11 -1
  67. package/dist/descriptor.js +9 -0
  68. package/dist/descriptors/agent37.d.ts +41 -0
  69. package/dist/descriptors/agent37.js +28 -0
  70. package/dist/descriptors/daytona.d.ts +6 -5
  71. package/dist/descriptors/daytona.js +9 -5
  72. package/dist/descriptors/index.d.ts +42 -7
  73. package/dist/descriptors/index.js +4 -2
  74. package/dist/descriptors/orgo.d.ts +2 -1
  75. package/dist/descriptors/orgo.js +3 -2
  76. package/dist/descriptors/phone-harness.d.ts +1 -1
  77. package/dist/descriptors/phone-harness.js +2 -2
  78. package/dist/descriptors/shared.d.ts +1 -1
  79. package/dist/descriptors/shared.js +2 -2
  80. package/dist/desktop.d.ts +18 -4
  81. package/dist/desktop.js +89 -9
  82. package/dist/docker.d.ts +7 -10
  83. package/dist/docker.js +272 -34
  84. package/dist/drift.js +4 -4
  85. package/dist/e2b.d.ts +16 -290
  86. package/dist/e2b.js +230 -1393
  87. package/dist/fake-ui-driver.d.ts +97 -0
  88. package/dist/fake-ui-driver.js +717 -0
  89. package/dist/host.d.ts +201 -0
  90. package/dist/host.js +8 -0
  91. package/dist/hosted/process.d.ts +81 -0
  92. package/dist/hosted/process.js +259 -0
  93. package/dist/hosted/provider.d.ts +160 -0
  94. package/dist/hosted/provider.js +1415 -0
  95. package/dist/hosted/rest.d.ts +66 -0
  96. package/dist/hosted/rest.js +121 -0
  97. package/dist/hosted/scripts.d.ts +82 -0
  98. package/dist/{child.js → hosted/scripts.js} +118 -12
  99. package/dist/hosted/values.d.ts +5 -0
  100. package/dist/hosted/values.js +8 -0
  101. package/dist/index.d.ts +7 -3
  102. package/dist/index.js +7 -4
  103. package/dist/kernel.d.ts +2 -10
  104. package/dist/kernel.js +3 -6
  105. package/dist/kinds.d.ts +11 -2
  106. package/dist/kinds.js +20 -4
  107. package/dist/local-chrome.d.ts +2 -10
  108. package/dist/local-chrome.js +3 -6
  109. package/dist/modal.d.ts +22 -257
  110. package/dist/modal.js +183 -1280
  111. package/dist/mount-archil.d.ts +8 -4
  112. package/dist/mount-archil.js +22 -11
  113. package/dist/mount.d.ts +10 -4
  114. package/dist/mount.js +8 -4
  115. package/dist/orgo-channel.d.ts +3 -2
  116. package/dist/orgo-channel.js +5 -2
  117. package/dist/orgo-desktop.d.ts +9 -4
  118. package/dist/orgo-desktop.js +33 -13
  119. package/dist/orgo-workspaces.d.ts +47 -0
  120. package/dist/orgo-workspaces.js +94 -0
  121. package/dist/orgo.d.ts +10 -13
  122. package/dist/orgo.js +32 -21
  123. package/dist/phone-harness.d.ts +31 -28
  124. package/dist/phone-harness.js +510 -702
  125. package/dist/png.d.ts +4 -0
  126. package/dist/png.js +27 -0
  127. package/dist/protocol.d.ts +339 -33
  128. package/dist/protocol.js +97 -3
  129. package/dist/provider.d.ts +36 -8
  130. package/dist/provider.js +16 -0
  131. package/dist/providers.d.ts +11 -12
  132. package/dist/result.d.ts +1 -1
  133. package/dist/screen-watch.js +34 -6
  134. package/dist/surface/api.d.ts +260 -0
  135. package/dist/surface/api.js +1 -0
  136. package/dist/surface/core.d.ts +55 -0
  137. package/dist/surface/core.js +475 -0
  138. package/dist/surface/index.d.ts +5 -0
  139. package/dist/surface/index.js +3 -0
  140. package/dist/surface/outline.d.ts +10 -0
  141. package/dist/surface/outline.js +51 -0
  142. package/dist/surface/script.d.ts +10 -0
  143. package/dist/surface/script.js +94 -0
  144. package/dist/ui-engine.d.ts +114 -0
  145. package/dist/ui-engine.js +814 -0
  146. package/package.json +18 -3
  147. package/dist/child.d.ts +0 -42
  148. package/dist/conformance/daytona-sweep.d.ts +0 -18
  149. package/dist/conformance/daytona-sweep.js +0 -126
  150. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  151. package/dist/conformance/e2b-diagnose.js +0 -61
  152. package/dist/conformance/e2b-sweep.d.ts +0 -18
  153. package/dist/conformance/e2b-sweep.js +0 -132
  154. package/dist/conformance/modal-sweep.d.ts +0 -22
  155. package/dist/conformance/modal-sweep.js +0 -213
package/dist/kinds.js CHANGED
@@ -2,8 +2,8 @@ import { DESCRIPTORS } from "./descriptors/index.js";
2
2
  export const SETTING_KINDS = {
3
3
  none: { machineKinds: [], required: [], optional: [] },
4
4
  sandbox: { machineKinds: ["linux"], required: ["exec", "files", "processes"], optional: [] },
5
- desktop: { machineKinds: ["desktop"], required: ["screen", "input.pointer", "input.keys"], optional: ["exec", "files", "processes", "apps", "stream"] },
6
- phone: { machineKinds: ["android", "ios"], required: ["screen", "input.touch", "apps"], optional: ["input.keys", "apps.install", "apps.ui_tree", "stream"] },
5
+ desktop: { machineKinds: ["desktop"], required: ["screen", "input.pointer", "input.keys"], optional: ["exec", "files", "processes", "apps", "ui", "stream"] },
6
+ phone: { machineKinds: ["android", "ios"], required: ["screen", "input.touch", "apps"], optional: ["input.keys", "apps.install", "ui", "stream"] },
7
7
  browser: { machineKinds: ["browser"], required: ["cdp"], optional: ["stream", "downloads"] },
8
8
  };
9
9
  /** Every setting kind, in the table's order. */
@@ -18,12 +18,28 @@ export function servingRefusals(capabilities, kind) {
18
18
  const refusals = [];
19
19
  if (!spec.machineKinds.includes(capabilities.kind))
20
20
  refusals.push(`kind ${kind} is a ${spec.machineKinds.join(" or ")} machine, not a ${capabilities.kind} one`);
21
- const groups = Array.isArray(capabilities.groups) ? capabilities.groups : [];
22
- const missing = spec.required.filter((group) => !groups.includes(group));
21
+ const missing = missingGroups(spec, capabilities.groups);
23
22
  if (missing.length > 0)
24
23
  refusals.push(`kind ${kind} needs groups ${missing.join(", ")}, which the provider does not declare`);
25
24
  return refusals;
26
25
  }
26
+ /** The groups a setting kind requires that `groups` lacks; a groups that is no list lacks them all. */
27
+ function missingGroups(spec, groups) {
28
+ const declared = Array.isArray(groups) ? groups : [];
29
+ return spec.required.filter((group) => !declared.includes(group));
30
+ }
31
+ /**
32
+ * The groups a computer's hello must add to serve the setting kind its machine kind belongs to: the required groups
33
+ * hello.groups lacks, for the SETTING_KINDS entry whose machineKinds holds hello.kind. Empty when it serves that kind.
34
+ * A desktop that declares no input.pointer can't be given to an agent, so serve refuses it at connect and pairing, and
35
+ * health.kind-served fails a driver whose hello says so.
36
+ */
37
+ export function kindServed(hello) {
38
+ const kind = SETTING_KIND_NAMES.find((name) => SETTING_KINDS[name].machineKinds.includes(hello.kind));
39
+ if (kind === undefined)
40
+ return [];
41
+ return missingGroups(SETTING_KINDS[kind], hello.groups);
42
+ }
27
43
  /** Whether a provider with these capabilities serves the kind: its machine kind is one of the kind's, and it declares every required group. */
28
44
  export function serves(capabilities, kind) {
29
45
  return servingRefusals(capabilities, kind).length === 0;
@@ -1,19 +1,13 @@
1
- import type { KindCapabilities } from "./kinds.js";
2
- import type { MountKind } from "./mount.js";
3
- import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
1
+ import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreateContext, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
4
2
  import { type Result } from "./result.js";
5
3
  /** The longest a local browser lives: a day, as pi-browser's local Chrome. */
6
4
  export declare const LOCAL_MAX_LIFETIME_MS: number;
7
- /** A browser takes no mount: its descriptor's (descriptors/local-chrome.ts). */
8
- export declare const MOUNT: readonly MountKind[];
9
5
  /** A spec's network as this browser's proxy takes it: open (no list), a list (parseAllow's), or why it can't. */
10
6
  export declare function browserNetworkOf(network: unknown): {
11
7
  allow?: string[];
12
8
  } | {
13
9
  problem: string;
14
10
  };
15
- /** The one configuration it offers, its descriptor's: a browser with a CDP target. */
16
- export declare const CAPABILITIES: readonly KindCapabilities[];
17
11
  export interface LocalBrowserOptions {
18
12
  /** The Chrome or Chromium to run; default the one findChrome finds in `env`, then in the usual places. */
19
13
  executablePath?: string;
@@ -49,9 +43,7 @@ export declare class LocalBrowserProvider implements ComputerProvider {
49
43
  executable(): string | null;
50
44
  check(spec: ComputerSpec): Refusal[];
51
45
  /** Starts Chrome under a supervisor of its own, waits until its DevTools socket answers, and hands back its ref. */
52
- create(spec: ComputerSpec, { signal }?: {
53
- signal?: AbortSignal;
54
- }): Promise<Result<CreatedComputer>>;
46
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
55
47
  /**
56
48
  * Settings' test: finds the Chrome and starts it once, headless, on a blank page, with its sandbox on (chrome.ts
57
49
  * checkChrome), with a proxy that reaches nothing. No browser is kept and no key is read; no Chrome, root, or a Chrome
@@ -45,8 +45,6 @@ const WINDOW = "--window-size=1280,800";
45
45
  const SOCKET_PATH_MAX = 107;
46
46
  /** How long a release waits for the supervisor, then for Chrome, to end. */
47
47
  const END_MS = 10_000;
48
- /** A browser takes no mount: its descriptor's (descriptors/local-chrome.ts). */
49
- export const MOUNT = LOCAL.mounts;
50
48
  /** The networks a local browser runs on, its descriptor's: through its egress proxy, public addresses ("open"), or only
51
49
  * the hosts of a list ("allow"), public ones still. */
52
50
  const NETWORK = LOCAL.network;
@@ -75,8 +73,6 @@ const networkRecord = (network) => {
75
73
  };
76
74
  /** A browser's network as list, attach and network() read it back from browser.json. */
77
75
  const networkRead = (record) => (record.allow ? { allow: [...record.allow] } : "open");
78
- /** The one configuration it offers, its descriptor's: a browser with a CDP target. */
79
- export const CAPABILITIES = LOCAL.capabilities;
80
76
  const ID = /^lb-[0-9a-f]{16}$/;
81
77
  const idProblem = (id) => (typeof id === "string" && ID.test(id) ? undefined : `${typeof id === "string" ? JSON.stringify(id) : String(id)} is not a local browser's id`);
82
78
  const refOf = (id) => ({ id, name: id });
@@ -124,7 +120,7 @@ export class LocalBrowserProvider {
124
120
  isolation: "host",
125
121
  os: "linux",
126
122
  daemon: "none",
127
- groups: [...CAPABILITIES[0].groups],
123
+ groups: [...LOCAL.capabilities[0].groups],
128
124
  maxLifetimeMs: LOCAL_MAX_LIFETIME_MS,
129
125
  release: ["delete"],
130
126
  browser: { timeout: "wall-clock" },
@@ -188,7 +184,8 @@ export class LocalBrowserProvider {
188
184
  }
189
185
  }
190
186
  /** Starts Chrome under a supervisor of its own, waits until its DevTools socket answers, and hands back its ref. */
191
- async create(spec, { signal } = {}) {
187
+ async create(spec, context) {
188
+ const signal = context?.signal;
192
189
  const refusals = this.check(spec);
193
190
  if (refusals.length > 0)
194
191
  return fail(refusals.some((r) => r.field === "image" && r.message.endsWith(NO_CHROME)) ? "not_found" : "refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
package/dist/modal.d.ts CHANGED
@@ -1,151 +1,21 @@
1
- import type { KindCapabilities } from "./kinds.js";
2
- import { type MountKind } from "./mount.js";
3
- import { type ProviderNote } from "./mount-archil.js";
4
- import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
5
- import { type Result } from "./result.js";
6
- import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
- /** The App sandboxes are made in (modal-client@64880502:js/src/app.ts:32-61). */
8
- export interface ModalApp {
9
- readonly appId: string;
10
- }
11
- /** An Image, built on Modal's side when a sandbox is created from it (js/src/image.ts:311-401). */
12
- export interface ModalImage {
13
- dockerfileCommands(commands: string[]): ModalImage;
14
- }
15
- /** What sandboxes.create is given: every field is one of the SDK's SandboxCreateParams (js/src/sandbox.ts:356-474). */
16
- export interface ModalCreateParams {
17
- /** vm, or gvisor for a GPU computer: Modal offers GPUs on gVisor only. */
18
- runtime: ModalRuntime;
19
- /** The GPUs, as the SDK takes them ("T4", "A100-80GB:4"): a GPU computer only. */
20
- gpu?: string;
21
- command: string[];
22
- timeoutMs: number;
23
- workdir: string;
24
- cpu: number;
25
- cpuLimit: number;
26
- memoryMiB: number;
27
- memoryLimitMiB: number;
28
- blockNetwork?: true;
29
- tags: Record<string, string>;
30
- }
31
- /** A program's stdin in binary mode: the SDK's ModalWriteStream (js/src/streams.ts:33-39) and WritableStream's close. */
32
- export interface ModalByteSink {
33
- writeBytes(bytes: Uint8Array): Promise<void>;
34
- close(): Promise<void>;
35
- }
36
- /** One program started by exec in binary mode: the part of the SDK's ContainerProcess read here (sandbox.ts:2774-2914). */
37
- export interface ModalProcess {
38
- readonly stdin: ModalByteSink;
39
- readonly stdout: AsyncIterable<Uint8Array>;
40
- readonly stderr: AsyncIterable<Uint8Array>;
41
- wait(): Promise<number>;
42
- }
43
- /** The part of the SDK's Sandbox called here (sandbox.ts:1624-2772). */
44
- export interface ModalSandbox {
45
- readonly sandboxId: string;
46
- exec(command: string[], params: {
47
- mode: "binary";
48
- }): Promise<ModalProcess>;
49
- /** null while the sandbox runs, its exit code once it has finished. */
50
- poll(): Promise<number | null>;
51
- getTags(): Promise<Record<string, string>>;
52
- terminate(): Promise<void>;
53
- /** The sandbox's own command's output (the SDK's ModalReadStream): read only to say why a create's sandbox ended. */
54
- readonly stdout?: {
55
- readText(): Promise<string>;
56
- };
57
- readonly stderr?: {
58
- readText(): Promise<string>;
59
- };
60
- }
61
- /** The part of the SDK's ModalClient this provider calls. The host passes its own client. */
62
- export interface ModalSdk {
63
- readonly apps: {
64
- fromName(name: string, params: {
65
- createIfMissing: boolean;
66
- }): Promise<ModalApp>;
67
- };
68
- /** fromId opens an image Modal already holds (im-..., as box/build-modal.py prints it); a spec naming one needs it. */
69
- readonly images: {
70
- fromRegistry(tag: string): ModalImage;
71
- fromId?(id: string): Promise<ModalImage>;
72
- };
73
- readonly sandboxes: {
74
- create(app: ModalApp, image: ModalImage, params: ModalCreateParams): Promise<ModalSandbox>;
75
- fromId(id: string): Promise<ModalSandbox>;
76
- list(params: {
77
- appId: string;
78
- tags: Record<string, string>;
79
- }): AsyncIterable<ModalSandbox>;
80
- };
81
- }
82
- /** The longest each kind of call may take, in ms. */
83
- export interface ModalTimeouts {
84
- /** sandboxes.create, which builds the image layer and waits for the sandbox to be scheduled. */
85
- createMs: number;
86
- /** Every other SDK call: apps.fromName, fromId, getTags, poll, terminate, exec's start. */
87
- callMs: number;
88
- /** A new connection, from the start of the bridge's exec (at most callMs of it) to the daemon's hello. */
89
- helloMs: number;
90
- /** The probe, run through the daemon. */
91
- probeMs: number;
92
- /** One whole list, every page and every sandbox's tags. */
93
- listMs: number;
94
- /** The daemon's upload, from the exec's start to its exit. The entrypoint waits this long and one call more. */
95
- uploadMs: number;
96
- /**
97
- * How long release delete, and a create that refuses its sandbox (drift, an abort, a failed upload), wait after the
98
- * terminate for poll to read the sandbox finished: Modal ends a sandbox asynchronously, and lists it until then. Each
99
- * wait also ends on the caller's abort.
100
- */
101
- releaseMs: number;
102
- /** The first pause between two of those polls; the pauses double up to 5 s. */
103
- releasePollMs: number;
104
- /**
105
- * How long a create whose sandbox Modal says is shutting down on its own (its command, init, exited) waits for poll to
106
- * read it finished, to give the command's exit code and words in its failure.
107
- */
108
- endedMs: number;
109
- /** Each root step of an Archil mount through exec (the preflight, mount or revoke, serve), and its checkin at release. */
110
- mountMs: number;
111
- }
112
- export interface ModalProviderOptions {
113
- /** The host's Modal client, or anything with the same slice. */
1
+ import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
+ /**
3
+ * The SDK's own types, imported as types only: erased at build, so nothing loads the SDK from here. The host passes its
4
+ * own client (or the constructor), which these name.
5
+ */
6
+ export type ModalSdk = object;
7
+ /** The Modal provider's options: the client and the app, then the shared adapter's (HostedOptions). */
8
+ export interface ModalProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs"> {
9
+ /** The host's Modal client. */
114
10
  sdk: ModalSdk;
115
- /** Told what is no failure of the call it came from: a release that did not let an Archil folder go cleanly. */
116
- onNote?: ProviderNote;
117
11
  /** The Modal App the sandboxes live in; made when missing. */
118
12
  app: string;
119
- /**
120
- * A registry image holding the daemon for linux/amd64 at /computerd, pinned by digest (name@sha256:<64 hex>), copied
121
- * into each computer's image with COPY --from. Without it the daemon is uploaded (daemonPath).
122
- */
123
- daemonImage?: string;
124
- /**
125
- * The daemon binary for linux/amd64 on this machine, streamed into each computer right after create when no
126
- * daemonImage is given. Default this package's dist/computerd-linux-amd64 (npm run build:daemon).
127
- */
128
- daemonPath?: string;
129
- /** The longest lifetime check takes, in ms, declared as capabilities().maxLifetimeMs: at most 24 hours, Modal's longest timeout, which is the default. */
13
+ /** The longest lifetime check takes, in ms: at most 24 hours, Modal's longest timeout, which is the default. */
130
14
  maxLifetimeMs?: number;
131
- /**
132
- * Who a computer runs as when its spec does not say: uid:gid in numbers, never root or root's group. Default 2510:2510
133
- * (TOOL_USER). Init refuses to start while another process in the sandbox holds the uid.
134
- */
135
- user?: string;
136
- timeouts?: Partial<ModalTimeouts>;
137
- /**
138
- * The addresses the probe tries, to show none of them answers a computer with network none: host:port over TCP, or
139
- * host:port/udp, a DNS query over UDP.
140
- */
141
- probeTargets?: string[];
15
+ timeouts?: Partial<HostedTimeouts>;
142
16
  }
143
- /** The mount kinds a Modal computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
144
- export declare const MOUNT: readonly MountKind[];
145
17
  /** The runtime a Modal sandbox runs under: vm, or gvisor for a GPU computer (Modal offers GPUs on gVisor only). */
146
18
  export type ModalRuntime = "vm" | "gvisor";
147
- /** The machine kind, groups and GPUs of its one configuration (its descriptor's): a linux computer, with GPUs when asked. */
148
- export declare const CAPABILITIES: readonly KindCapabilities[];
149
19
  /** The SDK's default server (modal-client@64880502:js/src/config.ts:143). */
150
20
  export declare const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com:443";
151
21
  /** What modalClient gives the SDK's ModalClient: the token, explicitly, so the SDK fills none of it in. */
@@ -185,126 +55,21 @@ export interface ModalCreateOptions extends Omit<ModalProviderOptions, "sdk">, M
185
55
  */
186
56
  export declare function modalClient({ tokenId, tokenSecret, serverUrl, ModalClient }: ModalClientOptions): Promise<ModalSdk>;
187
57
  /**
188
- * A ModalProvider from its options alone: the client as modalClient makes it from the token and server passed in, the
189
- * app (required), and the daemon copied from options.daemonImage when given, else uploaded (options.daemonPath, else this
190
- * package's build): given both, the image wins and no upload path is passed on, as the class takes one or the other. It
191
- * reads no environment but the guard modalClient keeps: serve passes its MODAL_TOKEN_ID, MODAL_TOKEN_SECRET and
192
- * AGENTRUN_BOX_APP, the conformance module the settings it reads. The app and the token are checked before any client
193
- * is made, and neither is ever echoed.
58
+ * A ModalProvider from its options alone: the client as modalClient makes it from the token and server passed in, and
59
+ * the app (required). It reads no environment but the guard modalClient keeps: serve passes its MODAL_TOKEN_ID,
60
+ * MODAL_TOKEN_SECRET and AGENTRUN_BOX_APP, the conformance module the settings it reads. The app and the token are
61
+ * checked before any client is made, and neither is ever echoed.
194
62
  */
195
63
  export declare function create(options: ModalCreateOptions): Promise<ModalProvider>;
196
64
  /** The conformance CLI's module for Modal: its live switch, the run's 30-minute cap and the drifted twin. */
197
65
  export declare const conformance: () => Promise<typeof import("./conformance/modal.js")>;
198
66
  /**
199
- * What an Archil computer's entrypoint waits for, beside the daemon, before it becomes init: root makes it through exec
200
- * once the run's folder is mounted, so no tool program runs before that. The daemon's directory is root's alone.
201
- */
202
- export declare const ARCHIL_GATE = "/opt/agentrun/archil-mounted";
203
- /**
204
- * The commands the provider sends into a sandbox when it uploads the daemon, exactly: the sandbox's command
205
- * (entrypoint, which also waits for `gate` when given: an Archil computer's), the upload, and a connection's bridge
206
- * (stdio). Exported so a test can run them where Modal would.
207
- */
208
- export declare function modalCommands({ deadline, user, waitSeconds, sha256, daemon, home, gate, }?: {
209
- deadline?: string;
210
- user?: string;
211
- waitSeconds?: number;
212
- sha256?: string;
213
- daemon?: string;
214
- home?: string;
215
- gate?: string;
216
- }): {
217
- entrypoint: string[];
218
- upload: string[];
219
- hold: string[];
220
- stdio: string[];
221
- };
222
- export interface UntilFinishedOptions {
223
- /** The sandbox in words, for the errors, such as its name or id. */
224
- name: string;
225
- /** The longest the whole wait takes, in ms. */
226
- boundMs: number;
227
- /** The longest one poll may take, in ms. */
228
- callMs: number;
229
- /** The first pause between two polls, in ms; each pause doubles up to maxMs. */
230
- minMs: number;
231
- /** The longest pause between two polls, in ms. */
232
- maxMs: number;
233
- /** Ends the wait early, as aborted; a wait that must finish whatever its caller does is given none. */
234
- signal?: AbortSignal;
235
- }
236
- /**
237
- * The one wait after a terminate, which returns before Modal has ended the sandbox (sandbox.ts:1292-1296, 2238-2251):
238
- * polls through waitUntil until poll reads an exit code (null while it runs, sandbox.ts:2761-2771) or Modal no longer
239
- * knows the sandbox. Past boundMs it is a timeout, and on the signal's abort an abort, each saying what poll last read;
240
- * it never reports a sandbox finished that it did not read finished. release delete, a create that refuses its
241
- * sandbox, and modal-sweep --after all wait through it.
242
- */
243
- export declare function untilFinished(poll: () => Promise<number | null>, { name, boundMs, callMs, minMs, maxMs, signal }: UntilFinishedOptions): Promise<Result<void>>;
244
- /**
245
- * Computers that are Modal sandboxes on the VM runtime, or on gVisor with a GPU. The daemon is uploaded right after create, streamed through an
246
- * exec's stdin, while the sandbox's command, a small sh entrypoint, waits for it and then becomes `computerd init`; or,
247
- * with daemonImage, it comes in as a layer of the computer's image (COPY --from) and is the command itself. A
248
- * connection is `computerd stdio` through exec, so a computer with network none is still reached, and needs no network
249
- * to get its daemon either way. Modal ends each sandbox at its timeout, so the lifetime is the vendor's. Modal reads no
250
- * network policy back, so the daemon's probe stands for one: network none is honoured only when none of its addresses
251
- * answers (an address that accepts and sends nothing back is named in the read-back's notes), and an allowlist is
252
- * refused until the live bypass cases pass.
67
+ * Computers that are Modal sandboxes on the VM runtime, or on gVisor with a GPU, on the shared adapter. The daemon is
68
+ * streamed in through an exec's stdin right after create, while the sandbox's command, the entrypoint, waits for it and
69
+ * then becomes `computerd init`. A connection is `computerd stdio` through exec, so a computer with network none is still
70
+ * reached. Modal ends each sandbox at its timeout, so the lifetime is the vendor's. A spec may size a computer (cpus,
71
+ * memoryMb) and name the uid its programs run as, never root.
253
72
  */
254
- export declare class ModalProvider implements ComputerProvider {
255
- #private;
256
- readonly id = "modal";
257
- readonly version: string;
258
- constructor({ sdk, app, daemonImage, daemonPath, maxLifetimeMs, user, timeouts, probeTargets, onNote }: ModalProviderOptions);
259
- /**
260
- * daemon pid1: the sandbox's command is init itself (with daemonImage) or the entrypoint that execs into it, and Modal
261
- * finishes the sandbox when that main process exits (sandbox.ts:384-388), so init's exit ends the computer. Whether
262
- * Modal gives that process the number 1 is not documented; init reaps as a subreaper either way. maxLifetimeMs is this
263
- * instance's cap: Modal's 24 hours unless the provider was made with less. Init starts with --own-network whatever
264
- * Modal runs in the sandbox (no listener of its own there is documented, so no port is declared), and network none is
265
- * all a computer takes until a proxy carries open out of the daemon's own network.
266
- */
267
- capabilities(): ComputerCapabilities;
268
- check(spec: ComputerSpec): Refusal[];
269
- create(spec: ComputerSpec, { signal }?: CallContext): Promise<Result<CreatedComputer>>;
270
- /**
271
- * Settings' test: the provider's app read without making it (createIfMissing false), which makes nothing. An app not
272
- * made yet is a connection all the same: the token was taken, and the first computer makes the app.
273
- */
274
- testConnection({ signal }?: CallContext): Promise<Result<{
275
- detail: string;
276
- }>>;
277
- /** The live view: screen.watch on a connection of the watch's own (daemonWatch); a sandbox has no screen. */
278
- watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
279
- connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
280
- attach(ref: {
281
- id: string;
282
- } | {
283
- labels: Record<string, string>;
284
- }, { signal }?: CallContext): Promise<Result<AttachedComputer>>;
285
- /**
286
- * Every running computer this provider made that carries all of these labels. Modal's list asks for running sandboxes
287
- * only (includeFinished: false, sandbox.ts:1135-1140), yet a sandbox terminated a moment ago is still listed: each one
288
- * listed is polled, and one that poll reads finished (an exit code, not null, sandbox.ts:2761-2771) or no longer
289
- * finds is left out.
290
- */
291
- list(labels: Record<string, string>, { signal }?: CallContext): Promise<Result<ComputerInfo[]>>;
292
- /**
293
- * Modal reads no policy back. A computer here is made with none, read back by the probe from inside, and is another
294
- * network in words when any of its addresses answered (an address that only accepted, and sent nothing back, leaves it
295
- * none). A change is refused: it is fixed at create.
296
- */
297
- network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
298
- /**
299
- * delete terminates, and is idempotent: a sandbox already finished, or one Modal no longer knows, is ok. Modal ends a
300
- * sandbox asynchronously (terminate returns before it has finished unless asked to wait, sandbox.ts:1292-1296 and
301
- * 2238-2251), so delete then polls through untilFinished, as a refusing create does, with pauses that double from
302
- * releasePollMs to 5 s, until poll reads an exit code (null while it runs, sandbox.ts:2761-2771) or Modal no longer
303
- * knows it, within releaseMs and the caller's signal. Past releaseMs it is a timeout that says what poll last read,
304
- * never done. An Archil computer that still runs lets go of the run's folder first (archilRelease: the final sync
305
- * through computerd, then checkin as root); the terminate runs whatever that answers. A folder not let go cleanly
306
- * loses nothing (every call that changed it synced, and the next claim revokes the hold), so it is said through
307
- * onNote, and the release succeeds once the sandbox is gone.
308
- */
309
- release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
73
+ export declare class ModalProvider extends HostedProvider {
74
+ constructor(options: ModalProviderOptions);
310
75
  }