@aerol-ai/aerolvm-sdk 0.1.10 → 0.2.1

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) {
@@ -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, 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>;
@@ -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) {
@@ -608,6 +609,21 @@ function fromApiLifecycle(lifecycle) {
608
609
  }
609
610
  return result;
610
611
  }
612
+ // buildTagQuery renders ListOptions.tags as the server's wire format. The
613
+ // `tag.` prefix is literal — the server's parseTagFilter does a prefix check
614
+ // on the *decoded* query key, so only the user-supplied key and value get
615
+ // percent-encoded. An empty or absent map returns "" so the request URL is
616
+ // byte-identical to the pre-filter call site (no trailing "?"), keeping
617
+ // fixtures and middleware that match on path stable.
618
+ function buildTagQuery(tags) {
619
+ if (!tags)
620
+ return "";
621
+ const entries = Object.entries(tags);
622
+ if (entries.length === 0)
623
+ return "";
624
+ const parts = entries.map(([key, value]) => `tag.${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
625
+ return "?" + parts.join("&");
626
+ }
611
627
  function cloneSandbox(sandbox) {
612
628
  return {
613
629
  ...sandbox,
package/dist/types.d.ts CHANGED
@@ -161,6 +161,15 @@ export interface ResizeOptions {
161
161
  memoryMB?: number;
162
162
  diskGB?: number;
163
163
  }
164
+ export interface ListOptions {
165
+ /**
166
+ * Filter the result to only sandboxes whose `tags` map contains every
167
+ * key/value pair given here (AND semantics on the server). Wire format is
168
+ * `?tag.<key>=<value>`; the SDK URL-encodes keys and values for you. Omit
169
+ * or pass an empty map to list every sandbox visible to the PAT.
170
+ */
171
+ tags?: Record<string, string>;
172
+ }
164
173
  export interface CreateSessionOptions {
165
174
  name?: string;
166
175
  argv?: string[];
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.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",