import type { Readable } from "node:stream";
export interface E2bSandbox {
    readonly sandboxId: string;
    readonly commands: E2bCommands;
    readonly files: E2bFiles;
    readonly pty: E2bPty;
    setTimeout(timeoutMs: number): Promise<void>;
    kill(): Promise<void>;
}
export interface E2bCommands {
    list(): Promise<E2bProcessInfo[]>;
    run(command: string, opts?: E2bCommandOptions): Promise<E2bCommandResult | E2bCommandHandle>;
    connect(pid: number, opts?: E2bCommandConnectOptions): Promise<E2bCommandHandle>;
    sendStdin(pid: number, data: string | Uint8Array): Promise<void>;
    closeStdin?(pid: number): Promise<void>;
    kill(pid: number): Promise<boolean>;
}
export interface E2bPty {
    create(opts: E2bPtyOptions): Promise<E2bCommandHandle>;
    sendInput(pid: number, data: Uint8Array): Promise<void>;
    kill(pid: number): Promise<boolean>;
}
export interface E2bFiles {
    read(path: string, opts: {
        format: "bytes";
    }): Promise<Uint8Array>;
    read(path: string): Promise<string>;
    write(path: string, data: string | ArrayBuffer | Blob | ReadableStream): Promise<unknown>;
    list(path: string): Promise<Array<{
        name: string;
        path: string;
        type?: "file" | "dir";
        size: number;
    }>>;
    makeDir(path: string): Promise<boolean>;
    rename(oldPath: string, newPath: string): Promise<unknown>;
    remove(path: string): Promise<void>;
    getInfo(path: string): Promise<{
        type?: "file" | "dir";
        size: number;
    }>;
    watchDir(path: string, onEvent: () => void | Promise<void>, opts?: {
        recursive?: boolean;
        onExit?: (error?: Error) => void | Promise<void>;
    }): Promise<{
        stop(): Promise<void>;
    }>;
}
export interface E2bProcessInfo {
    pid: number;
    cmd: string;
    args: string[];
}
export interface E2bCommandOptions {
    background?: boolean;
    cwd?: string;
    envs?: Record<string, string>;
    stdin?: boolean;
    timeoutMs?: number;
    onStdout?: (data: string) => void | Promise<void>;
    onStderr?: (data: string) => void | Promise<void>;
}
export interface E2bPtyOptions {
    cols: number;
    rows: number;
    cwd?: string;
    envs?: Record<string, string>;
    timeoutMs?: number;
    onData: (data: Uint8Array) => void | Promise<void>;
}
export interface E2bCommandConnectOptions {
    timeoutMs?: number;
    onStdout?: (data: string) => void | Promise<void>;
    onStderr?: (data: string) => void | Promise<void>;
}
export interface E2bCommandResult {
    exitCode?: number;
    stdout?: string;
    stderr?: string;
}
export interface E2bCommandHandle {
    readonly pid: number;
    wait(): Promise<E2bCommandResult>;
    kill(): Promise<boolean>;
}
export interface CreateSandboxOptions {
    apiKey: string;
    templateId: string;
    env: Record<string, string>;
    timeoutMinutes?: number;
}
export interface BuildTemplateOptions {
    apiKey: string;
    name: string;
    dockerfilePath: string;
    buildContext: string;
    cpu?: number;
    memoryMb?: number;
    fromTemplate?: string;
    onLog?: (entry: BuildLogEntry) => void;
}
export interface BuildLogEntry {
    level: "debug" | "info" | "warn" | "error";
    message: string;
    timestamp: Date;
}
export interface BuildTemplateResult {
    templateId: string;
}
export interface SandboxInfo {
    sandboxId: string;
}
export declare function createSandbox(opts: CreateSandboxOptions): Promise<E2bSandbox>;
export declare function connectSandbox(id: string, apiKey?: string): Promise<E2bSandbox>;
export declare function buildTemplate(opts: BuildTemplateOptions): Promise<BuildTemplateResult>;
export declare function listSandboxes(apiKey?: string): Promise<SandboxInfo[]>;
export declare function toArrayBuffer(buffer: Buffer): ArrayBuffer;
export declare function readableToString(stream: Readable | null): Promise<string>;
