@aerol-ai/aerolvm-sdk 0.1.10 → 0.2.2

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, RegisterSnapshotOptions, ResizeOptions, SandboxSnapshot, Session, SessionAttachHandle, SessionAttachOptions } from "./types.js";
4
+ import type { BuildImageOptions, BuildImageResult, CreateOptions, CreateSessionOptions, ExecStreamHandle, ExecStreamOptions, HealthStatus, Lifecycle, ListOptions, 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;
@@ -21,7 +21,7 @@ export declare class MicroVM {
21
21
  private readonly client;
22
22
  constructor(config?: MicroVMConfig);
23
23
  create(options: CreateOptions): Promise<Sandbox>;
24
- list(): Promise<Sandbox[]>;
24
+ list(options?: ListOptions): Promise<Sandbox[]>;
25
25
  get(id: string): Promise<Sandbox>;
26
26
  start(id: string): Promise<Sandbox>;
27
27
  stop(id: string): Promise<Sandbox>;
package/dist/MicroVM.js CHANGED
@@ -25,8 +25,8 @@ export class MicroVM {
25
25
  const sandbox = await this.client.create(options);
26
26
  return this.wrap(sandbox.toJSON());
27
27
  }
28
- async list() {
29
- const sandboxes = await this.client.list();
28
+ async list(options) {
29
+ const sandboxes = await this.client.list(options);
30
30
  return sandboxes.map((sandbox) => this.wrap(sandbox.toJSON()));
31
31
  }
32
32
  async get(id) {
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, RegisterSnapshotOptions, 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, Failover, FailoverPolicy, 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, RegisterSnapshotOptions, 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, Failover, HealthStatus, Lifecycle, ListOptions, 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
@@ -55,7 +55,7 @@ export declare class APIClient {
55
55
  */
56
56
  buildImage(image: Image, options?: BuildImageOptions): Promise<BuildImageResult>;
57
57
  private resolveImage;
58
- list(): Promise<SandboxResource[]>;
58
+ list(options?: ListOptions): Promise<SandboxResource[]>;
59
59
  get(id: string): Promise<SandboxResource>;
60
60
  start(id: string): Promise<SandboxResource>;
61
61
  stop(id: string): Promise<SandboxResource>;
@@ -126,6 +126,7 @@ export declare class SandboxResource implements Sandbox {
126
126
  lastError?: string;
127
127
  containerCommand?: string[];
128
128
  lifecycle: Lifecycle;
129
+ failover?: Failover;
129
130
  runtime: Sandbox["runtime"];
130
131
  protected readonly client: APIClient;
131
132
  constructor(client: APIClient, sandbox: Sandbox);
@@ -85,8 +85,9 @@ export class APIClient {
85
85
  const result = await this.buildImage(options.image);
86
86
  return { ...options, image: result.image };
87
87
  }
88
- async list() {
89
- const response = await this.doJSON("GET", this.versioned("/sandboxes"));
88
+ async list(options) {
89
+ const path = this.versioned("/sandboxes") + buildTagQuery(options?.tags);
90
+ const response = await this.doJSON("GET", path);
90
91
  return response.map((item) => this.wrap(item));
91
92
  }
92
93
  async get(id) {
@@ -387,6 +388,7 @@ function toApiCreateOptions(options) {
387
388
  container_command: options.containerCommand,
388
389
  mounts: options.mounts?.map(toApiMountSpec),
389
390
  lifecycle: options.lifecycle ? toApiLifecycle(options.lifecycle) : undefined,
391
+ failover: options.failover ? toApiFailover(options.failover) : undefined,
390
392
  runtime: options.runtime,
391
393
  };
392
394
  }
@@ -439,6 +441,11 @@ function toApiLifecycle(lifecycle) {
439
441
  destroy_at_age: lifecycle.destroyAtAge,
440
442
  };
441
443
  }
444
+ function toApiFailover(failover) {
445
+ return {
446
+ policy: failover.policy,
447
+ };
448
+ }
442
449
  function fromApiSandbox(sandbox) {
443
450
  return {
444
451
  id: sandbox.id,
@@ -462,6 +469,7 @@ function fromApiSandbox(sandbox) {
462
469
  lastError: sandbox.last_error,
463
470
  containerCommand: sandbox.container_command,
464
471
  lifecycle: fromApiLifecycle(sandbox.lifecycle),
472
+ failover: fromApiFailover(sandbox.failover),
465
473
  runtime: normalizeRuntime(sandbox.runtime),
466
474
  };
467
475
  }
@@ -608,6 +616,28 @@ function fromApiLifecycle(lifecycle) {
608
616
  }
609
617
  return result;
610
618
  }
619
+ function fromApiFailover(failover) {
620
+ const policy = failover?.policy;
621
+ if (policy !== "recreate" && policy !== "none") {
622
+ return undefined;
623
+ }
624
+ return { policy };
625
+ }
626
+ // buildTagQuery renders ListOptions.tags as the server's wire format. The
627
+ // `tag.` prefix is literal — the server's parseTagFilter does a prefix check
628
+ // on the *decoded* query key, so only the user-supplied key and value get
629
+ // percent-encoded. An empty or absent map returns "" so the request URL is
630
+ // byte-identical to the pre-filter call site (no trailing "?"), keeping
631
+ // fixtures and middleware that match on path stable.
632
+ function buildTagQuery(tags) {
633
+ if (!tags)
634
+ return "";
635
+ const entries = Object.entries(tags);
636
+ if (entries.length === 0)
637
+ return "";
638
+ const parts = entries.map(([key, value]) => `tag.${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
639
+ return "?" + parts.join("&");
640
+ }
611
641
  function cloneSandbox(sandbox) {
612
642
  return {
613
643
  ...sandbox,
@@ -615,6 +645,7 @@ function cloneSandbox(sandbox) {
615
645
  exposedPorts: sandbox.exposedPorts?.map((port) => ({ ...port })),
616
646
  containerCommand: sandbox.containerCommand ? [...sandbox.containerCommand] : undefined,
617
647
  lifecycle: { ...sandbox.lifecycle },
648
+ failover: sandbox.failover ? { ...sandbox.failover } : undefined,
618
649
  };
619
650
  }
620
651
  function toBlob(data) {
package/dist/types.d.ts CHANGED
@@ -75,6 +75,14 @@ export interface Lifecycle {
75
75
  destroyAtAge?: number;
76
76
  }
77
77
  export type UpdateLifecycleOptions = Lifecycle;
78
+ export type FailoverPolicy = "none" | "recreate";
79
+ export interface Failover {
80
+ /**
81
+ * "none" (default) returns 410 Gone after owner-node death. "recreate"
82
+ * opts into best-effort cluster recreation from the replicated create spec.
83
+ */
84
+ policy: FailoverPolicy;
85
+ }
78
86
  export type GPUVendor = "nvidia" | "amd" | "apple";
79
87
  export interface GPUOptions {
80
88
  /**
@@ -138,6 +146,7 @@ export interface CreateOptions {
138
146
  containerCommand?: string[];
139
147
  mounts?: MountSpec[];
140
148
  lifecycle?: Lifecycle;
149
+ failover?: Failover;
141
150
  /**
142
151
  * Container runtime to use for this sandbox. Omit to inherit the host
143
152
  * default (`SB_CONTAINER_RUNTIME`). Use `"gvisor"` for runsc-backed
@@ -161,6 +170,15 @@ export interface ResizeOptions {
161
170
  memoryMB?: number;
162
171
  diskGB?: number;
163
172
  }
173
+ export interface ListOptions {
174
+ /**
175
+ * Filter the result to only sandboxes whose `tags` map contains every
176
+ * key/value pair given here (AND semantics on the server). Wire format is
177
+ * `?tag.<key>=<value>`; the SDK URL-encodes keys and values for you. Omit
178
+ * or pass an empty map to list every sandbox visible to the PAT.
179
+ */
180
+ tags?: Record<string, string>;
181
+ }
164
182
  export interface CreateSessionOptions {
165
183
  name?: string;
166
184
  argv?: string[];
@@ -259,6 +277,7 @@ export interface Sandbox {
259
277
  lastError?: string;
260
278
  containerCommand?: string[];
261
279
  lifecycle: Lifecycle;
280
+ failover?: Failover;
262
281
  /**
263
282
  * Container runtime this sandbox is running under. Empty string indicates
264
283
  * a pre-migration row that resolves to the host default at start time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerol-ai/aerolvm-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,8 +21,8 @@
21
21
  "test": "tsc -p tsconfig.test.json --outDir dist-test && node --test dist-test/*.test.js dist-test/internal/*.test.js"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "^25.6.2",
24
+ "@types/node": "^25.8.0",
25
25
  "typescript": "^6.0.3",
26
- "tsx": "^4.21.0"
26
+ "tsx": "^4.22.3"
27
27
  }
28
28
  }