rustbox
v0.2.0
Published
Official TypeScript SDK for Rustbox - run untrusted code in a kernel-enforced sandbox.
Maintainers
Readme
📘 Rustbox TypeScript SDK
Native fetch. Zero runtime deps. Full type defs.
🚀 Install
bun add rustbox # or: npm install rustbox / pnpm add rustbox⚡ Quickstart
import { Rustbox } from "rustbox";
const result = await new Rustbox(process.env.RUSTBOX_API_KEY!).run({
language: "python",
code: "print('hello')",
});
console.log(result.verdict, result.stdout); // AC hellorun() submits, waits for sync completion, polls if needed, returns the verdict.
Profiles
// Judge profile (default) - short evaluation runs, no egress proxy.
await client.run({ language: "python", code: "print(1)" });
// Agent profile - longer jobs, egress proxy on, per-key byte budget.
// Requires a non-trial API key.
await client.run({ language: "python", code: "...", profile: "agent" });🔒 Errors
import { RustboxAuthError, RustboxRateLimitError, RustboxServerError } from "rustbox";
try { await client.run({ language: "python", code: "..." }); }
catch (e) {
if (e instanceof RustboxAuthError) { /* 401/403 */ }
if (e instanceof RustboxRateLimitError) { /* 429 - back off */ }
if (e instanceof RustboxServerError) { /* 5xx - retry */ }
}| Method | Returns |
|---|---|
| new Rustbox(apiKey, opts?) | Rustbox |
| run(req) | Promise<SubmitResponse> |
| submit(req, wait?, opts?) | Promise<SubmitResponse> |
| getResult(id) | Promise<SubmitResponse> |
| getLanguages() | Promise<string[]> |
| getHealth() | Promise<any> |
| getReady() | Promise<any> |
type SubmitRequest = {
language: string;
code: string;
stdin?: string;
profile?: "judge" | "agent";
};
type RustboxOptions = {
baseUrl?: string; // default: https://rustbox-api.orkait.com
timeoutMs?: number; // default: 65_000
maxRetries?: number; // default: 2
};
type SubmitOptions = {
idempotencyKey?: string; // safe to retry POST when set
};cd typescript && bun install && bun run testvitest + mocked fetch. No network.
🔗
- 📦 npm: rustbox
- 🪝 Webhooks
- 🛣️ Roadmap
- 🦀 SDK index
