@parcha/agentrun-computer 0.1.0-beta.40 → 0.1.0-beta.42

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 (96) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +285 -28
  3. package/box/Dockerfile +6 -4
  4. package/box/README.md +10 -2
  5. package/box/build-daytona.py +3 -1
  6. package/box/build-e2b.mjs +1 -1
  7. package/box/install.sh +68 -7
  8. package/dist/attach.d.ts +46 -1
  9. package/dist/attach.js +48 -4
  10. package/dist/box-image.d.ts +1 -1
  11. package/dist/box-image.js +1 -1
  12. package/dist/boxd.d.ts +126 -0
  13. package/dist/boxd.js +418 -0
  14. package/dist/cloudflare.d.ts +32 -0
  15. package/dist/cloudflare.js +179 -0
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +2 -2
  19. package/dist/conformance/boxd.d.ts +77 -0
  20. package/dist/conformance/boxd.js +113 -0
  21. package/dist/conformance/cases/isolation.js +1 -17
  22. package/dist/conformance/cases/provider.js +42 -26
  23. package/dist/conformance/cli.js +4 -1
  24. package/dist/conformance/cloudflare.d.ts +42 -0
  25. package/dist/conformance/cloudflare.js +54 -0
  26. package/dist/conformance/daytona.d.ts +25 -0
  27. package/dist/conformance/daytona.js +26 -1
  28. package/dist/conformance/dial-only.d.ts +6 -0
  29. package/dist/conformance/dial-only.js +9 -0
  30. package/dist/conformance/e2b.d.ts +12 -3
  31. package/dist/conformance/e2b.js +21 -4
  32. package/dist/conformance/exec-stream.js +14 -6
  33. package/dist/conformance/fly.d.ts +52 -0
  34. package/dist/conformance/fly.js +52 -0
  35. package/dist/conformance/modal.d.ts +15 -2
  36. package/dist/conformance/modal.js +36 -3
  37. package/dist/conformance/morph.d.ts +59 -0
  38. package/dist/conformance/morph.js +95 -0
  39. package/dist/conformance/phone-harness.js +2 -2
  40. package/dist/conformance/runner.js +5 -1
  41. package/dist/conformance/sweep.d.ts +1 -1
  42. package/dist/conformance/sweep.js +1 -1
  43. package/dist/conformance/types.d.ts +21 -0
  44. package/dist/daytona.d.ts +8 -1
  45. package/dist/daytona.js +124 -101
  46. package/dist/descriptor.d.ts +22 -1
  47. package/dist/descriptor.js +18 -0
  48. package/dist/descriptors/boxd.d.ts +52 -0
  49. package/dist/descriptors/boxd.js +29 -0
  50. package/dist/descriptors/cloudflare.d.ts +21 -0
  51. package/dist/descriptors/cloudflare.js +29 -0
  52. package/dist/descriptors/daytona.d.ts +12 -3
  53. package/dist/descriptors/daytona.js +15 -7
  54. package/dist/descriptors/e2b.d.ts +4 -0
  55. package/dist/descriptors/e2b.js +3 -0
  56. package/dist/descriptors/fly.d.ts +19 -0
  57. package/dist/descriptors/fly.js +28 -0
  58. package/dist/descriptors/index.d.ts +121 -2
  59. package/dist/descriptors/index.js +7 -2
  60. package/dist/descriptors/modal.d.ts +3 -0
  61. package/dist/descriptors/modal.js +7 -2
  62. package/dist/descriptors/morph.d.ts +15 -0
  63. package/dist/descriptors/morph.js +21 -0
  64. package/dist/descriptors/phone-harness.d.ts +1 -0
  65. package/dist/descriptors/phone-harness.js +2 -0
  66. package/dist/e2b.d.ts +7 -1
  67. package/dist/e2b.js +87 -44
  68. package/dist/fly.d.ts +43 -0
  69. package/dist/fly.js +245 -0
  70. package/dist/host.d.ts +52 -48
  71. package/dist/hosted/framed-exec.d.ts +8 -19
  72. package/dist/hosted/framed-exec.js +21 -87
  73. package/dist/hosted/process.d.ts +21 -0
  74. package/dist/hosted/process.js +37 -2
  75. package/dist/hosted/provider.d.ts +32 -6
  76. package/dist/hosted/provider.js +239 -236
  77. package/dist/hosted/rest.d.ts +19 -0
  78. package/dist/hosted/rest.js +76 -0
  79. package/dist/hosted/scripts.d.ts +52 -8
  80. package/dist/hosted/scripts.js +118 -23
  81. package/dist/hosted/ssh-exec.d.ts +9 -7
  82. package/dist/hosted/ssh-exec.js +93 -54
  83. package/dist/hosted/values.d.ts +5 -0
  84. package/dist/hosted/values.js +9 -0
  85. package/dist/index.d.ts +3 -3
  86. package/dist/index.js +4 -4
  87. package/dist/kinds.d.ts +2 -0
  88. package/dist/modal.d.ts +6 -0
  89. package/dist/modal.js +40 -17
  90. package/dist/morph.d.ts +65 -0
  91. package/dist/morph.js +495 -0
  92. package/dist/phone-harness.d.ts +15 -5
  93. package/dist/phone-harness.js +50 -15
  94. package/dist/providers.d.ts +4 -2
  95. package/dist/screen-watch.js +2 -2
  96. package/package.json +20 -2
