@luxorai/sandbox
Version:
TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud
49 lines (48 loc) • 1.99 kB
TypeScript
import type { DiskUsage } from "./disk.js";
import type { Session } from "./session.js";
export interface ProcessRunOptions {
cwd?: string;
env?: Record<string, string>;
stdin?: ReadableStream<Uint8Array>;
privileged?: boolean;
/** Adds the secrets delivered to the session to the environment; `env` still wins. */
withSecrets?: boolean;
streamOnly?: boolean;
/**
* Wall-clock budget for the run; omitted or `0` means unbounded. Enforced by
* the guest-agent, which resolves a spent budget with `timedOut: true` rather
* than rejecting.
*/
timeoutMs?: number;
/** Signals the guest process and rejects the run with the signal's reason. */
signal?: AbortSignal;
}
export interface ProcessRunResult {
exitCode: number;
stdout: Uint8Array;
stderr: Uint8Array;
signal?: string;
durationMs?: number;
/** Reason string from the guest-agent. "exit" on natural exit, "signaled" on signal, etc. */
reason?: string;
/** Raw errno on fork/exec/wait failures (ENOENT, EMFILE, EACCES, ...). */
errno?: number;
/** Execution budget spent. May be set alongside `exitCode: 0`. */
timedOut?: boolean;
/** Sandbox filesystem state observed while the command ran. */
disk?: DiskUsage;
}
export interface ProcessRunHandle extends PromiseLike<ProcessRunResult> {
readonly pid: Promise<number>;
readonly stdout: ReadableStream<Uint8Array>;
readonly stderr: ReadableStream<Uint8Array>;
readonly stdin: WritableStream<Uint8Array>;
signal(signal: string): Promise<void>;
kill(): Promise<void>;
}
/**
* Resolve the two argv forms into one. A lone array is the argv itself, so
* `exec(["sh", "-c", cmd])` means the same as `exec("sh", { args: ["-c", cmd] })`.
*/
export declare function normalizeArgv(command: string | string[], args?: string[]): string[];
export declare function run(_session: Session, _argv: string[], _options?: ProcessRunOptions): ProcessRunHandle;