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]forawait using- New unified
DeepInfraClient(retries, typed errors, NDJSON exec streaming) - Typed error hierarchy:
AuthenticationError,NotFoundError,ConflictError,RateLimitError(TooManySandboxesErroralias),SandboxTimeoutError,CommandFailedError, etc.
See the Sandboxes section of the README and examples/sandbox-quickstart.ts.
Other changes
- Removed unused
@swc/core/@swc/wasmdependencies and updatedaxios/form-datato their latest versions, clearing known vulnerabilities in the published package's dependency tree.
Full diff: 2.0.2...2.1.0