@@ -4,6 +4,15 @@ import { deflateRawSync, inflateRawSync } from "node:zlib";
4
4
  /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
5
5
  export const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
6
6
  export const isWhole = (value) => typeof value === "number" && Number.isSafeInteger(value);
7
+ /**
8
+ * How a provider that can do both reaches its machines (its descriptor's connect setting): exec (the default), a bridge
9
+ * through the vendor's exec for each connection; dial, the machine's computerd dials the server (HostFacts.connect).
10
+ */
11
+ export function connectOf(value, label) {
12
+ if (value === undefined || value === "exec" || value === "dial")
13
+ return value ?? "exec";
14
+ throw new Error(`connect is how ${label} reaches its machines, "exec" (the default) or "dial", not ${JSON.stringify(value)}`);
15
+ }
7
16
  /** A vendor whose computer has its image's size: a spec's cpus or memoryMb, refused in words (computer: "an E2B computer"). */
8
17
  export function sizeRefusals(spec, computer, image) {
9
18
  return ["cpus", "memoryMb"].filter((field) => spec[field] !== undefined).map((field) => ({ field, message: `${computer} has the size of its ${image}: name a ${image} of the size you need, not ${field}` }));
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar }
10
10
  export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
11
11
  export { type ActionMapper, createActionMapper, daemonWatch, redactWords, type ScreenFrame, type ScreenFrames, type ScreenWatch, ScreenWatchError, type ScreenWatchHandlers, toAction, type ViewerEvent, type WatchEndCode, watchEndCode, type WatchOptions, watchScreen, } from "./screen-watch.js";
12
12
  export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
