Skip to content

2.1.0 | Sandbox API support

Latest

Choose a tag to compare

@mmilutinovic371 mmilutinovic371 released this 01 Sep 12:14

New: Sandboxes

Isolated Linux microVMs for running untrusted code — create a sandbox, run bash/python inside it, move files in and out, and tear it down:

import { Sandbox } from "deepinfra";

const sb = await Sandbox.create({ plan: "medium", timeout: "10m" });
const r = await sb.exec("python3", "-c", "print(21 * 2)");
console.log(r.stdout, r.returncode);
await sb.terminate();
  • Sandbox.create/fromId/list/catalog, exec, runPython, fs.read/write, stop/start/terminate, [Symbol.asyncDispose] for await using
  • New unified DeepInfraClient (retries, typed errors, NDJSON exec streaming)
  • Typed error hierarchy: AuthenticationError, NotFoundError, ConflictError, RateLimitError (TooManySandboxesError alias), SandboxTimeoutError, CommandFailedError, etc.

See the Sandboxes section of the README and examples/sandbox-quickstart.ts.

Other changes

  • Removed unused @swc/core/@swc/wasm dependencies and updated axios/form-data to their latest versions, clearing known vulnerabilities in the published package's dependency tree.

Full diff: 2.0.2...2.1.0