@solarisdk/e2b-compat
v0.2.14
Published
E2B-compatible API (sandboxes and code interpreter) on top of Solari Sandbox: change the import, keep your E2B code. Not affiliated with E2B.
Maintainers
Readme
@solarisdk/e2b-compat
An E2B-compatible API on top of Solari Sandbox. Change the import, keep your sandbox code.
Not affiliated with, endorsed by, or sponsored by E2B. "E2B" is E2B's product name; it appears here only to describe API compatibility. The API shapes follow the MIT-licensed
e2band@e2b/code-interpreterSDKs, see NOTICE. Do not look for this package under@e2b/*.
// before: import { Sandbox } from '@e2b/code-interpreter';
import { Sandbox } from '@solarisdk/e2b-compat/code-interpreter';
const sbx = await Sandbox.create(); // SOLARI_API_KEY in the environment
const execution = await sbx.runCode('x = 1\nx + 1');
console.log(execution.text); // "2"
const r = await sbx.commands.run('echo hello');
console.log(r.stdout);
await sbx.files.write('/tmp/a.txt', 'hi');
await sbx.kill();The plain e2b package maps to the package root:
// before: import { Sandbox, Template } from 'e2b';
import { Sandbox, Template } from '@solarisdk/e2b-compat';Exports: Sandbox (default and named; create, connect, list, kill, pause, snapshots, fork, commands, files, pty,
git), Template and the template builder, Volume (Solari persistent volumes), the E2B error classes (SandboxError,
TimeoutError, NotFoundError, FileNotFoundError, CommandExitError, AuthenticationError, ...),
SolariCompatUnsupported, and from /code-interpreter: Sandbox with runCode and code contexts, Execution, Result,
Context. Every name e2b and @e2b/code-interpreter export is exported here (the code-interpreter entry re-exports all of
e2b, as the original does); for a feature Solari does not have (Secret, the MCP gateway, ...) the name exists and throws
SolariCompatUnsupported when used.
Requirements
Node 18+. The type declarations need TypeScript 5.0 or newer.
Configuration
| | Order |
|---|---|
| API key | apiKey option, SOLARI_API_KEY, E2B_API_KEY: only an slr_… Solari key is ever used. A non-slr_ value (for example a real E2B key) is skipped with a warning (the key is never printed or sent); with no Solari key the call throws |
| Base URL | apiUrl / domain option (Solari or loopback only, anything else throws), SOLARI_BASE_URL, E2B_API_URL / E2B_DOMAIN (only if they point at a Solari API host or loopback; otherwise ignored with a warning), default https://api.getsolari.com |
An E2B key does not work here: use a Solari API key.
The code-interpreter template
@e2b/code-interpreter runs in a template with a data-analysis stack (pandas, numpy, scipy, scikit-learn, seaborn,
plotly, ...). Solari builds the equivalent, code-interpreter-v2, into your org the first time
Sandbox.create() is called without a template (about 90 seconds, once). To do it ahead of time:
import { buildCodeInterpreterTemplate } from '@solarisdk/e2b-compat/code-interpreter';
await buildCodeInterpreterTemplate();SOLARI_CODE_INTERPRETER_TEMPLATE overrides the template (a name or tpl_… id). The package list is
CODE_INTERPRETER_PACKAGES; the very large audio, NLP and computer-vision wheels E2B ships (spacy, librosa, opencv,
numba, gensim) are not included.
What works, what does not
COMPAT.md is the support matrix. Anything Solari cannot do throws SolariCompatUnsupported
(a SandboxError) naming the feature; nothing is silently ignored. The sibling Python package is
sdk/python-e2b-compat (solari-e2b-compat) and follows the same rules.
Tests
npm test: offline unit tests, a fake gateway.- Live tests against a staging gateway run in the maintainers' CI (not shipped in this package). They create their own sandboxes, snapshots and templates and delete only those.