13
- export { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
13
+ export { HostedProvider, type HostedDial, type HostedOptions, type HostedTimeouts, hostedDaemonPath } from "./hosted/provider.js";
14
14
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
15
15
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, type EnsureImageOptions, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, type ImageSource, imageSourceProblem, type Making, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
16
16
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
@@ -23,8 +23,8 @@ export { type ReleasedOlder, releaseOlder, sweep, type SweepOptions, type Swept
23
23
  export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerFilter, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
24
24
  export { waitUntil, type WaitOptions } from "./wait.js";
25
25
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
26
- export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
27
- export { AGENT37, AGENT37_BASE_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
26
+ export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
27
+ export { AGENT37, AGENT37_BASE_TEMPLATE, BOXD, BOXD_DEFAULT_IMAGE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
28
28
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
29
29
  export { type ComputerSettingKind, configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, kindServed, type ProviderEntry, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
30
30
  export * from "./conformance/index.js";
package/dist/index.js CHANGED
@@ -9,9 +9,9 @@ export { checkActions, isKey } from "./actions.js";
9
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
10
10
  export { listProcesses, readAll } from "./processes.js";
11
11
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
12
- export { HostedProvider } from "./hosted/provider.js";
12
+ export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
13
13
  // The provider classes and their option types are not here: each provider loads by its id through the registry
14
- // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /orgo,
14
+ // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /morph, /orgo,
15
15
  // /phone-harness, /browserbase, /kernel, /local: each the provider file's name).
16
16
  export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
17
17
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, imageSourceProblem, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
@@ -27,7 +27,7 @@ export { releaseOlder, sweep } from "./janitor.js";
27
27
  export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerFilter, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
28
28
  export { waitUntil } from "./wait.js";
29
29
  export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
30
- export { defineProvider, descriptorProblems } from "./descriptor.js";
31
- export { AGENT37, AGENT37_BASE_TEMPLATE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
30
+ export { defineProvider, descriptorProblems, mountsOf } from "./descriptor.js";
31
+ export { AGENT37, AGENT37_BASE_TEMPLATE, BOXD, BOXD_DEFAULT_IMAGE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
32
32
  export { configurationOf, entryOf, imagesOf, kindOf, kindServed, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
33
33
  export * from "./conformance/index.js";
package/dist/kinds.d.ts CHANGED
@@ -68,6 +68,8 @@ export interface ProviderEntry {
68
68
  readonly mounts: readonly MountKind[];
69
69
  /** Why its computers take none of these mount kinds, each in one sentence (descriptor.ts). */
70
70
  readonly unmounted?: Unmounted;
71
+ /** Mount kinds its computers take only where the operator sets the key named, by kind (descriptor.ts, mountsOf). */
72
+ readonly mountsWith?: Readonly<Partial<Record<MountKind, string>>>;
71
73
  /**
72
74
  * The network forms its computers make, its descriptor's: ["none"], a remote computer whose programs run in a network
73
75
  * of their own; ["open"], the vendor's own network, which no allowlist of this server reaches; Docker's all three.
package/dist/modal.d.ts CHANGED
@@ -14,6 +14,12 @@ export interface ModalProviderOptions extends Omit<HostedOptions, "kind" | "desk
14
14
  /** The longest lifetime check takes, in ms: at most 24 hours, Modal's longest timeout, which is the default. */
15
15
  maxLifetimeMs?: number;
16
16
  timeouts?: Partial<HostedTimeouts>;
17
+ /**
18
+ * exec (default): the daemon goes in through exec's stdin and each connection is a bridge through Modal's exec. dial:
19
+ * the sandbox's command is the box image's agentrun-dial, and the machine dials the server (options.dial), which
20
+ * every connection goes over.
21
+ */
22
+ connect?: "exec" | "dial";
17
23
  }
18
24
  /** The SDK's default server (modal-client@64880502:js/src/config.ts:143). */
19
25
  export declare const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com:443";
package/dist/modal.js CHANGED
@@ -3,7 +3,8 @@ import { MODAL } from "./descriptors/modal.js";
3
3
  import { DEFAULT_CPUS, DEFAULT_MEMORY_MB, WORK } from "./drift.js";
4
4
  import { HostError } from "./host.js";
5
5
  import { HostedProvider } from "./hosted/provider.js";
6
- import { isWhole } from "./hosted/values.js";
6
+ import { AGENTRUN_DIAL, PID_WRAPPER, pidKill, pidStderr } from "./hosted/scripts.js";
7
+ import { connectOf, isWhole } from "./hosted/values.js";
7
8
  import { ok } from "./result.js";
8
9
  /** A GPU as the SDK takes it: the type, then :count past one ("T4", "H100:8"). */
9
10
  const modalGpu = ({ type, count }) => (count === 1 ? type : `${type}:${count}`);
@@ -113,18 +114,22 @@ function codeOf(error) {
113
114
  class ModalHost {
114
115
  descriptor = MODAL;
115
116
  facts;
117
+ /** connect exec alone: a dial host has none (HostFacts.connect). */
118
+ exec;
116
119
  #sdk;
117
120
  #appName;
118
121
  /** Each sandbox create or a read gave, by id: let go of at its delete. */
119
122
  #sandboxes = new Map();
120
123
  #app;
121
- constructor(sdk, app) {
124
+ constructor(sdk, app, connect) {
122
125
  this.#sdk = sdk;
123
126
  this.#appName = app;
124
127
  this.facts = {
125
128
  // The sandbox's command is the entrypoint, which becomes init: Modal finishes the sandbox when that main process
126
- // exits (sandbox.ts:384-388), so init's exit ends the computer.
127
- daemon: "pid1",
129
+ // exits (sandbox.ts:384-388), so init's exit ends the computer. On dial the command is agentrun-dial, which
130
+ // starts init as its child and becomes `computerd attach`.
131
+ daemon: connect === "dial" ? "child" : "pid1",
132
+ ...(connect === "dial" ? { connect } : {}),
128
133
  // A GPU computer runs on gVisor, Modal's one GPU runtime (its descriptor's gpu.isolation): vm is every other computer's.
129
134
  isolation: "vm",
130
135
  lifetime: "vendor",
@@ -137,6 +142,8 @@ class ModalHost {
137
142
  user: ["uid"],
138
143
  labels: { count: MAX_TAGS, bytes: MAX_TAG_BYTES },
139
144
  };
145
+ if (connect === "exec")
146
+ this.exec = (id, argv, ctx) => this.#exec(id, argv, ctx);
140
147
  }
141
148
  errorCode(error) {
142
149
  return codeOf(error);
@@ -185,7 +192,10 @@ class ModalHost {
185
192
  */
186
193
  async create(req, ctx) {
187
194
  void ctx;
188
- if (req.command === undefined)
195
+ // A dial machine's command is the box image's agentrun-dial, and its boot env goes in as env, which the SDK sends as
196
+ // an ephemeral Secret (Secret.fromObject, modal@0.11.1 dist/index.js mergeEnvIntoSecrets).
197
+ const command = req.boot === undefined ? req.command : [AGENTRUN_DIAL];
198
+ if (command === undefined)
189
199
  throw new HostError("invalid", "a Modal sandbox's command is the entrypoint the adapter gives a pid1 host, and the request has none");
190
200
  let base;
191
201
  if (MODAL_IMAGE_ID.test(req.image)) {
@@ -201,7 +211,8 @@ class ModalHost {
201
211
  const cpuLimit = cpus / CPUS_PER_CORE;
202
212
  const params = {
203
213
  ...(req.gpu === undefined ? { runtime: "vm" } : { runtime: "gvisor", gpu: modalGpu(req.gpu) }),
204
- command: [...req.command],
214
+ command: [...command],
215
+ ...(req.boot === undefined ? {} : { env: { ...req.boot.env } }),
205
216
  timeoutMs: Math.ceil(req.lifetimeMs / 1000) * 1000,
206
217
  workdir: WORK,
207
218
  cpu: Math.min(CPU_REQUEST, cpuLimit),
@@ -287,21 +298,33 @@ class ModalHost {
287
298
  }
288
299
  }
289
300
  /**
290
- * exec in binary mode, as root (Modal containers always run as root), outside computerd. Modal has no kill for an
291
- * exec: kill closes its stdin, which ends the stdio bridge and anything else that reads it.
301
+ * exec in binary mode, as root (Modal containers always run as root), outside computerd, under PID_WRAPPER
302
+ * (./hosted/scripts.ts): Modal has no kill for an exec, so kill runs pidKill in an exec of its own, which ends the
303
+ * process and every process under it, then closes its stdin. Not once wait() read its exit: its pid may be another's.
292
304
  */
293
- async exec(id, argv, ctx) {
294
- void ctx;
305
+ async #exec(id, argv, ctx) {
295
306
  const sandbox = await this.#sandbox(id);
296
- const program = await sandbox.exec([...argv], { mode: "binary" });
297
- const close = () => program.stdin.close().catch(() => { });
307
+ const program = await sandbox.exec([...PID_WRAPPER, ...argv], { mode: "binary" });
308
+ const { stderr, pid } = pidStderr(program.stderr);
309
+ let exited = false;
310
+ let waited;
298
311
  return {
299
312
  stdout: program.stdout,
300
- stderr: program.stderr,
313
+ stderr,
301
314
  write: (bytes) => program.stdin.writeBytes(bytes),
302
315
  end: () => program.stdin.close(),
303
- wait: () => program.wait(),
304
- kill: async () => void (await close()),
316
+ wait: () => (waited ??= program.wait().then((code) => ((exited = true), code))),
317
+ kill: async () => {
318
+ try {
319
+ const target = exited ? undefined : await pid(ctx.timeoutMs);
320
+ if (target !== undefined && !exited)
321
+ await (await sandbox.exec(pidKill(target), { mode: "binary" })).wait();
322
+ }
323
+ catch {
324
+ // Best effort: kill never throws.
325
+ }
326
+ await program.stdin.close().catch(() => { });
327
+ },
305
328
  };
306
329
  }
307
330
  }
@@ -323,7 +346,7 @@ export class ModalProvider extends HostedProvider {
323
346
  return ok(boxImageRef());
324
347
  }
325
348
  constructor(options) {
326
- const { app, timeouts = {}, ...rest } = options ?? {};
349
+ const { app, timeouts = {}, connect, ...rest } = options ?? {};
327
350
  const sdk = options?.sdk;
328
351
  const lacks = [
329
352
  ["apps.fromName", sdk?.apps?.fromName],
@@ -336,6 +359,6 @@ export class ModalProvider extends HostedProvider {
336
359
  throw new Error(`options.sdk must be a Modal client; it lacks ${lacks.map(([name]) => name).join(", ")}`);
337
360
  if (typeof app !== "string" || app.trim() === "")
338
361
  throw new Error("options.app, the Modal app's name, is required");
339
- super(new ModalHost(sdk, app), { ...rest, kind: "linux", timeouts: { ...MODAL_TIMEOUTS, ...timeouts } });
362
+ super(new ModalHost(sdk, app, connectOf(connect, "Modal")), { ...rest, kind: "linux", timeouts: { ...MODAL_TIMEOUTS, ...timeouts } });
340
363
  }
341
364
  }
@@ -0,0 +1,65 @@
1
+ import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
+ import { type Ssh2Module } from "./hosted/ssh-exec.js";
3
+ import type { CallContext } from "./provider.js";
4
+ import { type Result } from "./result.js";
5
+ /** One instance as Morph answers it (OpenAPI InstanceModel), as far as this provider reads it. */
6
+ export interface MorphInstance {
7
+ id: string;
8
+ /** pending, ready, paused, saving or error (OpenAPI InstanceStatus). */
9
+ status: string;
10
+ /** Unix seconds. */
11
+ created?: number;
12
+ metadata?: Record<string, string> | null;
13
+ /** ttl_expire_at in Unix seconds; null fields when the instance has no TTL (OpenAPI InstanceTTL). */
14
+ ttl?: {
15
+ ttl_seconds?: number | null;
16
+ ttl_expire_at?: number | null;
17
+ ttl_action?: string | null;
18
+ } | null;
19
+ }
20
+ /** The Morph provider's options: the key and ssh2, then the shared adapter's (HostedOptions). */
21
+ export interface MorphProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs"> {
22
+ /** The account's API key. The caller passes it; this provider never reads it from the environment. */
23
+ apiKey: string;
24
+ /** The ssh2 package: the host's own, or anything with the same slice. */
25
+ ssh2: Ssh2Module;
26
+ /** The fetch every REST call goes through; default the global one. */
27
+ fetch?: typeof fetch;
28
+ /** Morph's REST API; default https://cloud.morph.so/api. */
29
+ apiUrl?: string;
30
+ /** Morph's SSH gateway; default ssh.cloud.morph.so, port 22. */
31
+ sshHost?: string;
32
+ sshPort?: number;
33
+ /** The longest lifetime check takes: 24 h by default, an assumed cap (Morph states none: unverified). */
34
+ maxLifetimeMs?: number;
35
+ timeouts?: Partial<HostedTimeouts>;
36
+ }
37
+ /** What create() takes: the provider's options, ssh2 optional (default the host's ssh2 package). */
38
+ export interface MorphOptions extends Omit<MorphProviderOptions, "ssh2"> {
39
+ ssh2?: Ssh2Module;
40
+ }
41
+ /**
42
+ * A MorphProvider from its options alone; it reads no environment. The key is options.apiKey, nowhere else (serve passes
43
+ * its MORPH_API_KEY, the conformance module what it reads), and ssh2 is the host's package unless given. Throws in words
44
+ * when an option is missing or wrong, never echoing a key.
45
+ */
46
+ export declare function create(options: MorphOptions): Promise<MorphProvider>;
47
+ /** The conformance CLI's module for Morph: its live switch, the run's cap, its snapshot and the drifted twin. */
48
+ export declare const conformance: () => Promise<typeof import("./conformance/morph.js")>;
49
+ /**
50
+ * Computers that are Morph instances, on the shared adapter. A spec's image is a Morph snapshot id. A server starts
51
+ * every one from the snapshot prepareImage() answers: our box image, built once in the key's own account.
52
+ */
53
+ export declare class MorphProvider extends HostedProvider {
54
+ /**
55
+ * The provider contract's prepareImage (its descriptor declares it): the box image as a snapshot of the key's
56
+ * account, its digest agentrun-box-<recipe hash>, found or built (MorphHost.boxSnapshot), so a new recipe is a new
57
+ * snapshot. ok with the snapshot's id; onWait is told "build" once, before a build, never when the account has one.
58
+ */
59
+ prepareImage(context?: CallContext & {
60
+ onWait?: (making: "build" | "pull", tag: string) => void;
61
+ }): Promise<Result<string>>;
62
+ constructor(options: MorphProviderOptions);
63
+ }
64
+ /** The account a key reaches, in words, for the sweep's scope: the key's sha256 prefix, never the key. */
65
+ export declare function accountOf(apiKey: string, apiUrl?: string): string;