@omnirun/sdk 0.3.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.
@@ -0,0 +1,113 @@
1
+ /** Persistent interpreter context namespace for a single sandbox. */
2
+ export class Contexts {
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}/contexts`;
11
+ }
12
+ /** Create a new interpreter context for the given language. */
13
+ async create(language, opts) {
14
+ const body = { language };
15
+ if (opts?.cwd)
16
+ body.cwd = opts.cwd;
17
+ const data = await this.client.post(this.baseUrl, body);
18
+ return {
19
+ id: data.id ?? "",
20
+ language: data.language ?? language,
21
+ createdAt: data.created_at ?? "",
22
+ cwd: data.cwd ?? "",
23
+ };
24
+ }
25
+ /** List all interpreter contexts. */
26
+ async list() {
27
+ const data = await this.client.get(this.baseUrl);
28
+ const contexts = Array.isArray(data) ? data : [];
29
+ return contexts.map((c) => ({
30
+ id: c.id ?? "",
31
+ language: c.language ?? "",
32
+ createdAt: c.created_at ?? "",
33
+ cwd: c.cwd ?? "",
34
+ }));
35
+ }
36
+ /** Execute code in an existing interpreter context. */
37
+ async execute(contextId, code, opts) {
38
+ if (opts?.onStdout || opts?.onStderr || opts?.onResult) {
39
+ return this.streamExecute(contextId, code, opts);
40
+ }
41
+ const data = await this.client.post(`${this.baseUrl}/${contextId}/execute`, { code });
42
+ return parseExecutionResult(data);
43
+ }
44
+ /** Delete an interpreter context. */
45
+ async delete(contextId) {
46
+ await this.client.delete(`${this.baseUrl}/${contextId}`);
47
+ }
48
+ /** Restart an interpreter context. */
49
+ async restart(contextId) {
50
+ const data = await this.client.post(`${this.baseUrl}/${contextId}/restart`);
51
+ return {
52
+ id: data.id ?? contextId,
53
+ language: data.language ?? "",
54
+ createdAt: data.created_at ?? "",
55
+ cwd: data.cwd ?? "",
56
+ };
57
+ }
58
+ async streamExecute(contextId, code, opts) {
59
+ const stdoutParts = [];
60
+ const stderrParts = [];
61
+ const results = [];
62
+ let executionCount = 0;
63
+ for await (const event of this.client.streamSSEPost(`${this.baseUrl}/${contextId}/stream-execute`, { code })) {
64
+ const e = event;
65
+ if (e.type === "stdout") {
66
+ stdoutParts.push(e.data ?? "");
67
+ opts?.onStdout?.(e.data ?? "");
68
+ }
69
+ else if (e.type === "stderr") {
70
+ stderrParts.push(e.data ?? "");
71
+ opts?.onStderr?.(e.data ?? "");
72
+ }
73
+ else if (e.type === "result") {
74
+ const item = parseResultItem(e.data ?? {});
75
+ results.push(item);
76
+ opts?.onResult?.(item);
77
+ }
78
+ else if (e.type === "done") {
79
+ executionCount = e.execution_count ?? 0;
80
+ }
81
+ }
82
+ return {
83
+ results,
84
+ logs: { stdout: stdoutParts.join("\n"), stderr: stderrParts.join("\n") },
85
+ executionCount,
86
+ };
87
+ }
88
+ }
89
+ function parseResultItem(r) {
90
+ return {
91
+ text: r.text ?? undefined,
92
+ png: r.png ?? undefined,
93
+ html: r.html ?? undefined,
94
+ svg: r.svg ?? undefined,
95
+ markdown: r.markdown ?? undefined,
96
+ json: r.json ?? undefined,
97
+ latex: r.latex ?? undefined,
98
+ javascript: r.javascript ?? undefined,
99
+ };
100
+ }
101
+ function parseExecutionResult(data) {
102
+ return {
103
+ results: Array.isArray(data.results)
104
+ ? data.results.map(parseResultItem)
105
+ : [],
106
+ logs: {
107
+ stdout: data.logs?.stdout ?? "",
108
+ stderr: data.logs?.stderr ?? "",
109
+ },
110
+ error: data.error ?? undefined,
111
+ executionCount: data.execution_count ?? 0,
112
+ };
113
+ }
package/dist/e2ee.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * E2EE protocol helpers (SDK-side scaffold).
3
+ *
4
+ * Current purpose:
5
+ * - generate client key material
6
+ * - send client public key during sandbox create
7
+ * - provide envelope encryption helpers for future encrypted endpoints
8
+ */
9
+ export type E2EEAlgorithm = "ECDH-P256";
10
+ export interface E2EEKeyPairMaterial {
11
+ algorithm: E2EEAlgorithm;
12
+ publicKey: CryptoKey;
13
+ privateKey: CryptoKey;
14
+ /** Base64-encoded SPKI public key sent to OmniRun create endpoint. */
15
+ publicKeyBase64: string;
16
+ }
17
+ export interface E2EECreateOptions {
18
+ /** Enable E2EE bootstrap on sandbox create. */
19
+ enabled?: boolean;
20
+ /** Optional pre-generated keypair. If omitted, SDK generates one. */
21
+ keyPair?: E2EEKeyPairMaterial;
22
+ /** Optional explicit public key string if key material is managed externally. */
23
+ clientPublicKey?: string;
24
+ }
25
+ export interface E2EESessionInfo {
26
+ enabled: boolean;
27
+ clientPublicKey: string;
28
+ clientKeyPair?: E2EEKeyPairMaterial;
29
+ /** Optional server public key returned by API for handshake completion. */
30
+ serverPublicKey?: string;
31
+ }
32
+ export interface EncryptedEnvelope {
33
+ alg: "AES-256-GCM";
34
+ nonce: string;
35
+ ciphertext: string;
36
+ aad?: string;
37
+ }
38
+ export declare function generateE2EEKeyPair(): Promise<E2EEKeyPairMaterial>;
39
+ export declare function importE2EEPublicKey(publicKeyBase64: string): Promise<CryptoKey>;
40
+ export declare function deriveE2EESharedKey(privateKey: CryptoKey, peerPublicKeyBase64: string): Promise<CryptoKey>;
41
+ export declare function encryptE2EEJSON(key: CryptoKey, payload: unknown, aad?: string): Promise<EncryptedEnvelope>;
42
+ export declare function decryptE2EEJSON<T = unknown>(key: CryptoKey, envelope: EncryptedEnvelope): Promise<T>;
package/dist/e2ee.js ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * E2EE protocol helpers (SDK-side scaffold).
3
+ *
4
+ * Current purpose:
5
+ * - generate client key material
6
+ * - send client public key during sandbox create
7
+ * - provide envelope encryption helpers for future encrypted endpoints
8
+ */
9
+ const ECDH_ALG = { name: "ECDH", namedCurve: "P-256" };
10
+ const HKDF_ALG = {
11
+ name: "HKDF",
12
+ hash: "SHA-256",
13
+ salt: new Uint8Array(),
14
+ info: new TextEncoder().encode("omnirun-e2ee-v1"),
15
+ };
16
+ function getCrypto() {
17
+ const c = globalThis.crypto;
18
+ if (!c?.subtle) {
19
+ throw new Error("WebCrypto is required for E2EE helpers (Node 18+ or modern browser)");
20
+ }
21
+ return c;
22
+ }
23
+ function bytesToBase64(bytes) {
24
+ if (typeof Buffer !== "undefined") {
25
+ return Buffer.from(bytes).toString("base64");
26
+ }
27
+ let binary = "";
28
+ for (const b of bytes)
29
+ binary += String.fromCharCode(b);
30
+ return btoa(binary);
31
+ }
32
+ function base64ToBytes(b64) {
33
+ if (typeof Buffer !== "undefined") {
34
+ return new Uint8Array(Buffer.from(b64, "base64"));
35
+ }
36
+ const binary = atob(b64);
37
+ const bytes = new Uint8Array(binary.length);
38
+ for (let i = 0; i < binary.length; i++)
39
+ bytes[i] = binary.charCodeAt(i);
40
+ return bytes;
41
+ }
42
+ function toArrayBuffer(bytes) {
43
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
44
+ }
45
+ export async function generateE2EEKeyPair() {
46
+ const crypto = getCrypto();
47
+ const keys = await crypto.subtle.generateKey(ECDH_ALG, true, ["deriveBits"]);
48
+ const publicKey = keys.publicKey;
49
+ const privateKey = keys.privateKey;
50
+ const spki = new Uint8Array(await crypto.subtle.exportKey("spki", publicKey));
51
+ return {
52
+ algorithm: "ECDH-P256",
53
+ publicKey,
54
+ privateKey,
55
+ publicKeyBase64: bytesToBase64(spki),
56
+ };
57
+ }
58
+ export async function importE2EEPublicKey(publicKeyBase64) {
59
+ const crypto = getCrypto();
60
+ const spki = base64ToBytes(publicKeyBase64);
61
+ return crypto.subtle.importKey("spki", toArrayBuffer(spki), ECDH_ALG, true, []);
62
+ }
63
+ export async function deriveE2EESharedKey(privateKey, peerPublicKeyBase64) {
64
+ const crypto = getCrypto();
65
+ const peerKey = await importE2EEPublicKey(peerPublicKeyBase64);
66
+ const bits = await crypto.subtle.deriveBits({ name: "ECDH", public: peerKey }, privateKey, 256);
67
+ const ikm = await crypto.subtle.importKey("raw", bits, "HKDF", false, ["deriveKey"]);
68
+ return crypto.subtle.deriveKey(HKDF_ALG, ikm, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
69
+ }
70
+ export async function encryptE2EEJSON(key, payload, aad) {
71
+ const crypto = getCrypto();
72
+ const iv = crypto.getRandomValues(new Uint8Array(12));
73
+ const plaintext = new TextEncoder().encode(JSON.stringify(payload));
74
+ const additionalData = aad ? new TextEncoder().encode(aad) : undefined;
75
+ const ivBuffer = toArrayBuffer(iv);
76
+ const plaintextBuffer = toArrayBuffer(plaintext);
77
+ const additionalDataBuffer = additionalData ? toArrayBuffer(additionalData) : undefined;
78
+ const ciphertext = await crypto.subtle.encrypt({
79
+ name: "AES-GCM",
80
+ iv: ivBuffer,
81
+ additionalData: additionalDataBuffer,
82
+ }, key, plaintextBuffer);
83
+ return {
84
+ alg: "AES-256-GCM",
85
+ nonce: bytesToBase64(iv),
86
+ ciphertext: bytesToBase64(new Uint8Array(ciphertext)),
87
+ aad,
88
+ };
89
+ }
90
+ export async function decryptE2EEJSON(key, envelope) {
91
+ const crypto = getCrypto();
92
+ const iv = base64ToBytes(envelope.nonce);
93
+ const ciphertext = base64ToBytes(envelope.ciphertext);
94
+ const additionalData = envelope.aad
95
+ ? new TextEncoder().encode(envelope.aad)
96
+ : undefined;
97
+ const ivBuffer = toArrayBuffer(iv);
98
+ const ciphertextBuffer = toArrayBuffer(ciphertext);
99
+ const additionalDataBuffer = additionalData ? toArrayBuffer(additionalData) : undefined;
100
+ const plaintext = await crypto.subtle.decrypt({
101
+ name: "AES-GCM",
102
+ iv: ivBuffer,
103
+ additionalData: additionalDataBuffer,
104
+ }, key, ciphertextBuffer);
105
+ const decoded = new TextDecoder().decode(new Uint8Array(plaintext));
106
+ return JSON.parse(decoded);
107
+ }
@@ -0,0 +1,18 @@
1
+ export declare class SandboxError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class SandboxNotFoundError extends SandboxError {
5
+ constructor(sandboxId: string);
6
+ }
7
+ export declare class CommandExitException extends SandboxError {
8
+ stdout: string;
9
+ stderr: string;
10
+ exitCode: number;
11
+ constructor(stdout: string, stderr: string, exitCode: number);
12
+ }
13
+ export declare class StreamError extends SandboxError {
14
+ constructor(message: string);
15
+ }
16
+ export declare class TimeoutError extends SandboxError {
17
+ constructor(message: string);
18
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,36 @@
1
+ export class SandboxError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "SandboxError";
5
+ }
6
+ }
7
+ export class SandboxNotFoundError extends SandboxError {
8
+ constructor(sandboxId) {
9
+ super(`Sandbox ${sandboxId} not found`);
10
+ this.name = "SandboxNotFoundError";
11
+ }
12
+ }
13
+ export class CommandExitException extends SandboxError {
14
+ stdout;
15
+ stderr;
16
+ exitCode;
17
+ constructor(stdout, stderr, exitCode) {
18
+ super(`Command exited with code ${exitCode}: ${stderr || stdout}`);
19
+ this.name = "CommandExitException";
20
+ this.stdout = stdout;
21
+ this.stderr = stderr;
22
+ this.exitCode = exitCode;
23
+ }
24
+ }
25
+ export class StreamError extends SandboxError {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = "StreamError";
29
+ }
30
+ }
31
+ export class TimeoutError extends SandboxError {
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = "TimeoutError";
35
+ }
36
+ }
@@ -0,0 +1,35 @@
1
+ import type { HTTPClient } from "./client.js";
2
+ import type { EntryInfo, WriteEntry } from "./models.js";
3
+ import { WatchHandle } from "./watch-handle.js";
4
+ export interface FileReadOptions {
5
+ user?: string;
6
+ }
7
+ export interface FileWriteOptions {
8
+ user?: string;
9
+ }
10
+ export interface FileListOptions {
11
+ depth?: number;
12
+ user?: string;
13
+ }
14
+ /** File operations namespace for a single sandbox. */
15
+ export declare class Filesystem {
16
+ private sandboxId;
17
+ private client;
18
+ constructor(sandboxId: string, client: HTTPClient);
19
+ private get baseUrl();
20
+ read(path: string, format?: "text", opts?: FileReadOptions): Promise<string>;
21
+ read(path: string, format: "bytes", opts?: FileReadOptions): Promise<Uint8Array>;
22
+ read(path: string, format: "stream", opts?: FileReadOptions): Promise<ReadableStream<Uint8Array>>;
23
+ write(path: string, content: string, opts?: FileWriteOptions): Promise<EntryInfo>;
24
+ write(path: string, content: Uint8Array, opts?: FileWriteOptions): Promise<EntryInfo>;
25
+ write(entries: WriteEntry[]): Promise<EntryInfo[]>;
26
+ list(path?: string, opts?: FileListOptions): Promise<EntryInfo[]>;
27
+ exists(path: string, opts?: FileReadOptions): Promise<boolean>;
28
+ info(path: string, opts?: FileReadOptions): Promise<EntryInfo>;
29
+ remove(path: string, opts?: FileWriteOptions): Promise<void>;
30
+ rename(oldPath: string, newPath: string, opts?: FileWriteOptions): Promise<EntryInfo>;
31
+ makeDir(path: string, opts?: FileWriteOptions): Promise<void>;
32
+ watchDir(path: string, opts?: {
33
+ recursive?: boolean;
34
+ }): WatchHandle;
35
+ }
@@ -0,0 +1,124 @@
1
+ import { WatchHandle } from "./watch-handle.js";
2
+ /** File operations namespace for a single sandbox. */
3
+ export class Filesystem {
4
+ sandboxId;
5
+ client;
6
+ constructor(sandboxId, client) {
7
+ this.sandboxId = sandboxId;
8
+ this.client = client;
9
+ }
10
+ get baseUrl() {
11
+ return `/sandboxes/${this.sandboxId}/files`;
12
+ }
13
+ async read(path, format = "text", opts) {
14
+ const params = { path };
15
+ if (opts?.user)
16
+ params.user = opts.user;
17
+ if (format === "stream") {
18
+ return this.client.streamDownload(`${this.baseUrl}/download`, params);
19
+ }
20
+ if (format === "bytes") {
21
+ return this.client.download(`${this.baseUrl}/download`, params);
22
+ }
23
+ const data = await this.client.get(this.baseUrl, params);
24
+ return data.content ?? "";
25
+ }
26
+ async write(pathOrEntries, content, opts) {
27
+ // Batch write
28
+ if (Array.isArray(pathOrEntries)) {
29
+ const data = await this.client.post(`${this.baseUrl}/batch`, pathOrEntries);
30
+ return data.map((r) => ({
31
+ name: r.name ?? "",
32
+ path: r.path ?? "",
33
+ isDir: r.is_dir ?? false,
34
+ size: r.size ?? 0,
35
+ }));
36
+ }
37
+ const path = pathOrEntries;
38
+ const writeOpts = opts;
39
+ // Binary upload
40
+ if (content instanceof Uint8Array) {
41
+ const filename = path.split("/").pop() || "upload";
42
+ const data = await this.client.upload(`${this.baseUrl}/upload`, path, content, filename);
43
+ return {
44
+ name: data.name ?? filename,
45
+ path: data.path ?? path,
46
+ isDir: false,
47
+ size: data.size ?? content.length,
48
+ };
49
+ }
50
+ // Text write
51
+ const body = { path, content: content ?? "" };
52
+ if (writeOpts?.user)
53
+ body.user = writeOpts.user;
54
+ const data = await this.client.post(this.baseUrl, body);
55
+ return {
56
+ name: path.split("/").pop() || "",
57
+ path: data.path ?? path,
58
+ isDir: false,
59
+ size: (typeof content === "string" ? content : "").length,
60
+ };
61
+ }
62
+ async list(path = "/", opts) {
63
+ const params = { path };
64
+ if (opts?.depth != null && opts.depth !== 1) {
65
+ params.depth = String(opts.depth);
66
+ }
67
+ if (opts?.user)
68
+ params.user = opts.user;
69
+ const data = await this.client.get(`${this.baseUrl}/list`, params);
70
+ const entries = Array.isArray(data) ? data : [];
71
+ return entries.map((e) => ({
72
+ name: e.name,
73
+ path: e.path,
74
+ isDir: e.is_dir,
75
+ size: e.size ?? 0,
76
+ }));
77
+ }
78
+ async exists(path, opts) {
79
+ const params = { path };
80
+ if (opts?.user)
81
+ params.user = opts.user;
82
+ const data = await this.client.get(`${this.baseUrl}/exists`, params);
83
+ return data.exists ?? false;
84
+ }
85
+ async info(path, opts) {
86
+ const params = { path };
87
+ if (opts?.user)
88
+ params.user = opts.user;
89
+ const data = await this.client.get(`${this.baseUrl}/info`, params);
90
+ return {
91
+ name: data.name ?? "",
92
+ path: data.path ?? path,
93
+ isDir: data.is_dir ?? false,
94
+ size: data.size ?? 0,
95
+ };
96
+ }
97
+ async remove(path, opts) {
98
+ const params = { path };
99
+ if (opts?.user)
100
+ params.user = opts.user;
101
+ await this.client.delete(this.baseUrl, params);
102
+ }
103
+ async rename(oldPath, newPath, opts) {
104
+ const body = { oldPath, newPath };
105
+ if (opts?.user)
106
+ body.user = opts.user;
107
+ const data = await this.client.post(`${this.baseUrl}/rename`, body);
108
+ return {
109
+ name: data.name ?? "",
110
+ path: data.path ?? newPath,
111
+ isDir: data.is_dir ?? false,
112
+ size: data.size ?? 0,
113
+ };
114
+ }
115
+ async makeDir(path, opts) {
116
+ const body = { path };
117
+ if (opts?.user)
118
+ body.user = opts.user;
119
+ await this.client.post(`${this.baseUrl}/mkdir`, body);
120
+ }
121
+ watchDir(path, opts) {
122
+ return new WatchHandle(this.sandboxId, path, opts?.recursive ?? false, this.client);
123
+ }
124
+ }
@@ -0,0 +1,19 @@
1
+ export { Sandbox, SandboxPaginator } from "./sandbox.js";
2
+ export { makeCommandResult } from "./utils.js";
3
+ export { Commands } from "./commands.js";
4
+ export { CommandHandle } from "./command-handle.js";
5
+ export { Filesystem } from "./filesystem.js";
6
+ export { Pty, PtySession } from "./pty.js";
7
+ export { Contexts } from "./contexts.js";
8
+ export { Production } from "./production.js";
9
+ export { Webhooks } from "./webhooks.js";
10
+ export { WatchHandle } from "./watch-handle.js";
11
+ export { HTTPClient } from "./client.js";
12
+ export { generateE2EEKeyPair, importE2EEPublicKey, deriveE2EESharedKey, encryptE2EEJSON, decryptE2EEJSON, } from "./e2ee.js";
13
+ export { resolveConfig } from "./config.js";
14
+ export type { ConnectionConfig } from "./config.js";
15
+ export { SandboxError, SandboxNotFoundError, CommandExitException, StreamError, TimeoutError, } from "./errors.js";
16
+ export type { CommandResult, EntryInfo, SandboxInfo, FullSandboxInfo, ProcessInfo, PtyInfo, WriteEntry, FilesystemEvent, StreamEvent, RunCommandOptions, CreateSandboxOptions, ListSandboxOptions, ContextInfo, ResultItem, LogOutput, ExecutionResult, SandboxMetrics, MetricsSnapshot, NetworkPolicy, WebhookInfo, CodeResult, } from "./models.js";
17
+ export type { E2EEAlgorithm, E2EEKeyPairMaterial, E2EECreateOptions, E2EESessionInfo, EncryptedEnvelope, } from "./e2ee.js";
18
+ export type { FileReadOptions, FileWriteOptions, FileListOptions } from "./filesystem.js";
19
+ export type { ExecuteOptions } from "./contexts.js";
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export { Sandbox, SandboxPaginator } from "./sandbox.js";
2
+ export { makeCommandResult } from "./utils.js";
3
+ export { Commands } from "./commands.js";
4
+ export { CommandHandle } from "./command-handle.js";
5
+ export { Filesystem } from "./filesystem.js";
6
+ export { Pty, PtySession } from "./pty.js";
7
+ export { Contexts } from "./contexts.js";
8
+ export { Production } from "./production.js";
9
+ export { Webhooks } from "./webhooks.js";
10
+ export { WatchHandle } from "./watch-handle.js";
11
+ export { HTTPClient } from "./client.js";
12
+ export { generateE2EEKeyPair, importE2EEPublicKey, deriveE2EESharedKey, encryptE2EEJSON, decryptE2EEJSON, } from "./e2ee.js";
13
+ export { resolveConfig } from "./config.js";
14
+ export { SandboxError, SandboxNotFoundError, CommandExitException, StreamError, TimeoutError, } from "./errors.js";
@@ -0,0 +1,154 @@
1
+ import type { E2EECreateOptions } from "./e2ee.js";
2
+ export interface CommandResult {
3
+ stdout: string;
4
+ stderr: string;
5
+ exitCode: number;
6
+ /** Alias for stdout (e2b compat). */
7
+ readonly output?: string;
8
+ }
9
+ export interface EntryInfo {
10
+ name: string;
11
+ path: string;
12
+ isDir: boolean;
13
+ size: number;
14
+ }
15
+ export interface SandboxInfo {
16
+ sandboxId: string;
17
+ templateId: string;
18
+ status: string;
19
+ startedAt: string;
20
+ endAt?: string;
21
+ name?: string;
22
+ state?: string;
23
+ cpuCount?: number;
24
+ memoryMB?: number;
25
+ }
26
+ export interface ProcessInfo {
27
+ pid: number;
28
+ command: string;
29
+ running: boolean;
30
+ exitCode: number;
31
+ stdout?: string;
32
+ stderr?: string;
33
+ startedAt?: string;
34
+ endedAt?: string;
35
+ }
36
+ export interface PtyInfo {
37
+ pid: number;
38
+ running: boolean;
39
+ startedAt?: string;
40
+ }
41
+ export interface WriteEntry {
42
+ path: string;
43
+ content: string;
44
+ }
45
+ export interface FilesystemEvent {
46
+ type: "create" | "write" | "remove" | "rename";
47
+ path: string;
48
+ name: string;
49
+ timestamp?: string;
50
+ }
51
+ export interface StreamEvent {
52
+ type: "stdout" | "stderr" | "exit";
53
+ data?: string;
54
+ exit_code?: number;
55
+ timestamp?: string;
56
+ }
57
+ export interface FullSandboxInfo extends SandboxInfo {
58
+ state: string;
59
+ cpuCount: number;
60
+ memoryMB: number;
61
+ }
62
+ export interface RunCommandOptions {
63
+ cwd?: string;
64
+ timeout?: number;
65
+ background?: boolean;
66
+ envs?: Record<string, string>;
67
+ user?: string;
68
+ onStdout?: (data: string) => void;
69
+ onStderr?: (data: string) => void;
70
+ }
71
+ export interface CreateSandboxOptions {
72
+ timeout?: number;
73
+ apiKey?: string;
74
+ apiUrl?: string;
75
+ requestTimeout?: number;
76
+ internet?: boolean;
77
+ envVars?: Record<string, string>;
78
+ metadata?: Record<string, string>;
79
+ keepAlive?: number;
80
+ autoPause?: boolean;
81
+ network?: NetworkPolicy;
82
+ secure?: boolean;
83
+ maskRequestHost?: string;
84
+ /** Client-side E2EE bootstrap options (key generation + public key announcement). */
85
+ e2ee?: boolean | E2EECreateOptions;
86
+ }
87
+ export interface ListSandboxOptions {
88
+ apiKey?: string;
89
+ apiUrl?: string;
90
+ limit?: number;
91
+ nextToken?: string;
92
+ state?: string;
93
+ metadata?: Record<string, string>;
94
+ }
95
+ export interface ContextInfo {
96
+ id: string;
97
+ language: string;
98
+ createdAt: string;
99
+ cwd?: string;
100
+ }
101
+ export interface ResultItem {
102
+ text?: string;
103
+ png?: string;
104
+ html?: string;
105
+ svg?: string;
106
+ markdown?: string;
107
+ json?: any;
108
+ latex?: string;
109
+ javascript?: string;
110
+ }
111
+ export interface LogOutput {
112
+ stdout: string;
113
+ stderr: string;
114
+ }
115
+ export interface ExecutionResult {
116
+ results: ResultItem[];
117
+ logs: LogOutput;
118
+ error?: string;
119
+ executionCount?: number;
120
+ }
121
+ export interface SandboxMetrics {
122
+ cpuTimeMs: number;
123
+ memoryUsedMb: number;
124
+ diskUsedMb: number;
125
+ networkRxKb: number;
126
+ networkTxKb: number;
127
+ commandCount: number;
128
+ uptime: string;
129
+ }
130
+ export interface NetworkPolicy {
131
+ allowDomains?: string[];
132
+ denyDomains?: string[];
133
+ allowIPs?: string[];
134
+ denyIPs?: string[];
135
+ }
136
+ export interface WebhookInfo {
137
+ id: string;
138
+ url: string;
139
+ events: string[];
140
+ }
141
+ export interface CodeResult {
142
+ stdout: string;
143
+ stderr: string;
144
+ exitCode: number;
145
+ }
146
+ export interface MetricsSnapshot {
147
+ timestamp: string;
148
+ cpuUsedPct: number;
149
+ cpuCount: number;
150
+ memUsed: number;
151
+ memTotal: number;
152
+ diskUsed: number;
153
+ diskTotal: number;
154
+ }
package/dist/models.js ADDED
@@ -0,0 +1 @@
1
+ export {};