@omnirun/sdk 0.5.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add Desktop class for GUI sandbox control (screenshot, mouse, keyboard, screen). Implement full E2EE payload encryption with AES-256-GCM. Add HTTP transport security warnings.
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -77,6 +77,38 @@ const metrics = await sbx.production.metrics();
77
77
  const snapshots = await sbx.production.metricsSnapshots();
78
78
  ```
79
79
 
80
+ ## LLM proxy
81
+
82
+ OpenAI-compatible LLM proxy with per-user spend tracking.
83
+
84
+ ```ts
85
+ import { LLM } from "@omnirun/sdk";
86
+
87
+ const llm = new LLM({ apiKey: process.env.OMNIRUN_API_KEY });
88
+
89
+ // Chat completion
90
+ const response = await llm.chatCompletion({
91
+ model: "gpt-4o",
92
+ messages: [{ role: "user", content: "Hello!" }],
93
+ });
94
+ console.log(response.choices[0].message.content);
95
+
96
+ // Streaming
97
+ for await (const chunk of llm.streamChatCompletion({
98
+ model: "gpt-4o",
99
+ messages: [{ role: "user", content: "Tell me a joke" }],
100
+ })) {
101
+ process.stdout.write(chunk);
102
+ }
103
+
104
+ // List available models
105
+ const models = await llm.listModels();
106
+
107
+ // Check spend / remaining credits
108
+ const usage = await llm.getUsage();
109
+ console.log(`Remaining: ${usage.remainingCents / 100} USD`);
110
+ ```
111
+
80
112
  ## Integration tests
81
113
 
82
114
  Integration tests are opt-in:
@@ -126,3 +158,4 @@ Protocol scaffold details: `docs/E2EE-PROTOCOL-SCAFFOLD.md`.
126
158
  - `Contexts`
127
159
  - `Production`
128
160
  - `Webhooks`
161
+ - `LLM`
package/dist/client.d.ts CHANGED
@@ -3,7 +3,9 @@ import type { StreamEvent } from "./models.js";
3
3
  /** Low-level HTTP transport for OmniRun API requests. */
4
4
  export declare class HTTPClient {
5
5
  private config;
6
+ private e2eeKey;
6
7
  constructor(config: ConnectionConfig);
8
+ setE2EEKey(key: CryptoKey): void;
7
9
  get baseUrl(): string;
8
10
  private get authHeaders();
9
11
  private get jsonHeaders();
@@ -22,6 +24,7 @@ export declare class HTTPClient {
22
24
  streamSSEWithSignal(path: string, params?: Record<string, string>, signal?: AbortSignal): AsyncGenerator<StreamEvent>;
23
25
  private buildUrl;
24
26
  private handle;
27
+ private handleWithDecrypt;
25
28
  private parseSSE;
26
29
  private errorMessage;
27
30
  }
package/dist/client.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { encryptE2EEJSON, decryptE2EEJSON } from "./e2ee.js";
1
2
  import { SandboxError, StreamError } from "./errors.js";
2
3
  /** Maximum number of retry attempts for retryable server errors. */
3
4
  const MAX_RETRIES = 2;
@@ -8,8 +9,17 @@ function isRetryable(status) {
8
9
  /** Low-level HTTP transport for OmniRun API requests. */
9
10
  export class HTTPClient {
10
11
  config;
12
+ e2eeKey = null;
11
13
  constructor(config) {
12
14
  this.config = config;
15
+ if (config.apiUrl.startsWith("http://") &&
16
+ !config.apiUrl.includes("localhost") &&
17
+ !config.apiUrl.includes("127.0.0.1")) {
18
+ console.warn("[omnirun] WARNING: API URL uses unencrypted HTTP. API keys will be sent in plaintext. Use HTTPS for production.");
19
+ }
20
+ }
21
+ setE2EEKey(key) {
22
+ this.e2eeKey = key;
13
23
  }
14
24
  get baseUrl() {
15
25
  return this.config.apiUrl;
@@ -31,10 +41,15 @@ export class HTTPClient {
31
41
  headers: this.authHeaders,
32
42
  signal: AbortSignal.timeout(this.config.requestTimeout),
33
43
  });
34
- return this.handle(resp);
44
+ return this.handleWithDecrypt(resp);
35
45
  }
36
46
  async post(path, body) {
37
- const jsonBody = body != null ? JSON.stringify(body) : undefined;
47
+ let actualBody = body;
48
+ if (this.e2eeKey && body != null) {
49
+ const envelope = await encryptE2EEJSON(this.e2eeKey, body);
50
+ actualBody = { _encrypted: envelope };
51
+ }
52
+ const jsonBody = actualBody != null ? JSON.stringify(actualBody) : undefined;
38
53
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
39
54
  const resp = await fetch(this.buildUrl(path), {
40
55
  method: "POST",
@@ -47,7 +62,7 @@ export class HTTPClient {
47
62
  await resp.text();
48
63
  continue;
49
64
  }
50
- return this.handle(resp);
65
+ return this.handleWithDecrypt(resp);
51
66
  }
52
67
  // Unreachable, but TypeScript needs it
53
68
  throw new SandboxError("max retries exceeded");
@@ -184,6 +199,13 @@ export class HTTPClient {
184
199
  }
185
200
  return (await resp.text());
186
201
  }
202
+ async handleWithDecrypt(resp) {
203
+ const data = await this.handle(resp);
204
+ if (this.e2eeKey && data && typeof data === "object" && "_encrypted" in data) {
205
+ return decryptE2EEJSON(this.e2eeKey, data._encrypted);
206
+ }
207
+ return data;
208
+ }
187
209
  async *parseSSE(resp) {
188
210
  if (!resp.ok) {
189
211
  throw new StreamError(`Stream error ${resp.status}: ${await this.errorMessage(resp)}`);
package/dist/commands.js CHANGED
@@ -1,6 +1,18 @@
1
1
  import { CommandHandle } from "./command-handle.js";
2
2
  import { CommandExitException } from "./errors.js";
3
3
  import { makeCommandResult } from "./utils.js";
4
+ function parseProcessInfo(p) {
5
+ return {
6
+ pid: p.pid ?? 0,
7
+ command: p.command ?? "",
8
+ running: p.running ?? false,
9
+ exitCode: p.exit_code ?? p.exitCode ?? 0,
10
+ stdout: p.stdout,
11
+ stderr: p.stderr,
12
+ startedAt: p.started_at ?? p.startedAt,
13
+ endedAt: p.ended_at ?? p.endedAt,
14
+ };
15
+ }
4
16
  /** Command execution namespace for a single sandbox. */
5
17
  export class Commands {
6
18
  sandboxId;
@@ -51,10 +63,13 @@ export class Commands {
51
63
  return result;
52
64
  }
53
65
  async list() {
54
- return this.client.get(this.baseUrl);
66
+ const data = await this.client.get(this.baseUrl);
67
+ const items = Array.isArray(data) ? data : [];
68
+ return items.map(parseProcessInfo);
55
69
  }
56
70
  async get(pid) {
57
- return this.client.get(`${this.baseUrl}/${pid}`);
71
+ const data = await this.client.get(`${this.baseUrl}/${pid}`);
72
+ return parseProcessInfo(data);
58
73
  }
59
74
  async kill(pid) {
60
75
  await this.client.delete(`${this.baseUrl}/${pid}`);
@@ -0,0 +1,72 @@
1
+ import type { HTTPClient } from "./client.js";
2
+ export interface ScreenInfo {
3
+ width: number;
4
+ height: number;
5
+ cursorX: number;
6
+ cursorY: number;
7
+ }
8
+ export interface DesktopStreamInfo {
9
+ novncPort: number;
10
+ vncPort: number;
11
+ wsPath: string;
12
+ }
13
+ export type MouseAction = "click" | "doubleClick" | "rightClick" | "move" | "drag" | "scroll";
14
+ export type ScrollDirection = "up" | "down" | "left" | "right";
15
+ export type KeyboardAction = "type" | "press";
16
+ export interface MouseOptions {
17
+ action: MouseAction;
18
+ x?: number;
19
+ y?: number;
20
+ endX?: number;
21
+ endY?: number;
22
+ direction?: ScrollDirection;
23
+ amount?: number;
24
+ }
25
+ export interface KeyboardOptions {
26
+ action: KeyboardAction;
27
+ text?: string;
28
+ key?: string;
29
+ }
30
+ /** Desktop control namespace for GUI sandboxes. */
31
+ export declare class Desktop {
32
+ private sandboxId;
33
+ private client;
34
+ constructor(sandboxId: string, client: HTTPClient);
35
+ private get baseUrl();
36
+ /** Capture a screenshot of the desktop as a PNG image. */
37
+ screenshot(): Promise<Uint8Array>;
38
+ /** Send a mouse action to the desktop. */
39
+ mouse(opts: MouseOptions): Promise<void>;
40
+ /** Send a keyboard action to the desktop. */
41
+ keyboard(opts: KeyboardOptions): Promise<void>;
42
+ /** Get current screen dimensions and cursor position. */
43
+ getScreen(): Promise<ScreenInfo>;
44
+ /** Get streaming connection info (noVNC / VNC ports and WebSocket path). */
45
+ getStreamInfo(): Promise<DesktopStreamInfo>;
46
+ /** Left-click at the given coordinates. */
47
+ leftClick(x: number, y: number): Promise<void>;
48
+ /** Right-click at the given coordinates. */
49
+ rightClick(x: number, y: number): Promise<void>;
50
+ /** Double-click at the given coordinates. */
51
+ doubleClick(x: number, y: number): Promise<void>;
52
+ /** Move the mouse cursor to the given coordinates. */
53
+ moveMouse(x: number, y: number): Promise<void>;
54
+ /** Drag from (startX, startY) to (endX, endY). */
55
+ drag(startX: number, startY: number, endX: number, endY: number): Promise<void>;
56
+ /** Scroll in a direction. */
57
+ scroll(direction: ScrollDirection, amount?: number): Promise<void>;
58
+ /** Type text character by character. */
59
+ type(text: string): Promise<void>;
60
+ /** Press a key or key combination (e.g. "Enter", "ctrl+c"). */
61
+ press(key: string): Promise<void>;
62
+ /** Get the current screen dimensions. */
63
+ getScreenSize(): Promise<{
64
+ width: number;
65
+ height: number;
66
+ }>;
67
+ /** Get the current cursor position. */
68
+ getCursorPosition(): Promise<{
69
+ x: number;
70
+ y: number;
71
+ }>;
72
+ }
@@ -0,0 +1,86 @@
1
+ /** Desktop control namespace for GUI sandboxes. */
2
+ export class Desktop {
3
+ sandboxId;
4
+ client;
5
+ constructor(sandboxId, client) {
6
+ this.sandboxId = sandboxId;
7
+ this.client = client;
8
+ }
9
+ get baseUrl() {
10
+ return `/sandboxes/${this.sandboxId}/desktop`;
11
+ }
12
+ /** Capture a screenshot of the desktop as a PNG image. */
13
+ async screenshot() {
14
+ return this.client.download(`${this.baseUrl}/screenshot`);
15
+ }
16
+ /** Send a mouse action to the desktop. */
17
+ async mouse(opts) {
18
+ await this.client.post(`${this.baseUrl}/mouse`, opts);
19
+ }
20
+ /** Send a keyboard action to the desktop. */
21
+ async keyboard(opts) {
22
+ await this.client.post(`${this.baseUrl}/keyboard`, opts);
23
+ }
24
+ /** Get current screen dimensions and cursor position. */
25
+ async getScreen() {
26
+ const data = await this.client.get(`${this.baseUrl}/screen`);
27
+ return {
28
+ width: data.width ?? 0,
29
+ height: data.height ?? 0,
30
+ cursorX: data.cursorX ?? 0,
31
+ cursorY: data.cursorY ?? 0,
32
+ };
33
+ }
34
+ /** Get streaming connection info (noVNC / VNC ports and WebSocket path). */
35
+ async getStreamInfo() {
36
+ const data = await this.client.get(`${this.baseUrl}/stream`);
37
+ return {
38
+ novncPort: data.novncPort ?? 0,
39
+ vncPort: data.vncPort ?? 0,
40
+ wsPath: data.wsPath ?? "",
41
+ };
42
+ }
43
+ // ── Convenience methods (E2B parity) ──────────────────────────────────
44
+ /** Left-click at the given coordinates. */
45
+ async leftClick(x, y) {
46
+ await this.mouse({ action: "click", x, y });
47
+ }
48
+ /** Right-click at the given coordinates. */
49
+ async rightClick(x, y) {
50
+ await this.mouse({ action: "rightClick", x, y });
51
+ }
52
+ /** Double-click at the given coordinates. */
53
+ async doubleClick(x, y) {
54
+ await this.mouse({ action: "doubleClick", x, y });
55
+ }
56
+ /** Move the mouse cursor to the given coordinates. */
57
+ async moveMouse(x, y) {
58
+ await this.mouse({ action: "move", x, y });
59
+ }
60
+ /** Drag from (startX, startY) to (endX, endY). */
61
+ async drag(startX, startY, endX, endY) {
62
+ await this.mouse({ action: "drag", x: startX, y: startY, endX, endY });
63
+ }
64
+ /** Scroll in a direction. */
65
+ async scroll(direction, amount) {
66
+ await this.mouse({ action: "scroll", direction, amount });
67
+ }
68
+ /** Type text character by character. */
69
+ async type(text) {
70
+ await this.keyboard({ action: "type", text });
71
+ }
72
+ /** Press a key or key combination (e.g. "Enter", "ctrl+c"). */
73
+ async press(key) {
74
+ await this.keyboard({ action: "press", key });
75
+ }
76
+ /** Get the current screen dimensions. */
77
+ async getScreenSize() {
78
+ const screen = await this.getScreen();
79
+ return { width: screen.width, height: screen.height };
80
+ }
81
+ /** Get the current cursor position. */
82
+ async getCursorPosition() {
83
+ const screen = await this.getScreen();
84
+ return { x: screen.cursorX, y: screen.cursorY };
85
+ }
86
+ }
@@ -1,14 +1,65 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { CreateExposureOptions, ExposureInfo, RefreshExposureOptions } from "./models.js";
3
- /** Preview URL management namespace for a sandbox. */
3
+ /**
4
+ * Preview URL management namespace for a sandbox.
5
+ *
6
+ * An exposure creates a publicly (or privately) accessible URL that proxies
7
+ * traffic to a port inside the sandbox. The lifecycle of an exposure is:
8
+ *
9
+ * `pending` -> `ready` -> `expired` | `revoked` | `sandbox_stopped`
10
+ *
11
+ * - **pending**: The exposure has been requested but the proxy is not yet routing traffic.
12
+ * - **ready**: The URL is live and accepting requests.
13
+ * - **expired**: The TTL elapsed without a refresh.
14
+ * - **revoked**: The exposure was explicitly closed via {@link close}.
15
+ * - **sandbox_stopped**: The parent sandbox was killed or stopped.
16
+ */
4
17
  export declare class Exposures {
5
18
  private sandboxId;
6
19
  private client;
7
20
  constructor(sandboxId: string, client: HTTPClient);
8
21
  private get baseUrl();
22
+ /**
23
+ * Create a new exposure for a sandbox port.
24
+ *
25
+ * @param port - The port number inside the sandbox to expose (1-65535).
26
+ * @param opts - Optional configuration.
27
+ * @param opts.visibility - `"public"` (default) or `"private"` (requires auth token).
28
+ * @param opts.ttlSeconds - Time-to-live in seconds before the exposure expires.
29
+ * @param opts.slug - Custom slug for the exposure URL.
30
+ * @param opts.openPath - Path appended to the exposure URL when opened in a browser.
31
+ * @param opts.preserveHost - Whether to preserve the original `Host` header when proxying.
32
+ * @returns The created {@link ExposureInfo}.
33
+ */
9
34
  create(port: number, opts?: CreateExposureOptions): Promise<ExposureInfo>;
35
+ /**
36
+ * List all exposures for this sandbox.
37
+ *
38
+ * @returns An array of {@link ExposureInfo} objects for every exposure
39
+ * (including expired and revoked ones).
40
+ */
10
41
  list(): Promise<ExposureInfo[]>;
42
+ /**
43
+ * Get details for a single exposure.
44
+ *
45
+ * @param exposureId - The unique exposure identifier.
46
+ * @returns The {@link ExposureInfo} for the requested exposure.
47
+ */
11
48
  get(exposureId: string): Promise<ExposureInfo>;
49
+ /**
50
+ * Extend the TTL of an existing exposure, preventing it from expiring.
51
+ *
52
+ * @param exposureId - The unique exposure identifier.
53
+ * @param opts - Optional refresh options.
54
+ * @param opts.ttlSeconds - New TTL in seconds from now. If omitted the server default is used.
55
+ * @returns The updated {@link ExposureInfo} with the new `expiresAt` timestamp.
56
+ */
12
57
  refresh(exposureId: string, opts?: RefreshExposureOptions): Promise<ExposureInfo>;
58
+ /**
59
+ * Permanently close and revoke an exposure. The URL will immediately
60
+ * stop accepting traffic. This action cannot be undone.
61
+ *
62
+ * @param exposureId - The unique exposure identifier.
63
+ */
13
64
  close(exposureId: string): Promise<void>;
14
65
  }
package/dist/exposures.js CHANGED
@@ -19,7 +19,20 @@ function parseExposureInfo(data) {
19
19
  createdBy: data.createdBy,
20
20
  };
21
21
  }
22
- /** Preview URL management namespace for a sandbox. */
22
+ /**
23
+ * Preview URL management namespace for a sandbox.
24
+ *
25
+ * An exposure creates a publicly (or privately) accessible URL that proxies
26
+ * traffic to a port inside the sandbox. The lifecycle of an exposure is:
27
+ *
28
+ * `pending` -> `ready` -> `expired` | `revoked` | `sandbox_stopped`
29
+ *
30
+ * - **pending**: The exposure has been requested but the proxy is not yet routing traffic.
31
+ * - **ready**: The URL is live and accepting requests.
32
+ * - **expired**: The TTL elapsed without a refresh.
33
+ * - **revoked**: The exposure was explicitly closed via {@link close}.
34
+ * - **sandbox_stopped**: The parent sandbox was killed or stopped.
35
+ */
23
36
  export class Exposures {
24
37
  sandboxId;
25
38
  client;
@@ -30,6 +43,18 @@ export class Exposures {
30
43
  get baseUrl() {
31
44
  return `/sandboxes/${this.sandboxId}/exposures`;
32
45
  }
46
+ /**
47
+ * Create a new exposure for a sandbox port.
48
+ *
49
+ * @param port - The port number inside the sandbox to expose (1-65535).
50
+ * @param opts - Optional configuration.
51
+ * @param opts.visibility - `"public"` (default) or `"private"` (requires auth token).
52
+ * @param opts.ttlSeconds - Time-to-live in seconds before the exposure expires.
53
+ * @param opts.slug - Custom slug for the exposure URL.
54
+ * @param opts.openPath - Path appended to the exposure URL when opened in a browser.
55
+ * @param opts.preserveHost - Whether to preserve the original `Host` header when proxying.
56
+ * @returns The created {@link ExposureInfo}.
57
+ */
33
58
  async create(port, opts) {
34
59
  const data = await this.client.post(this.baseUrl, {
35
60
  port,
@@ -41,21 +66,47 @@ export class Exposures {
41
66
  });
42
67
  return parseExposureInfo(data);
43
68
  }
69
+ /**
70
+ * List all exposures for this sandbox.
71
+ *
72
+ * @returns An array of {@link ExposureInfo} objects for every exposure
73
+ * (including expired and revoked ones).
74
+ */
44
75
  async list() {
45
76
  const data = await this.client.get(this.baseUrl);
46
77
  const items = Array.isArray(data) ? data : [];
47
78
  return items.map(parseExposureInfo);
48
79
  }
80
+ /**
81
+ * Get details for a single exposure.
82
+ *
83
+ * @param exposureId - The unique exposure identifier.
84
+ * @returns The {@link ExposureInfo} for the requested exposure.
85
+ */
49
86
  async get(exposureId) {
50
87
  const data = await this.client.get(`${this.baseUrl}/${exposureId}`);
51
88
  return parseExposureInfo(data);
52
89
  }
90
+ /**
91
+ * Extend the TTL of an existing exposure, preventing it from expiring.
92
+ *
93
+ * @param exposureId - The unique exposure identifier.
94
+ * @param opts - Optional refresh options.
95
+ * @param opts.ttlSeconds - New TTL in seconds from now. If omitted the server default is used.
96
+ * @returns The updated {@link ExposureInfo} with the new `expiresAt` timestamp.
97
+ */
53
98
  async refresh(exposureId, opts) {
54
99
  const data = await this.client.post(`${this.baseUrl}/${exposureId}/refresh`, {
55
100
  requestedTtlSeconds: opts?.ttlSeconds,
56
101
  });
57
102
  return parseExposureInfo(data);
58
103
  }
104
+ /**
105
+ * Permanently close and revoke an exposure. The URL will immediately
106
+ * stop accepting traffic. This action cannot be undone.
107
+ *
108
+ * @param exposureId - The unique exposure identifier.
109
+ */
59
110
  async close(exposureId) {
60
111
  await this.client.delete(`${this.baseUrl}/${exposureId}`);
61
112
  }
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export { CommandHandle } from "./command-handle.js";
5
5
  export { Filesystem } from "./filesystem.js";
6
6
  export { Pty, PtySession } from "./pty.js";
7
7
  export { Contexts } from "./contexts.js";
8
+ export { Desktop } from "./desktop.js";
9
+ export type { ScreenInfo, DesktopStreamInfo, MouseOptions, KeyboardOptions, MouseAction, ScrollDirection, KeyboardAction, } from "./desktop.js";
8
10
  export { Exposures } from "./exposures.js";
9
11
  export { Production } from "./production.js";
10
12
  export { Webhooks } from "./webhooks.js";
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export { CommandHandle } from "./command-handle.js";
5
5
  export { Filesystem } from "./filesystem.js";
6
6
  export { Pty, PtySession } from "./pty.js";
7
7
  export { Contexts } from "./contexts.js";
8
+ export { Desktop } from "./desktop.js";
8
9
  export { Exposures } from "./exposures.js";
9
10
  export { Production } from "./production.js";
10
11
  export { Webhooks } from "./webhooks.js";
package/dist/models.d.ts CHANGED
@@ -61,23 +61,41 @@ export interface FullSandboxInfo extends SandboxInfo {
61
61
  }
62
62
  export type ExposureVisibility = "public" | "private";
63
63
  export type ExposureStatus = "pending" | "ready" | "revoked" | "expired" | "sandbox_stopped" | "error";
64
+ /** Detailed information about a sandbox port exposure (preview URL). */
64
65
  export interface ExposureInfo {
66
+ /** Unique exposure identifier. */
65
67
  id: string;
68
+ /** ID of the parent sandbox. */
66
69
  sandboxId: string;
70
+ /** Account that owns the exposure. */
67
71
  accountId?: string;
72
+ /** Sandbox-internal port being exposed. */
68
73
  port: number;
74
+ /** Hostname of the exposure proxy. */
69
75
  hostname: string;
76
+ /** Full public URL for the exposure. */
70
77
  url: string;
78
+ /** URL with embedded access token for private exposures. */
71
79
  accessUrl?: string;
80
+ /** Visibility level: `"public"` or `"private"`. */
72
81
  visibility: ExposureVisibility;
82
+ /** Current lifecycle status of the exposure. */
73
83
  status: ExposureStatus;
84
+ /** ISO-8601 timestamp when the exposure was created. */
74
85
  createdAt: string;
86
+ /** ISO-8601 timestamp when the exposure will expire. */
75
87
  expiresAt: string;
88
+ /** ISO-8601 timestamp when the exposure was revoked, if applicable. */
76
89
  revokedAt?: string;
90
+ /** ISO-8601 timestamp when the parent sandbox stopped, if applicable. */
77
91
  sandboxStoppedAt?: string;
92
+ /** ISO-8601 timestamp of the last proxied request. */
78
93
  lastAccessedAt?: string;
94
+ /** Default path appended to the URL when opened in a browser. */
79
95
  openPath?: string;
96
+ /** Whether the original `Host` header is preserved when proxying. */
80
97
  preserveHost: boolean;
98
+ /** Identifier of the user or API key that created the exposure. */
81
99
  createdBy?: string;
82
100
  }
83
101
  export interface CreateExposureOptions {
@@ -100,20 +118,38 @@ export interface RunCommandOptions {
100
118
  onStderr?: (data: string) => void;
101
119
  }
102
120
  export interface CreateSandboxOptions {
121
+ /** Sandbox timeout in seconds. Default varies by template (typically 300). Use `0` for a permanent sandbox. */
103
122
  timeout?: number;
123
+ /** OmniRun API key. Falls back to `OMNIRUN_API_KEY` environment variable. */
104
124
  apiKey?: string;
125
+ /** OmniRun API base URL. Falls back to `OMNIRUN_API_URL` environment variable. */
105
126
  apiUrl?: string;
127
+ /** HTTP request timeout in milliseconds for SDK-to-API calls. */
106
128
  requestTimeout?: number;
129
+ /** Enable outbound internet access from the sandbox. Default: `false`. */
107
130
  internet?: boolean;
131
+ /** Memory allocation in MB. Overrides the template default when set. */
132
+ memory?: number;
133
+ /** Environment variables injected into the sandbox at creation time. */
108
134
  envVars?: Record<string, string>;
135
+ /** Arbitrary key-value metadata attached to the sandbox. Queryable via `list()`. */
109
136
  metadata?: Record<string, string>;
137
+ /** Heartbeat interval in seconds. The SDK sends periodic `setTimeout` calls to prevent auto-kill. */
110
138
  keepAlive?: number;
139
+ /** Auto-pause the sandbox after a period of inactivity instead of killing it. */
111
140
  autoPause?: boolean;
141
+ /** Network policy controlling allowed/denied domains and IPs for outbound traffic. */
112
142
  network?: NetworkPolicy;
143
+ /** Enable E2E encrypted mode for the sandbox. */
113
144
  secure?: boolean;
145
+ /** Mask the request `Host` header seen inside the sandbox with this value. */
114
146
  maskRequestHost?: string;
115
- /** Client-side E2EE bootstrap options (key generation + public key announcement). */
147
+ /** Inject vault credentials into the sandbox as environment variables via `/tmp/.omnirun-env`. */
148
+ vaultInject?: boolean;
149
+ /** Client-side E2EE bootstrap options (key generation + public key announcement). Pass `true` for defaults. */
116
150
  e2ee?: boolean | E2EECreateOptions;
151
+ /** Domain used for sandbox preview URLs (e.g. `"omnirun-preview.dev"`). Falls back to `OMNIRUN_PREVIEW_DOMAIN` env var, then `"claudebox.io"`. */
152
+ previewDomain?: string;
117
153
  }
118
154
  export interface ListSandboxOptions {
119
155
  apiKey?: string;
@@ -149,19 +185,32 @@ export interface ExecutionResult {
149
185
  error?: string;
150
186
  executionCount?: number;
151
187
  }
188
+ /** Aggregated usage metrics for a sandbox. */
152
189
  export interface SandboxMetrics {
190
+ /** Total CPU time consumed in milliseconds. */
153
191
  cpuTimeMs: number;
192
+ /** Current memory usage in megabytes. */
154
193
  memoryUsedMb: number;
194
+ /** Current disk usage in megabytes. */
155
195
  diskUsedMb: number;
196
+ /** Network bytes received in kilobytes. */
156
197
  networkRxKb: number;
198
+ /** Network bytes transmitted in kilobytes. */
157
199
  networkTxKb: number;
200
+ /** Number of commands executed in the sandbox. */
158
201
  commandCount: number;
202
+ /** Human-readable uptime string or ISO-8601 timestamp. */
159
203
  uptime: string;
160
204
  }
205
+ /** Network policy controlling outbound traffic from a sandbox. */
161
206
  export interface NetworkPolicy {
207
+ /** Domains the sandbox is allowed to reach. If set, only these domains are permitted. */
162
208
  allowDomains?: string[];
209
+ /** Domains the sandbox is explicitly blocked from reaching. */
163
210
  denyDomains?: string[];
211
+ /** IP addresses or CIDR ranges the sandbox is allowed to reach. */
164
212
  allowIPs?: string[];
213
+ /** IP addresses or CIDR ranges the sandbox is explicitly blocked from reaching. */
165
214
  denyIPs?: string[];
166
215
  }
167
216
  export interface WebhookInfo {
@@ -174,12 +223,20 @@ export interface CodeResult {
174
223
  stderr: string;
175
224
  exitCode: number;
176
225
  }
226
+ /** A single point-in-time metrics snapshot from the sandbox time-series. */
177
227
  export interface MetricsSnapshot {
228
+ /** ISO-8601 timestamp of the snapshot. */
178
229
  timestamp: string;
230
+ /** CPU utilization as a percentage (0-100). */
179
231
  cpuUsedPct: number;
232
+ /** Number of virtual CPUs allocated to the sandbox. */
180
233
  cpuCount: number;
234
+ /** Memory currently used in bytes. */
181
235
  memUsed: number;
236
+ /** Total memory available in bytes. */
182
237
  memTotal: number;
238
+ /** Disk space currently used in bytes. */
183
239
  diskUsed: number;
240
+ /** Total disk space available in bytes. */
184
241
  diskTotal: number;
185
242
  }
@@ -1,5 +1,7 @@
1
1
  import type { HTTPClient } from "./client.js";
2
2
  import type { MetricsSnapshot, NetworkPolicy, SandboxMetrics } from "./models.js";
3
+ /** Map a raw metrics snapshot from the API (snake_case) to a {@link MetricsSnapshot}. */
4
+ export declare function parseMetricsSnapshot(m: any): MetricsSnapshot;
3
5
  /** Production controls for pause/resume/metrics/network policy. */
4
6
  export declare class Production {
5
7
  private sandboxId;
@@ -1,3 +1,15 @@
1
+ /** Map a raw metrics snapshot from the API (snake_case) to a {@link MetricsSnapshot}. */
2
+ export function parseMetricsSnapshot(m) {
3
+ return {
4
+ timestamp: m.timestamp ?? "",
5
+ cpuUsedPct: m.cpu_used_pct ?? 0,
6
+ cpuCount: m.cpu_count ?? 0,
7
+ memUsed: m.mem_used ?? 0,
8
+ memTotal: m.mem_total ?? 0,
9
+ diskUsed: m.disk_used ?? 0,
10
+ diskTotal: m.disk_total ?? 0,
11
+ };
12
+ }
1
13
  /** Production controls for pause/resume/metrics/network policy. */
2
14
  export class Production {
3
15
  sandboxId;
@@ -48,15 +60,7 @@ export class Production {
48
60
  const data = await this.client.get(`${this.baseUrl}/metrics`);
49
61
  if (!Array.isArray(data))
50
62
  return [];
51
- return data.map((m) => ({
52
- timestamp: m.timestamp ?? "",
53
- cpuUsedPct: m.cpu_used_pct ?? 0,
54
- cpuCount: m.cpu_count ?? 0,
55
- memUsed: m.mem_used ?? 0,
56
- memTotal: m.mem_total ?? 0,
57
- diskUsed: m.disk_used ?? 0,
58
- diskTotal: m.disk_total ?? 0,
59
- }));
63
+ return data.map(parseMetricsSnapshot);
60
64
  }
61
65
  /** Set network policy for the sandbox. */
62
66
  async setNetworkPolicy(policy) {
package/dist/sandbox.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Commands } from "./commands.js";
2
2
  import { Contexts } from "./contexts.js";
3
3
  import { type E2EESessionInfo } from "./e2ee.js";
4
4
  import { Filesystem } from "./filesystem.js";
5
+ import { Desktop } from "./desktop.js";
5
6
  import { Exposures } from "./exposures.js";
6
7
  import type { CodeResult, CreateSandboxOptions, CreateExposureOptions, ExposureInfo, FullSandboxInfo, ListSandboxOptions, MetricsSnapshot, NetworkPolicy, SandboxInfo } from "./models.js";
7
8
  import { Production } from "./production.js";
@@ -29,25 +30,98 @@ export declare class Sandbox {
29
30
  readonly files: Filesystem;
30
31
  readonly pty: Pty;
31
32
  readonly contexts: Contexts;
33
+ readonly desktop: Desktop;
32
34
  readonly exposures: Exposures;
33
35
  readonly production: Production;
34
36
  readonly webhooks: Webhooks;
35
37
  e2ee: E2EESessionInfo | null;
36
38
  trafficAccessToken: string;
37
39
  private client;
40
+ private previewDomain;
38
41
  private keepAliveInterval;
39
42
  private constructor();
43
+ /**
44
+ * Create a new sandbox from a template.
45
+ *
46
+ * @param template - Template identifier (e.g. `"python-3.11"`, `"node-20"`). Defaults to `"python-3.11"`.
47
+ * @param opts - Creation options.
48
+ * @param opts.timeout - Sandbox timeout in seconds. Default `300`. Use `0` for a permanent sandbox.
49
+ * @param opts.apiKey - API key. Falls back to `OMNIRUN_API_KEY` env var.
50
+ * @param opts.apiUrl - API base URL. Falls back to `OMNIRUN_API_URL` env var.
51
+ * @param opts.internet - Enable outbound internet access.
52
+ * @param opts.envVars - Environment variables injected into the sandbox.
53
+ * @param opts.metadata - Arbitrary key-value metadata attached to the sandbox.
54
+ * @param opts.secure - Enable E2E encrypted mode.
55
+ * @param opts.maskRequestHost - Mask the request host header.
56
+ * @param opts.autoPause - Auto-pause the sandbox after inactivity.
57
+ * @param opts.keepAlive - Heartbeat interval in seconds to prevent auto-kill.
58
+ * @param opts.network - Network policy (allow/deny domains and IPs).
59
+ * @param opts.e2ee - E2EE bootstrap options or `true` for defaults.
60
+ * @param opts.vaultInject - Inject vault credentials as env vars via `/tmp/.omnirun-env`.
61
+ * @param opts.requestTimeout - HTTP request timeout in milliseconds.
62
+ * @returns A connected {@link Sandbox} instance.
63
+ */
40
64
  static create(template?: string, opts?: CreateSandboxOptions): Promise<Sandbox>;
65
+ /**
66
+ * Connect to an existing, already-running sandbox by its ID.
67
+ *
68
+ * Use this instead of {@link create} when you already have a sandbox ID
69
+ * (e.g. from a previous session, webhook payload, or database record).
70
+ *
71
+ * @param sandboxId - The unique sandbox identifier.
72
+ * @param opts - Connection options (apiKey, apiUrl, requestTimeout).
73
+ * @returns A connected {@link Sandbox} instance.
74
+ * @throws {SandboxNotFoundError} If the sandbox does not exist or has been killed.
75
+ */
41
76
  static connect(sandboxId: string, opts?: {
42
77
  apiKey?: string;
43
78
  apiUrl?: string;
44
79
  requestTimeout?: number;
80
+ previewDomain?: string;
45
81
  }): Promise<Sandbox>;
82
+ /**
83
+ * List sandboxes for the authenticated account.
84
+ *
85
+ * @param opts - Filter and pagination options (limit, nextToken, state, metadata).
86
+ * @returns An array of {@link SandboxInfo} objects.
87
+ */
46
88
  static list(opts?: ListSandboxOptions): Promise<SandboxInfo[]>;
89
+ /**
90
+ * Return a cursor-based paginator for listing sandboxes.
91
+ *
92
+ * Call {@link SandboxPaginator.nextItems} repeatedly until
93
+ * {@link SandboxPaginator.hasNext} is `false` to iterate through all pages.
94
+ *
95
+ * @param opts - Filter and pagination options.
96
+ * @returns A {@link SandboxPaginator} instance.
97
+ */
47
98
  static paginate(opts?: ListSandboxOptions): SandboxPaginator;
99
+ /**
100
+ * Permanently destroy the sandbox. This is irreversible — the sandbox
101
+ * cannot be resumed or reconnected after being killed.
102
+ * Also clears any active keep-alive heartbeat.
103
+ */
48
104
  kill(): Promise<void>;
105
+ /**
106
+ * Reset the sandbox auto-kill timer.
107
+ *
108
+ * @param timeout - New timeout value in seconds. The sandbox will be killed
109
+ * after this many seconds of wall-clock time unless the timer is reset again.
110
+ */
49
111
  setTimeout(timeout: number): Promise<void>;
112
+ /**
113
+ * Check whether the sandbox is currently in the `"running"` state.
114
+ *
115
+ * Makes a GET request to the sandbox info endpoint. Returns `false` if the
116
+ * sandbox does not exist, has been killed, or is in any non-running state.
117
+ */
50
118
  isRunning(): Promise<boolean>;
119
+ /**
120
+ * Retrieve detailed information about the sandbox.
121
+ *
122
+ * @returns A {@link FullSandboxInfo} object containing state, CPU count,
123
+ * memory, template ID, and timestamps.
124
+ */
51
125
  getInfo(): Promise<FullSandboxInfo>;
52
126
  /** Execute code via the /code endpoint. */
53
127
  runCode(code: string, language?: string): Promise<CodeResult>;
@@ -59,9 +133,18 @@ export declare class Sandbox {
59
133
  downloadUrl(path: string): Promise<string>;
60
134
  /** Get a pre-signed upload URL for a file. */
61
135
  uploadUrl(path: string): Promise<string>;
136
+ /**
137
+ * Pause the sandbox VM. A paused sandbox retains its state on disk and can
138
+ * be resumed later with {@link resume}. Use this for production sandboxes
139
+ * that need to survive periods of inactivity without being killed.
140
+ */
62
141
  pause(): Promise<{
63
142
  status: string;
64
143
  }>;
144
+ /**
145
+ * Resume a previously paused sandbox. The VM is restored from its
146
+ * saved state and continues running where it left off.
147
+ */
65
148
  resume(): Promise<{
66
149
  status: string;
67
150
  }>;
package/dist/sandbox.js CHANGED
@@ -2,10 +2,11 @@ import { HTTPClient } from "./client.js";
2
2
  import { Commands } from "./commands.js";
3
3
  import { resolveConfig } from "./config.js";
4
4
  import { Contexts } from "./contexts.js";
5
- import { generateE2EEKeyPair, } from "./e2ee.js";
5
+ import { deriveE2EESharedKey, generateE2EEKeyPair, } from "./e2ee.js";
6
6
  import { Filesystem } from "./filesystem.js";
7
+ import { Desktop } from "./desktop.js";
7
8
  import { Exposures } from "./exposures.js";
8
- import { Production } from "./production.js";
9
+ import { parseMetricsSnapshot, Production } from "./production.js";
9
10
  import { Pty } from "./pty.js";
10
11
  import { makeCommandResult } from "./utils.js";
11
12
  import { Webhooks } from "./webhooks.js";
@@ -15,8 +16,7 @@ function encodeMetadataFilter(metadata) {
15
16
  const entries = Object.entries(metadata);
16
17
  if (entries.length === 0)
17
18
  return undefined;
18
- const [key, value] = entries[0];
19
- return `${key}:${value}`;
19
+ return entries.map(([key, value]) => `${key}:${value}`).join(",");
20
20
  }
21
21
  function parseSandboxInfo(s) {
22
22
  return {
@@ -97,24 +97,51 @@ export class Sandbox {
97
97
  files;
98
98
  pty;
99
99
  contexts;
100
+ desktop;
100
101
  exposures;
101
102
  production;
102
103
  webhooks;
103
104
  e2ee = null;
104
105
  trafficAccessToken = "";
105
106
  client;
107
+ previewDomain;
106
108
  keepAliveInterval = null;
107
- constructor(sandboxId, client) {
109
+ constructor(sandboxId, client, previewDomain) {
108
110
  this.sandboxId = sandboxId;
109
111
  this.client = client;
112
+ this.previewDomain = previewDomain
113
+ || (typeof process !== "undefined" ? process.env.OMNIRUN_PREVIEW_DOMAIN : undefined)
114
+ || "claudebox.io";
110
115
  this.commands = new Commands(sandboxId, client);
111
116
  this.files = new Filesystem(sandboxId, client);
112
117
  this.pty = new Pty(sandboxId, client);
113
118
  this.contexts = new Contexts(sandboxId, client);
119
+ this.desktop = new Desktop(sandboxId, client);
114
120
  this.exposures = new Exposures(sandboxId, client);
115
121
  this.production = new Production(sandboxId, client);
116
122
  this.webhooks = new Webhooks(client);
117
123
  }
124
+ /**
125
+ * Create a new sandbox from a template.
126
+ *
127
+ * @param template - Template identifier (e.g. `"python-3.11"`, `"node-20"`). Defaults to `"python-3.11"`.
128
+ * @param opts - Creation options.
129
+ * @param opts.timeout - Sandbox timeout in seconds. Default `300`. Use `0` for a permanent sandbox.
130
+ * @param opts.apiKey - API key. Falls back to `OMNIRUN_API_KEY` env var.
131
+ * @param opts.apiUrl - API base URL. Falls back to `OMNIRUN_API_URL` env var.
132
+ * @param opts.internet - Enable outbound internet access.
133
+ * @param opts.envVars - Environment variables injected into the sandbox.
134
+ * @param opts.metadata - Arbitrary key-value metadata attached to the sandbox.
135
+ * @param opts.secure - Enable E2E encrypted mode.
136
+ * @param opts.maskRequestHost - Mask the request host header.
137
+ * @param opts.autoPause - Auto-pause the sandbox after inactivity.
138
+ * @param opts.keepAlive - Heartbeat interval in seconds to prevent auto-kill.
139
+ * @param opts.network - Network policy (allow/deny domains and IPs).
140
+ * @param opts.e2ee - E2EE bootstrap options or `true` for defaults.
141
+ * @param opts.vaultInject - Inject vault credentials as env vars via `/tmp/.omnirun-env`.
142
+ * @param opts.requestTimeout - HTTP request timeout in milliseconds.
143
+ * @returns A connected {@link Sandbox} instance.
144
+ */
118
145
  static async create(template = "python-3.11", opts) {
119
146
  const config = resolveConfig({
120
147
  apiUrl: opts?.apiUrl,
@@ -149,8 +176,10 @@ export class Sandbox {
149
176
  body.secure = true;
150
177
  if (opts?.maskRequestHost)
151
178
  body.maskRequestHost = opts.maskRequestHost;
179
+ if (opts?.vaultInject)
180
+ body.vaultInject = true;
152
181
  const data = await client.post("/sandboxes", body);
153
- const sandbox = new Sandbox(data.sandboxID, client);
182
+ const sandbox = new Sandbox(data.sandboxID, client, opts?.previewDomain);
154
183
  sandbox.trafficAccessToken = data.trafficToken ?? "";
155
184
  if (e2eeOpts?.enabled && clientPublicKey) {
156
185
  sandbox.e2ee = {
@@ -160,6 +189,10 @@ export class Sandbox {
160
189
  serverPublicKey: data.serverPublicKey ?? data.e2ee?.serverPublicKey,
161
190
  };
162
191
  }
192
+ if (sandbox.e2ee?.enabled && sandbox.e2ee.clientKeyPair && sandbox.e2ee.serverPublicKey) {
193
+ const sharedKey = await deriveE2EESharedKey(sandbox.e2ee.clientKeyPair.privateKey, sandbox.e2ee.serverPublicKey);
194
+ client.setE2EEKey(sharedKey);
195
+ }
163
196
  if (opts?.keepAlive != null) {
164
197
  const interval = opts.keepAlive;
165
198
  const timeout = opts.timeout ?? 300;
@@ -174,12 +207,29 @@ export class Sandbox {
174
207
  }
175
208
  return sandbox;
176
209
  }
210
+ /**
211
+ * Connect to an existing, already-running sandbox by its ID.
212
+ *
213
+ * Use this instead of {@link create} when you already have a sandbox ID
214
+ * (e.g. from a previous session, webhook payload, or database record).
215
+ *
216
+ * @param sandboxId - The unique sandbox identifier.
217
+ * @param opts - Connection options (apiKey, apiUrl, requestTimeout).
218
+ * @returns A connected {@link Sandbox} instance.
219
+ * @throws {SandboxNotFoundError} If the sandbox does not exist or has been killed.
220
+ */
177
221
  static async connect(sandboxId, opts) {
178
222
  const config = resolveConfig(opts);
179
223
  const client = new HTTPClient(config);
180
224
  await client.get(`/sandboxes/${sandboxId}`);
181
- return new Sandbox(sandboxId, client);
225
+ return new Sandbox(sandboxId, client, opts?.previewDomain);
182
226
  }
227
+ /**
228
+ * List sandboxes for the authenticated account.
229
+ *
230
+ * @param opts - Filter and pagination options (limit, nextToken, state, metadata).
231
+ * @returns An array of {@link SandboxInfo} objects.
232
+ */
183
233
  static async list(opts) {
184
234
  const config = resolveConfig(opts);
185
235
  const client = new HTTPClient(config);
@@ -197,9 +247,23 @@ export class Sandbox {
197
247
  const sandboxes = Array.isArray(data) ? data : [];
198
248
  return sandboxes.map(parseSandboxInfo);
199
249
  }
250
+ /**
251
+ * Return a cursor-based paginator for listing sandboxes.
252
+ *
253
+ * Call {@link SandboxPaginator.nextItems} repeatedly until
254
+ * {@link SandboxPaginator.hasNext} is `false` to iterate through all pages.
255
+ *
256
+ * @param opts - Filter and pagination options.
257
+ * @returns A {@link SandboxPaginator} instance.
258
+ */
200
259
  static paginate(opts) {
201
260
  return new SandboxPaginator(opts);
202
261
  }
262
+ /**
263
+ * Permanently destroy the sandbox. This is irreversible — the sandbox
264
+ * cannot be resumed or reconnected after being killed.
265
+ * Also clears any active keep-alive heartbeat.
266
+ */
203
267
  async kill() {
204
268
  if (this.keepAliveInterval) {
205
269
  clearInterval(this.keepAliveInterval);
@@ -207,9 +271,21 @@ export class Sandbox {
207
271
  }
208
272
  await this.client.delete(`/sandboxes/${this.sandboxId}`);
209
273
  }
274
+ /**
275
+ * Reset the sandbox auto-kill timer.
276
+ *
277
+ * @param timeout - New timeout value in seconds. The sandbox will be killed
278
+ * after this many seconds of wall-clock time unless the timer is reset again.
279
+ */
210
280
  async setTimeout(timeout) {
211
281
  await this.client.post(`/sandboxes/${this.sandboxId}/timeout`, { timeout });
212
282
  }
283
+ /**
284
+ * Check whether the sandbox is currently in the `"running"` state.
285
+ *
286
+ * Makes a GET request to the sandbox info endpoint. Returns `false` if the
287
+ * sandbox does not exist, has been killed, or is in any non-running state.
288
+ */
213
289
  async isRunning() {
214
290
  try {
215
291
  const data = await this.client.get(`/sandboxes/${this.sandboxId}`);
@@ -219,6 +295,12 @@ export class Sandbox {
219
295
  return false;
220
296
  }
221
297
  }
298
+ /**
299
+ * Retrieve detailed information about the sandbox.
300
+ *
301
+ * @returns A {@link FullSandboxInfo} object containing state, CPU count,
302
+ * memory, template ID, and timestamps.
303
+ */
222
304
  async getInfo() {
223
305
  const data = await this.client.get(`/sandboxes/${this.sandboxId}`);
224
306
  return parseFullSandboxInfo(data);
@@ -230,7 +312,7 @@ export class Sandbox {
230
312
  }
231
313
  /** Get public URL for a port exposed inside the sandbox. */
232
314
  getHost(port) {
233
- return `https://${this.sandboxId}-${port}.claudebox.io`;
315
+ return `https://${this.sandboxId}-${port}.${this.previewDomain}`;
234
316
  }
