boxer-sdk
    Preparing search index...

    Class BoxerClient

    HTTP client for the Boxer sandbox execution API.

    Uses the web-standard fetch API with zero dependencies. Compatible with Node.js 18+, Bun, Deno, and browsers.

    const client = new BoxerClient({ baseUrl: "http://localhost:8080" });
    const result = await client.run("python:3.12-slim", ["python3", "-c", "print('hello')"]);
    console.log(result.stdout); // hello
    Index

    Constructors

    Methods

    • Download a file from the Boxer file store.

      To retrieve output files written by a container to /output/, use the path pattern "output/<exec_id>/<filename>". The execution must have been started with persist: true.

      Parameters

      • path: string

        Relative path of the file to download (e.g. "output/boxer-abc123/result.json").

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Raw file contents as a Uint8Array.

    • Returns true if the server responds with a 2xx status, false for non-OK responses. Network-level failures (connection refused, DNS error, timeout) propagate as exceptions so callers can distinguish between "server is up but unhealthy" and "server is unreachable".

      Returns Promise<boolean>

    • Pull image (if not cached) and run cmd inside a gVisor sandbox.

      Parameters

      • image: string

        OCI image reference, e.g. "python:3.12-slim".

      • cmd: string[]

        Command and arguments to execute, e.g. ["python3", "-c", "print(1)"].

      • options: RunOptions = {}

        Optional execution parameters (limits, files, network, …).

      Returns Promise<RunResult>

      A RunResult with exit code, stdout, stderr, and timing.

      BoxerTimeoutError if the wall-clock limit or client timeout is exceeded.

      BoxerOutputLimitError if stdout/stderr exceeds the server limit.

      BoxerAPIError for other server-side errors.

    • Upload a file to the Boxer file store so it can be bind-mounted in a subsequent run call via options.files.

      The file is stored at remotePath on the server and mounted read-only at /<remotePath> inside the container.

      Parameters

      • remotePath: string

        Destination path on the server (e.g. "script.py" or "data/input.csv").

      • content: ArrayBuffer | Blob | Uint8Array<ArrayBufferLike>

        File content as a Blob, Uint8Array, or ArrayBuffer.

      Returns Promise<void>