@lelantos-ai/sdk
v0.2.3
Published
First-party Lelantos SDK — modern createLelantos() namespaces (compute / browser / durable / snapshot / template) PLUS a backward-compatible LelantosClient / SandboxHandle superset of the legacy @lelantos-ai/sdk. Dual-key (lel_/e2b_) + domain/apiUrl baked
Readme
Lelantos SDK
Firecracker microVM code sandboxes + stealth browser sandboxes for AI agents — one TypeScript SDK.
Spin up an isolated Linux microVM, run real commands with real exit codes, read and write its filesystem, and get a public preview URL — or drive a fingerprint-resistant headless browser over CDP and a no-Playwright action API. One client, one auth config, the full Lelantos platform.
Install
npm i @lelantos-ai/sdkShort alias: npm i lelantos (re-exports this package; import … from 'lelantos').
# the browser namespace's Playwright path also needs Playwright (optional peer):
npm i playwrightQuickstart (30 seconds)
import { createLelantos } from '@lelantos-ai/sdk';
const lel = createLelantos({
apiKey: process.env.LELANTOS_API_KEY, // lel_… or its e2b_… alias
domain: 'lelantos.ai',
});
const sbx = await lel.compute.create('base'); // boot a microVM
const r = await sbx.runCommand('echo hello from the vm');
console.log(r.exitCode, r.stdout); // 0 "hello from the vm\n"
await sbx.destroy();runCommand returns the real exit code — a genuine non-zero (including a shell 127) is surfaced immediately, never a silent fake; only transient envd cold-starts are retried with bounded backoff.
Browser sandboxes
Stealth headless Chromium/Firefox, driven with Playwright over CDP:
const { browser, artifacts, close } = await lel.browser.createBrowser({
engine: 'chromium', // or 'firefox'
});
try {
const page = await browser.newPage();
await page.goto('https://example.com');
await artifacts.screenshot(); // captured via CDP, persisted server-side
await artifacts.pdf(); // chromium only
} finally {
await close(); // closes browser + bridge + deletes the sandbox
}…or drive the browser without Playwright via the NDJSON /rpc action API:
const client = await lel.browser.rpc(sandboxId);
await client.navigate('https://example.com');
const snap = await client.snapshot(); // accessibility tree → { tree_yaml, … }
const title = await client.evaluate('document.title'); // → { value, … }
await client.send('page.scroll', { dy: 600 }); // any daemon action via send()
await client.close();Filesystem & preview URLs
await sbx.filesystem.write('/tmp/app.py', 'print("hi")');
const files = await sbx.filesystem.list('/tmp');
const url = await sbx.getUrl(3000); // https://3000-<id>.lelantos.aiTwo API styles
The package ships both surfaces — pick one, they coexist:
- Modern (recommended) —
createLelantos(config)returns namespaces (compute/browser/durable/snapshot/template). Auth + domain are baked into every call; no per-call threading. - Legacy compat — the original
LelantosClient/SandboxHandleclasses are still exported unchanged, so existing code keeps working. New code should prefercreateLelantos.
import { LelantosClient } from '@lelantos-ai/sdk'; // legacy, still supportedFeatures
- Compute — E2B-compatible Firecracker microVMs: create / connect / list / destroy,
runCommandwith real exit codes, normalized filesystem, preview URLs. - Browser — CDP browser sandboxes via Playwright/Puppeteer, plus a Playwright-free NDJSON
/rpcaction client; per-context BYO proxy (hot-swap, no restart); screenshot/PDF artifacts. - Durable pause / resume — snapshot a compute sandbox to S3 so a pause survives a node restart (compute only).
- Snapshots & templates — create snapshots; build custom templates via the v3 pipeline.
- Dual-key auth — accepts a
lel_…key or itse2b_…alias; env fallbacks for key/domain/apiUrl. - First-class TypeScript — full types, namespaced, no codegen step.
- Escape hatches —
lel.httpfor any endpoint not yet surfaced;sbx.getInstance()for the raw underlying handle.
Durable pause / resume (compute only)
await lel.durable.pause(sbx.id, { durable: true }); // 202, async snapshot to S3
let s = await lel.durable.get(sbx.id); // poll until 'durable_paused'
await lel.durable.resume(sbx.id, { timeout: 3600 });Default pause is an in-RAM vCPU freeze (lost on node restart); durable: true survives a restart. Never use this for browser sandboxes — their state is time-sensitive.
Links
- Website — https://lelantos.ai
- Docs — https://lelantos.ai/docs
- Agent homepage (llms.txt) — https://lelantos.ai/llms.txt
License
Apache-2.0