235
317
  /** Create a managed preview URL for a sandbox port. */
236
318
  async expose(port, opts) {
@@ -255,24 +337,25 @@ export class Sandbox {
255
337
  return url;
256
338
  }
257
339
  // Convenience wrappers delegating to production namespace (e2b compat)
340
+ /**
341
+ * Pause the sandbox VM. A paused sandbox retains its state on disk and can
342
+ * be resumed later with {@link resume}. Use this for production sandboxes
343
+ * that need to survive periods of inactivity without being killed.
344
+ */
258
345
  async pause() {
259
346
  return this.production.pause();
260
347
  }
348
+ /**
349
+ * Resume a previously paused sandbox. The VM is restored from its
350
+ * saved state and continues running where it left off.
351
+ */
261
352
  async resume() {
262
353
  return this.production.resume();
263
354
  }
264
355
  async getMetrics() {
265
356
  const data = await this.client.get(`/sandboxes/${this.sandboxId}/metrics`);
266
357
  if (Array.isArray(data)) {
267
- return data.map((m) => ({
268
- timestamp: m.timestamp ?? "",
269
- cpuUsedPct: m.cpu_used_pct ?? 0,
270
- cpuCount: m.cpu_count ?? 0,
271
- memUsed: m.mem_used ?? 0,
272
- memTotal: m.mem_total ?? 0,
273
- diskUsed: m.disk_used ?? 0,
274
- diskTotal: m.disk_total ?? 0,
275
- }));
358
+ return data.map(parseMetricsSnapshot);
276
359
  }
277
360
  return [];
278
361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnirun/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "TypeScript SDK for OmniRun sandboxes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",