@aerol-ai/aerolvm-sdk 0.1.9 → 0.1.10

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.
package/dist/MicroVM.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type APIVersion } from "./internal/client.js";
2
2
  import { Sandbox } from "./Sandbox.js";
3
3
  import { Image } from "./Image.js";
4
- import type { BuildImageOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecStreamHandle, ExecStreamOptions, HealthStatus, Lifecycle, MountSpecRedacted, ResizeOptions, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions } from "./types.js";
4
+ import type { BuildImageOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecStreamHandle, ExecStreamOptions, HealthStatus, Lifecycle, MountSpecRedacted, RegisterSnapshotOptions, ResizeOptions, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions } from "./types.js";
5
5
  type FetchLike = typeof fetch;
6
6
  export interface MicroVMConfig {
7
7
  patToken?: string;
@@ -26,6 +26,8 @@ export declare class MicroVM {
26
26
  start(id: string): Promise<Sandbox>;
27
27
  stop(id: string): Promise<Sandbox>;
28
28
  createSnapshot(id: string, name: string): Promise<SandboxSnapshot>;
29
+ registerSnapshot(options: RegisterSnapshotOptions): Promise<SandboxSnapshot>;
30
+ registerSnapshotFromImage(name: string, image: Image, options?: Omit<RegisterSnapshotOptions, "name" | "image" | "dockerfileContent">): Promise<SandboxSnapshot>;
29
31
  destroy(id: string): Promise<void>;
30
32
  resize(id: string, options: ResizeOptions): Promise<Sandbox>;
31
33
  updateLifecycle(id: string, lifecycle: Lifecycle): Promise<Sandbox>;
package/dist/MicroVM.js CHANGED
@@ -44,6 +44,12 @@ export class MicroVM {
44
44
  async createSnapshot(id, name) {
45
45
  return this.client.createSnapshot(id, name);
46
46
  }
47
+ async registerSnapshot(options) {
48
+ return this.client.registerSnapshot(options);
49
+ }
50
+ async registerSnapshotFromImage(name, image, options = {}) {
51
+ return this.client.registerSnapshotFromImage(name, image, options);
52
+ }
47
53
  async destroy(id) {
48
54
  await this.client.destroy(id);
49
55
  }
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { MicroVM } from "./MicroVM.js";
2
2
  export { Sandbox } from "./Sandbox.js";
3
3
  export { Image } from "./Image.js";
4
4
  export type { MicroVMConfig } from "./MicroVM.js";
5
- export type { BinaryLike, BuildImageOptions, BuildImagePushOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecRequest, ExecResult, ExecExitInfo, ExposedPort, ExposePortOptions, ExposeProtocol, ExposeResult, HealthStatus, Lifecycle, MountSpec, MountSpecRedacted, MountType, RegistryAuth, ResizeOptions, Sandbox as SandboxData, SandboxSnapshot, SandboxStatus, Session, SessionAttachHandle, SessionAttachOptions, SessionStatus, UpdateLifecycleOptions, } from "./types.js";
5
+ export type { BinaryLike, BuildImageOptions, BuildImagePushOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecRequest, ExecResult, ExecExitInfo, ExposedPort, ExposePortOptions, ExposeProtocol, ExposeResult, HealthStatus, Lifecycle, MountSpec, MountSpecRedacted, MountType, RegisterSnapshotOptions, RegistryAuth, ResizeOptions, Sandbox as SandboxData, SandboxSnapshot, SandboxStatus, Session, SessionAttachHandle, SessionAttachOptions, SessionStatus, UpdateLifecycleOptions, } from "./types.js";
@@ -1,5 +1,5 @@
1
1
  import { Image } from "../Image.js";
2
- import type { BinaryLike, BuildImageOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecRequest, ExecResult, ExecStreamHandle, ExecStreamOptions, ExposedPort, ExposePortOptions, ExposeResult, HealthStatus, Lifecycle, MountSpecRedacted, NetworkUsage, SetNetworkLimitsOptions, ResizeOptions, Sandbox, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions } from "../types.js";
2
+ import type { BinaryLike, BuildImageOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecRequest, ExecResult, ExecStreamHandle, ExecStreamOptions, ExposedPort, ExposePortOptions, ExposeResult, HealthStatus, Lifecycle, MountSpecRedacted, NetworkUsage, RegisterSnapshotOptions, SetNetworkLimitsOptions, ResizeOptions, Sandbox, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions } from "../types.js";
3
3
  type FetchLike = typeof fetch;
4
4
  /**
5
5
  * Wire version of the v1-style sandbox endpoints (`/v1/sandboxes`, etc.) this
@@ -60,6 +60,8 @@ export declare class APIClient {
60
60
  start(id: string): Promise<SandboxResource>;
61
61
  stop(id: string): Promise<SandboxResource>;
62
62
  createSnapshot(id: string, name: string): Promise<SandboxSnapshot>;
63
+ registerSnapshot(options: RegisterSnapshotOptions): Promise<SandboxSnapshot>;
64
+ registerSnapshotFromImage(name: string, image: Image, options?: Omit<RegisterSnapshotOptions, "name" | "image" | "dockerfileContent">): Promise<SandboxSnapshot>;
63
65
  destroy(id: string): Promise<void>;
64
66
  resize(id: string, options: ResizeOptions): Promise<SandboxResource>;
65
67
  updateLifecycle(id: string, lifecycle: Lifecycle): Promise<SandboxResource>;
@@ -105,6 +105,35 @@ export class APIClient {
105
105
  const response = await this.doJSON("POST", `${this.versionPrefix}/sandboxes/${id}/snapshot`, { name });
106
106
  return fromApiSandboxSnapshot(response);
107
107
  }
108
+ async registerSnapshot(options) {
109
+ const name = options.name.trim();
110
+ if (name === "") {
111
+ throw new Error("name is required");
112
+ }
113
+ const image = options.image?.trim() ?? "";
114
+ const dockerfileContent = options.dockerfileContent?.trim() ?? "";
115
+ if (image === "" && dockerfileContent === "") {
116
+ throw new Error("image or dockerfile_content is required");
117
+ }
118
+ if (image !== "" && dockerfileContent !== "") {
119
+ throw new Error("image and dockerfile_content are mutually exclusive");
120
+ }
121
+ const response = await this.doJSON("POST", this.versioned("/snapshots"), toApiRegisterSnapshotOptions({
122
+ ...options,
123
+ name,
124
+ image: image || undefined,
125
+ dockerfileContent: dockerfileContent || undefined,
126
+ regionID: options.regionID?.trim() || undefined,
127
+ }));
128
+ return fromApiSandboxSnapshot(response);
129
+ }
130
+ async registerSnapshotFromImage(name, image, options = {}) {
131
+ return this.registerSnapshot({
132
+ ...options,
133
+ name,
134
+ dockerfileContent: image.dockerfile,
135
+ });
136
+ }
108
137
  async destroy(id) {
109
138
  await this.doJSON("DELETE", `${this.versionPrefix}/sandboxes/${id}`);
110
139
  }
@@ -361,6 +390,20 @@ function toApiCreateOptions(options) {
361
390
  runtime: options.runtime,
362
391
  };
363
392
  }
393
+ function toApiRegisterSnapshotOptions(options) {
394
+ return {
395
+ name: options.name,
396
+ image: options.image,
397
+ dockerfile_content: options.dockerfileContent,
398
+ context_hashes: options.contextHashes,
399
+ entrypoint: options.entrypoint,
400
+ region_id: options.regionID,
401
+ cpu: options.cpu,
402
+ gpu: options.gpu,
403
+ memory_mb: options.memoryMB,
404
+ disk_gb: options.diskGB,
405
+ };
406
+ }
364
407
  function toApiResizeOptions(options) {
365
408
  return {
366
409
  cpu: options.cpu,
@@ -444,6 +487,12 @@ function fromApiSandboxSnapshot(snapshot) {
444
487
  imageID: snapshot.image_id,
445
488
  sourceSandboxID: snapshot.source_sandbox_id,
446
489
  createdAt: snapshot.created_at,
490
+ entrypoint: snapshot.entrypoint,
491
+ regionID: snapshot.region_id,
492
+ cpu: snapshot.cpu,
493
+ gpu: snapshot.gpu,
494
+ memoryMB: snapshot.memory_mb,
495
+ diskGB: snapshot.disk_gb,
447
496
  };
448
497
  }
449
498
  function fromApiSession(session) {
package/dist/types.d.ts CHANGED
@@ -28,6 +28,25 @@ export interface BuildImageResult {
28
28
  /** Pushed reference, e.g. "ghcr.io/my-org/my-image:v1.2.3". */
29
29
  pushed?: string;
30
30
  }
31
+ export interface RegisterSnapshotOptions {
32
+ /** Human-readable identifier other callers use in `CreateOptions.snapshot`. */
33
+ name: string;
34
+ /** Pre-built registry reference. Mutually exclusive with `dockerfileContent`. */
35
+ image?: string;
36
+ /** Literal Dockerfile the daemon will build. Mutually exclusive with `image`. */
37
+ dockerfileContent?: string;
38
+ /** Uploaded build-context hashes for future COPY/ADD resolution. */
39
+ contextHashes?: string[];
40
+ /** Optional command override persisted on the snapshot row. */
41
+ entrypoint?: string[];
42
+ /** Region hint persisted for read-back. */
43
+ regionID?: string;
44
+ /** Resource hints surfaced back on the snapshot row. */
45
+ cpu?: number;
46
+ gpu?: number;
47
+ memoryMB?: number;
48
+ diskGB?: number;
49
+ }
31
50
  export type MountType = "s3" | "nfs" | "sshfs" | "rclone";
32
51
  export interface MountSpec {
33
52
  type: MountType;
@@ -192,6 +211,12 @@ export interface SandboxSnapshot {
192
211
  imageID?: string;
193
212
  sourceSandboxID: string;
194
213
  createdAt: string;
214
+ entrypoint?: string[];
215
+ regionID?: string;
216
+ cpu?: number;
217
+ gpu?: number;
218
+ memoryMB?: number;
219
+ diskGB?: number;
195
220
  }
196
221
  /**
197
222
  * Discriminated result from `exposePort`. Branch on `protocol` to access the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerol-ai/aerolvm-sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",