solari-e2b-compat 0.2.4__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- solari_e2b_compat-0.2.5/COMPAT.md +139 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/PKG-INFO +1 -1
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/pyproject.toml +1 -1
- solari_e2b_compat-0.2.5/solari_e2b/__init__.py +79 -0
- solari_e2b_compat-0.2.5/solari_e2b/_commands.py +463 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_config.py +42 -17
- solari_e2b_compat-0.2.5/solari_e2b/_filesystem.py +362 -0
- solari_e2b_compat-0.2.5/solari_e2b/_git.py +504 -0
- solari_e2b_compat-0.2.5/solari_e2b/_request.py +43 -0
- solari_e2b_compat-0.2.5/solari_e2b/_sandbox.py +769 -0
- solari_e2b_compat-0.2.5/solari_e2b/_sync.py +394 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_template.py +202 -65
- solari_e2b_compat-0.2.5/solari_e2b/_volume.py +197 -0
- solari_e2b_compat-0.2.4/solari_e2b/code_interpreter.py → solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/__init__.py +187 -70
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/charts.py +224 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/client.py +3 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/code_interpreter_async.py +4 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/code_interpreter_sync.py +4 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/constants.py +7 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/exceptions.py +20 -0
- solari_e2b_compat-0.2.5/solari_e2b/code_interpreter/models.py +101 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/exceptions.py +50 -7
- solari_e2b_compat-0.2.5/solari_e2b/models.py +391 -0
- solari_e2b_compat-0.2.4/COMPAT.md +0 -117
- solari_e2b_compat-0.2.4/solari_e2b/__init__.py +0 -39
- solari_e2b_compat-0.2.4/solari_e2b/_commands.py +0 -307
- solari_e2b_compat-0.2.4/solari_e2b/_filesystem.py +0 -226
- solari_e2b_compat-0.2.4/solari_e2b/_sandbox.py +0 -504
- solari_e2b_compat-0.2.4/solari_e2b/_sync.py +0 -196
- solari_e2b_compat-0.2.4/solari_e2b/models.py +0 -128
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/.gitignore +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/LICENSE +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/LICENSE-E2B +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/NOTICE +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/README.md +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_box.py +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_loop.py +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_redact.py +0 -0
- {solari_e2b_compat-0.2.4 → solari_e2b_compat-0.2.5}/solari_e2b/_vendor_user.py +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# COMPAT.md: E2B Python SDK compatibility (target: e2b 2.59 and e2b-code-interpreter 2.11)
|
|
2
|
+
|
|
3
|
+
Legend: **OK** works and is tested; **DIFF** works with a behaviour difference (explained); **NO** raises
|
|
4
|
+
`SolariCompatUnsupported` naming the feature. "Live" means `tests/test_live_staging.py` runs it against staging.
|
|
5
|
+
The matrix is the same as the TypeScript package's (`sdk/packages/e2b-compat/COMPAT.md`); this file lists the Python names
|
|
6
|
+
and the differences that are specific to Python.
|
|
7
|
+
|
|
8
|
+
## At a glance
|
|
9
|
+
- **Works**: sandbox create / connect / list / info / kill / timeout / pause / resume / metrics, snapshots and fork,
|
|
10
|
+
commands (foreground, background, stdin, list, kill), PTY, the filesystem API (read as text, bytes or stream; write one or
|
|
11
|
+
many; list with depth; info; exists; make_dir; rename; remove; watch_dir; signed upload and download URLs), the code
|
|
12
|
+
interpreter (`run_code` with state, callbacks, errors, bash, contexts, rich results), the template builder and
|
|
13
|
+
`Template.build`. Blocking (`Sandbox`) and async (`AsyncSandbox`) flavours.
|
|
14
|
+
- **Not available** (raises `SolariCompatUnsupported` when used; the name itself always imports): egress network rules other than
|
|
15
|
+
"block everything", the MCP gateway, IAM tokens, the E2B `Secret` API, the `E2B(...)` client object, template tags,
|
|
16
|
+
`set_start_cmd` / `set_ready_cmd`, `set_user`, `Template.copy`, Dockerfile input, private registries, `on_resume='reboot'`,
|
|
17
|
+
JavaScript/TypeScript/R/Java in `run_code`.
|
|
18
|
+
- **Every name** that `e2b` (its `__all__`) and `e2b_code_interpreter` export exists, including the submodules
|
|
19
|
+
`solari_e2b.code_interpreter.models / charts / constants / exceptions / client`. A test (`compat-harness/py/test_e2b_exports.py`)
|
|
20
|
+
keeps the list complete.
|
|
21
|
+
|
|
22
|
+
## Setup and configuration
|
|
23
|
+
| E2B | Here |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `E2B_API_KEY`, `api_key=` | Only `slr_…` keys are used; see README. |
|
|
26
|
+
| `E2B_DOMAIN`, `E2B_API_URL`, `domain=`, `api_url=` | Honoured only when they point at a Solari API host or loopback. |
|
|
27
|
+
| `headers=`, `api_headers=`, `proxy=` | NO. |
|
|
28
|
+
| `request_timeout=` | OK. A deadline in seconds on the whole call (`0` removes the limit): `TimeoutException` when it passes. Not set: Solari's own transport limits apply (E2B's default is 60 s). On a streaming start (`commands.run`, `pty.create`) it bounds the start request; `run_code` has no per-call connection to bound, so there it has no effect and `timeout` is the limit. `Template.build` does not apply it either: E2B bounds each request of a build, not the build (the wait has its own cap). |
|
|
29
|
+
| `validate_api_key=` | Accepted: E2B documents it as having no effect. |
|
|
30
|
+
| `debug=True`, `retries=`, `http_version=`, `sandbox_url=`, `logger=` | NO. Raise `SolariCompatUnsupported` (`debug=False` is fine). They configure E2B's own transport and local debug mode. |
|
|
31
|
+
| An unknown option | `TypeError`, as for any Python signature. No call swallows keyword arguments any more. |
|
|
32
|
+
| `api_key=` / `domain=` / `api_url=` on a call of an already connected sandbox | NO when it points elsewhere than the sandbox's own account; pass them to `create` / `connect`. |
|
|
33
|
+
| `timeout=` arguments | Seconds, as in E2B. |
|
|
34
|
+
| `E2B(...)` client, `ApiClient`, `ConnectionConfig`, `VolumeConnectionConfig`, `client` | NO. Real classes (they import, annotate and subclass), construction or use raises. |
|
|
35
|
+
| Context manager | `with Sandbox.create() as s:` / `async with await AsyncSandbox.create() as s:` kill the sandbox on exit. |
|
|
36
|
+
|
|
37
|
+
## Sandbox
|
|
38
|
+
| Call | Status | Notes |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `Sandbox.create(template, timeout, metadata, envs, lifecycle, volume_mounts, ...)` | OK, live | `template`: `base`, a name from `Template.build`, or a `tpl_…` id. Default `base` (`code-interpreter-v2` in `solari_e2b.code_interpreter`). |
|
|
41
|
+
| `timeout` | DIFF | E2B's is a lifetime; Solari's is a rolling idle window that resets on use. Default 300 s as in E2B. The per-plan deadline still bounds total life. |
|
|
42
|
+
| `lifecycle={'on_timeout': ..., 'auto_resume': ...}` | OK | `{'action': 'pause', 'mode': 'filesystem'}` pauses with RAM too (a superset). |
|
|
43
|
+
| `volume_mounts={path: Volume \| 'vol_…' \| name}` | OK | Solari persistent volumes: a `Volume` / `AsyncVolume` object, an id or a name. Solari does not keep volume names unique (E2B does), so a name that matches more than one volume raises `InvalidArgumentException` naming the ids (mount one by its id) instead of picking one, and `Volume.create` refuses a name that is already taken. Volumes cannot be combined with `allow_internet_access=False` (below). |
|
|
44
|
+
| `secure=True` / unset | OK | Sandboxes are always access-controlled. `secure=False`: NO. |
|
|
45
|
+
| `allow_internet_access=False`, `network={'deny_out': ['0.0.0.0/0']}` (also as `lambda ctx: [ctx.all_traffic]`) | OK | Maps to Solari's `hardened` isolation (outbound network blocked). A host that cannot do it answers 409 and you get `SolariCompatUnsupported('allow_internet_access: False', ...)`. Together with `volume_mounts` it raises `SolariCompatUnsupported` before any request: Solari cannot mount volumes on a sandbox with internet access disabled (remove one of the two). Any other `network` (allow lists, partial deny lists, rules, egress proxy, DNS servers, public-traffic switches), `iam`, `mcp`, `logger`: NO. |
|
|
46
|
+
| `Sandbox.connect(id, timeout)`, `sbx.connect()` | OK, live | Resumes a paused or stopped sandbox. `on_resume='reboot'`: NO. |
|
|
47
|
+
| `Sandbox.list(query=SandboxQuery(...), limit, next_token, order)` | DIFF | Paginator with `has_next`, `next_token`, `next_items()`. Filters: `metadata`, `state` (by Solari), `template` and `started_after` (strictly after; applied to each page here; if the gateway does not report the field they raise). `order='asc'` reads the whole result and pages it oldest first (Solari lists newest first and cannot sort). `SandboxInfo.template_id` is what the gateway reports (empty if it omits it); `allow_internet_access` is `False` for a blocked-network sandbox; `lifecycle` and `volume_mounts` are what the sandbox was created with through this package (kept in a hidden metadata key `e2b.info`, continued in `e2b.info.1`, `e2b.info.2`, … when it is long (each entry at most 1000 characters, so many mounts are never cut off); none are shown in `info.metadata` and you cannot set them yourself), `None` / empty for sandboxes created elsewhere; `network` is `{'deny_out': ['0.0.0.0/0']}` or `None`. Solari `starting` counts as running, `stopped` as paused. |
|
|
48
|
+
| `get_info`, `is_running`, `kill`, `set_timeout` | OK, live | Usable on the class with an id (`Sandbox.kill(id)`) or on an instance. `kill` returns `False` for a sandbox that is already gone. |
|
|
49
|
+
| `get_metrics(start, end)` | DIFF | One current sample (no history), returned only if "now" is inside `[start, end]`, else an empty list; `mem_cache` is 0. |
|
|
50
|
+
| `pause()`, `beta_pause()` | OK, live | Keeps RAM and disk. `mode='filesystem'`, `keep_memory=False`: treated as a full pause (a superset; the sandbox resumes warm, not rebooted). Giving both `mode` and `keep_memory`, or an unknown `mode`, raises `InvalidArgumentException` as in E2B. |
|
|
51
|
+
| `create_snapshot(name=)`, `list_snapshots(...)`, `Sandbox.delete_snapshot(id)` | OK, live | Snapshots are RAM + disk. `mode='filesystem'` is ignored. Pages follow the gateway's cursor (`next_token` / `has_next`); a name lookup reads up to 1000 snapshots per page. `sbx.list_snapshots()` lists snapshots taken of that sandbox. Class-level listing over every sandbox is `Sandbox.list_all_snapshots(name=)` (extension). |
|
|
52
|
+
| `fork(count=)` | DIFF, live | Checkpoint then `count` new sandboxes from it; the gateway will not delete a checkpoint while a copy is alive, so each copy carries the checkpoint id in a hidden metadata key (`e2b.forkSnapshot`, not shown in `info.metadata`; you cannot set it yourself) and the **last copy killed deletes it** (waiting up to ~40 s). A copy that is not killed (it expires on its idle timeout) keeps the checkpoint, which is billed snapshot storage: kill your copies. Returns a sandbox or an exception per copy. |
|
|
53
|
+
| `get_host(port)` | NO | E2B returns the host synchronously; Solari mints preview URLs on the gateway. Use the extension `sbx.get_preview_url(port)` (returns `{'url': ..., 'token': ...}`). |
|
|
54
|
+
| `upload_url`, `download_url` | OK | `user=` and `use_signature_expiration=`: NO (the gateway chooses the lifetime). `get_signature(...)` reproduces E2B's signature computation. |
|
|
55
|
+
| `git` | OK | E2B's git helper (`clone`, `init`, `remote_add`, `remote_get`, `status`, `branches`, `create_branch`, `checkout_branch`, `delete_branch`, `add`, `commit`, `reset`, `restore`, `push`, `pull`, `set_config`, `get_config`, `dangerously_authenticate`, `configure_user`) run as `git` commands in the sandbox, with `GIT_TERMINAL_PROMPT=0`; credentials are never left in the stored remote. The sandbox image needs git. `Git` is the blocking class, `AsyncGit` the async one. |
|
|
56
|
+
| `update_network`, `get_mcp_url`, `envd_api_url`, `envd_direct_url`, `connection_config` | NO | `get_mcp_token()` returns `None` (MCP cannot be enabled), `traffic_access_token` is `None`. |
|
|
57
|
+
| `Volume` / `AsyncVolume` | DIFF | `create`, `connect`, `get_info(volume_id)`, `list()`, `destroy` and mounting work (Solari persistent volumes). Reading and writing a volume's files without a sandbox (`read_file`, `write_file`, `make_dir`, `exists`, `update_metadata`, `remove`, instance `get_info` / `list`) and `token`: NO; mount the volume and use `sandbox.files`. |
|
|
58
|
+
| `Secret` / `AsyncSecret` | NO | On purpose: E2B substitutes a secret into outbound requests so sandbox code never sees it; Solari injects an account secret into the sandbox environment, so mapping one onto the other would expose the value. |
|
|
59
|
+
| Lifecycle events API, webhooks, OTel export, sandbox logs API | NO | |
|
|
60
|
+
|
|
61
|
+
## Commands and PTY
|
|
62
|
+
| Call | Status | Notes |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| `commands.run(cmd, ...)` | OK, live | Runs `bash -lc` (a POSIX `sh` on images without bash) from the home directory. A non-zero exit raises `CommandExitException` (`stdout`, `stderr`, `exit_code`, `error`). `timeout` default 60 s (0 disables) stops the command and raises `TimeoutException`. `on_stdout` / `on_stderr` (sync or async callables), `envs`, `cwd`, `user`, `request_timeout`: OK. |
|
|
65
|
+
| `stdin=` | OK, live | As in E2B, a command starts with stdin closed (a program reading it gets end-of-file at once) unless `stdin=True`; `send_stdin` on a command started without it raises. |
|
|
66
|
+
| `commands.run(cmd, background=True)` | OK, live | Returns a command handle: `pid`, `stdout`, `stderr`, `exit_code`, `error`, `wait()`, `kill()`, `send_stdin()`, `disconnect()`. In the blocking API the handle is iterable (`for stdout, stderr, pty in handle`) and `wait(on_pty, on_stdout, on_stderr)` takes callbacks, as E2B's. |
|
|
67
|
+
| `timeout=` of a background command, of `connect` and of `pty.create` | DIFF | An explicit `timeout` > 0 cuts your connection to the process after that many seconds (callbacks stop, `wait()` raises `TimeoutException`, the process keeps running; `commands.connect(pid)` reattaches). Not set, or 0: the connection is never cut (E2B's default is 60 s). |
|
|
68
|
+
| `commands.list`, `kill(pid)`, `send_stdin(pid)`, `connect(pid)`, `stream_input(pid)` | DIFF | `pid` is a number this package hands out; Solari keeps the process on the control channel that started it. These work for commands started by **this process**; another process gets `NotFoundException`. `kill` returns `False` for a command that is already gone. |
|
|
69
|
+
| `close_stdin` | NO | Solari cannot close a command's stdin. End the program another way (for example a sentinel line). |
|
|
70
|
+
| `pty.create(PtySize(rows, cols), on_data)`, `send_stdin`, `resize`, `kill`, `stream_input` | OK, live | `connect(pid)`: this process only. The shell starts with `TERM=xterm-256color`, `LANG` / `LC_ALL=C.UTF-8` as in E2B. A shell that exits by itself is observed: `wait()` resolves with its exit code. `kill(pid)` returns `True` when it killed the PTY and `False` when the PTY had already ended or is unknown (it never raises for that). `user=`: NO. The blocking `pty.create(size, user, cwd, envs, timeout, request_timeout)` has no `on_data`: read the handle. |
|
|
71
|
+
|
|
72
|
+
## Filesystem
|
|
73
|
+
| Call | Status | Notes |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `read(path, format='text' \| 'bytes' \| 'stream')` | OK, live | Relative paths resolve against the guest's `$HOME`. `bytes` returns a `bytearray`. `stream` returns an async-iterable reader with one chunk (async API only; with the blocking API read with `format='bytes'`). A missing file raises `FileNotFoundException`. |
|
|
76
|
+
| `write(path, data)`, `write_files(entries)` | OK, live | `str`, `bytes` or a file-like object. Parent directories are created. `metadata=`: NO. `gzip`, `use_octet_stream`: how E2B encodes the HTTP upload; Solari writes over its control channel, so they change nothing (the file is the same). Likewise `read(gzip=, stream_idle_timeout=)`. |
|
|
77
|
+
| `list(path, depth)`, `get_info` | OK, live | Every symlink (also a dangling one) is returned as itself: `type=FileType.SYMLINK`, `symlink_target`, `permissions` like `Lrwxrwxrwx`, and it is not descended into by `depth`. `owner` and `group` are filled in. One extra shell command per listing does this (it needs `/bin/sh`; without it the plain listing is used: links are followed, `owner` / `group` are empty, and a dangling link raises). |
|
|
78
|
+
| `exists`, `make_dir`, `rename`, `remove` | OK, live | |
|
|
79
|
+
| `watch_dir(path, on_event, recursive=)` | DIFF, live | `FilesystemEvent.name` is relative to the watched path. Solari reports creates as `write`. `include_entry=True` adds the entry (best effort: none when the path is already gone). `allow_network_mounts` has no effect (Solari's watcher has no such limit). A watch ends after `timeout` seconds (default 60; 0 disables); `on_exit(None)` is called once, whether it timed out or you called `stop()`. |
|
|
80
|
+
| `user=` on any filesystem call | NO | |
|
|
81
|
+
|
|
82
|
+
## Code interpreter (`solari_e2b.code_interpreter`)
|
|
83
|
+
| Call | Status | Notes |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `run_code(code, language=None, context=None, ...)` | OK, live | Python (and `bash`). Passing both `language` and `context` raises `InvalidArgumentException`. Python state persists across calls in the default context. |
|
|
86
|
+
| `run_code(..., envs=)` | OK, live | Set in the kernel's `os.environ` (or passed to `bash`) for that run only and put back after it, also when the code fails. |
|
|
87
|
+
| Other languages | NO | The guest ships a Python kernel only: `javascript`, `typescript`, `r`, `java` raise. `bash` runs each call as a fresh shell (no state between calls). |
|
|
88
|
+
| `on_stdout`, `on_stderr`, `on_result`, `on_error` | DIFF | Called after the run finishes, not while it runs (Solari returns the result in one reply). Sync or async callables. |
|
|
89
|
+
| `Execution` (`results`, `logs`, `error`, `text`) | DIFF | `execution_count` is `None`. `error` is `ExecutionError(name, value, traceback)`. The last result with a text repr is `is_main_result`. |
|
|
90
|
+
| `Result` formats | DIFF | `text`, `html`, `markdown`, `svg`, `png`, `jpeg`, `latex`, `json` (as given by the kernel), `chart`. `pdf`, `javascript`, `data` and `extra` are not produced. `chart` is E2B's class for its type (`LineChart`, `ScatterChart`, `BarChart`, `SuperChart`, ... in `solari_e2b.code_interpreter.charts`) and appears when the guest kernel extracts a structured chart (not for every figure). |
|
|
91
|
+
| `envs=` per run | NO | |
|
|
92
|
+
| `timeout=` | DIFF | Stops waiting and raises `TimeoutException`; the kernel keeps running the code. No default timeout (E2B's is 300 s). |
|
|
93
|
+
| `create_code_context(cwd, language)` | OK, live | Python only. |
|
|
94
|
+
| `list_code_contexts`, `remove_code_context`, `restart_code_context` | DIFF, live | Solari cannot list or destroy kernels. `list` returns contexts created by this process; `remove` forgets the context (the kernel stays until the sandbox ends); `restart` clears the context's variables and working directory without restarting the process. |
|
|
95
|
+
| Default template | DIFF | `code-interpreter-v2` is built into your org on first `Sandbox.create()` without a template: about 80 seconds, billed as a template build, and two processes that both find it missing each start a build. `build_code_interpreter_template()` (async) / `build_code_interpreter_template_sync()` prebuild it. |
|
|
96
|
+
|
|
97
|
+
## Templates
|
|
98
|
+
| Call | Status | Notes |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `Template().from_base_image / from_image / from_python_image / from_node_image / from_ubuntu_image / from_debian_image / from_alpine_image / from_fedora_image / from_arch_image / from_bun_image / from_template` | OK, live | `from_base_image()` is Solari's base image. The others are public registry images. Credentials, `from_aws_registry`, `from_gcp_registry`, `from_dockerfile`: NO. |
|
|
101
|
+
| `apt_install`, `pip_install`, `npm_install`, `bun_install`, `run_cmd`, `make_dir`, `remove`, `rename`, `make_symlink`, `git_clone`, `set_workdir`, `set_envs` | OK, live | Compiled onto Solari's image steps. `set_envs` persists in the template (E2B: build time only). `user=` other than `root`: NO. Quoting uses `shlex`, so simple words are not quoted. |
|
|
102
|
+
| `copy`, `copy_items` (and `force_upload`, `resolve_symlinks`, `gzip`, `Template(file_ignore_patterns=)` that only matter through them) | NO | The Solari gateway does not accept local files in a template build yet (it answers `LocalFilesUnsupported`), so this raises when called instead of failing at build time. Fetch files inside the build with `run_cmd` (`curl`) or `git_clone`. |
|
|
103
|
+
| `set_user`, `set_start_cmd`, `set_ready_cmd`, `add_mcp_server`, dev containers | NO | Solari templates run no start command. Start processes after `Sandbox.create` with `commands.run(..., background=True)`. |
|
|
104
|
+
| `skip_cache()`, `skip_cache=` | OK | Nothing to skip: Solari has no build cache, every build runs every step. |
|
|
105
|
+
| `Template.build(template, name)`, `build_in_background`, `get_build_status`, `exists`, `alias_exists` | OK, live | `name:latest` is accepted; any other tag, and `tags=`: NO. `min_free_disk_mb=`: NO. `on_build_logs` receives a start entry, the build's own log lines (polled every few seconds from the gateway's build log), and an end entry. `get_build_status(..., logs_offset=)` returns `log_entries` / `logs` from that offset of the gateway's log tail (`stdout` lines are `info`, `stderr` lines `error`); the gateway keeps the newest 5000 lines of a build: `on_build_logs` keeps delivering new lines once that window is full (it finds where it left off), but a line that scrolled out before it was polled is lost, and `logs_offset` counts lines of the current window. A background build delivers only its start entry to `on_build_logs`. If the gateway cannot return the tail from the replica that answers (it keeps it in memory per replica), `log_entries` is empty and a warning says so. `status` is a `TemplateBuildStatus`, `reason` a `BuildStatusReason`. `Template.build` blocks (the `AsyncTemplate` twin is awaitable). |
|
|
106
|
+
| `Template.assign_tags`, `remove_tags`, `get_tags`, `to_json`, `to_dockerfile` | NO | |
|
|
107
|
+
|
|
108
|
+
## Python-specific differences
|
|
109
|
+
- The Python SDK's `GET /sandboxes/:id` view drops the creation time and the native-image marker, so this package reads that
|
|
110
|
+
route directly. `SandboxInfo.started_at` is the creation time when the gateway reports it, else the epoch.
|
|
111
|
+
- The blocking API runs the async client on one daemon thread. Calling it from one of your own callbacks (which run on that
|
|
112
|
+
thread) raises `RuntimeError`; use `AsyncSandbox` there. Callbacks passed to blocking calls (`on_stdout`, `on_result`, ...) run
|
|
113
|
+
on that thread as output arrives; to read output on your own thread, iterate the handle or use `handle.wait(on_stdout=...)`.
|
|
114
|
+
- The blocking classes follow E2B's blocking signatures where they differ from the async ones: `pty.create(size, user, cwd, envs, timeout, request_timeout)`
|
|
115
|
+
(no `on_data`), `commands.connect(pid, timeout, request_timeout)` (no callbacks), `commands.stream_input(pid, data)` (sends `data`),
|
|
116
|
+
`files.watch_dir(path, user, request_timeout, recursive, include_entry, allow_network_mounts)` (a polled handle).
|
|
117
|
+
- `Sandbox.git`, `Git`, `AsyncGit`, `Volume`, `AsyncVolume`, `CommandHandle`, `WatchHandle`, `SandboxPaginator`, `SnapshotPaginator`
|
|
118
|
+
exist as the blocking classes E2B names; the async ones are `AsyncGit`, `AsyncVolume`, `AsyncCommandHandle`, ...
|
|
119
|
+
- Error classes carry `status_code` when the answer came from the Solari API; `CommandExitException` is also a `CommandResult` and prints as E2B's does.
|
|
120
|
+
- Tested on Python 3.14; the code avoids syntax newer than 3.9 but only 3.14 is exercised here.
|
|
121
|
+
|
|
122
|
+
## Default user and home directory (matching E2B)
|
|
123
|
+
**Sandboxes run as `user` in `/home/user` on the hosted Solari API, matching E2B's default** (checked on staging and production on 2026-11-03). Only a gateway or a template that predates user support falls back to root, as below.
|
|
124
|
+
|
|
125
|
+
Here, E2B sandboxes run as `user` in `/home/user`; commands, code and files all start there, and relative paths resolve against it. This package
|
|
126
|
+
asks the gateway for exactly that at create time (`user: "user"`, `cwd: "/home/user"`; the gateway creates the user at first boot with passwordless
|
|
127
|
+
sudo). Restores from a snapshot keep the snapshot's own user.
|
|
128
|
+
- **Gateway that predates `user` / `cwd`** (it answers 400 naming them, or ignores them): the plain create is used and the sandbox runs as **root in
|
|
129
|
+
`/home/root`**, which is what this package did before. Check `whoami` if code depends on it.
|
|
130
|
+
- **Template or snapshot made before user support** (the server answers 400 naming `user` with "the guest predates user support"): the plain create is used, the sandbox runs as **root**, and one warning says so. Rebuild the template to get the vendor user. The default code-interpreter template is named `code-interpreter-v2`, so upgrading this package builds a fresh one on first `Sandbox.create()`; an older `code-interpreter-v1` in your org is left alone and no longer used.
|
|
131
|
+
- Shared isolation is commands and code only and takes no `user` / `cwd`; the compat packages never create shared sandboxes. `commands.run(..., user=)` is passed to the guest per call; `user=` on filesystem calls stays NO.
|
|
132
|
+
|
|
133
|
+
## Snapshots, results and listing (0.2.1)
|
|
134
|
+
- A template name that starts with `snap_` is always read as a snapshot id (name your templates otherwise). `Sandbox.create("snap_…")` restores from that snapshot (E2B's snapshot docs); killing the restored sandbox never deletes the snapshot.
|
|
135
|
+
- Blocking API: `Sandbox.list_snapshots()` (no arguments, or `sandbox_id=`) and `sandbox.list_snapshots()` return a paginator you page with `next_items()`;
|
|
136
|
+
`files.watch_dir(path, user=None, request_timeout=None, recursive=False, include_entry=False, allow_network_mounts=False)` has the sync signature (no `on_event`) and returns a handle whose
|
|
137
|
+
`get_new_events()` returns what arrived since the last call and `stop()` ends the watch.
|
|
138
|
+
- `run_code`: `logs.stdout` / `logs.stderr` hold one entry per line; an HTML-only DataFrame result also gets `text`; a PNG figure also gets `chart`
|
|
139
|
+
(same rules as the TypeScript package; the kernel snippets are kept identical by a test). Error messages carry only 8 characters of a sandbox id.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: solari-e2b-compat
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B.
|
|
5
5
|
Project-URL: Homepage, https://getsolari.com
|
|
6
6
|
Author: Solari
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "solari-e2b-compat"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.5"
|
|
8
8
|
description = "E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# ruff: noqa: F401
|
|
2
|
+
"""solari_e2b: an E2B-compatible Python API on Solari Sandbox. Not affiliated with E2B. See README.md, COMPAT.md, NOTICE.
|
|
3
|
+
|
|
4
|
+
``from solari_e2b import Sandbox`` (blocking) or ``AsyncSandbox``; ``from solari_e2b.code_interpreter import Sandbox`` for
|
|
5
|
+
``run_code``. Every name that ``e2b`` exports exists here: what Solari can do works, and what it cannot raises
|
|
6
|
+
``SolariCompatUnsupported`` when it is used (never at import)."""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from ._commands import AsyncCommandHandle, AsyncCommandInputHandle, AsyncCommands, AsyncPty
|
|
13
|
+
from ._config import DEFAULT_BASE_URL, is_solari_base_url
|
|
14
|
+
from ._filesystem import AsyncFileStreamReader, AsyncFilesystem, AsyncWatchHandle
|
|
15
|
+
from ._git import AsyncGit, GitBranches, GitFileStatus, GitResetMode, GitStatus
|
|
16
|
+
from ._sandbox import AsyncSandbox, AsyncSandboxPaginator, AsyncSnapshotPaginator
|
|
17
|
+
from ._sync import CommandHandle, Git, Sandbox, SandboxPaginator, SnapshotPaginator, WatchHandle
|
|
18
|
+
from ._template import (
|
|
19
|
+
AsyncTemplate,
|
|
20
|
+
BuildInfo,
|
|
21
|
+
BuildStatusReason,
|
|
22
|
+
CopyItem,
|
|
23
|
+
LogEntry,
|
|
24
|
+
LogEntryEnd,
|
|
25
|
+
LogEntryLevel,
|
|
26
|
+
LogEntryStart,
|
|
27
|
+
ReadyCmd,
|
|
28
|
+
Template,
|
|
29
|
+
TemplateBase,
|
|
30
|
+
TemplateBuildStatus,
|
|
31
|
+
TemplateBuildStatusResponse,
|
|
32
|
+
TemplateClass,
|
|
33
|
+
TemplateTag,
|
|
34
|
+
TemplateTagInfo,
|
|
35
|
+
default_build_logger,
|
|
36
|
+
wait_for_file,
|
|
37
|
+
wait_for_port,
|
|
38
|
+
wait_for_process,
|
|
39
|
+
wait_for_timeout,
|
|
40
|
+
wait_for_url,
|
|
41
|
+
)
|
|
42
|
+
from ._volume import AsyncVolume, Volume
|
|
43
|
+
from .exceptions import * # noqa: F401,F403
|
|
44
|
+
from .exceptions import DockerfileSyntaxError, SolariCompatUnsupported, unsupported_class
|
|
45
|
+
from .models import * # noqa: F401,F403
|
|
46
|
+
from .models import ALL_TRAFFIC, ApiParams, HttpVersion, OutputHandler, ProxyTypes, SecretInfo, Signature, Username, VolumeApiParams, get_signature
|
|
47
|
+
|
|
48
|
+
_SECRET_WHY = (
|
|
49
|
+
"E2B substitutes a secret into outbound requests so code in the sandbox never sees its value, while Solari injects an account "
|
|
50
|
+
"secret into the sandbox environment; mapping one onto the other would expose the value to the sandbox"
|
|
51
|
+
)
|
|
52
|
+
_SECRET_METHODS = ("create", "update", "get_info", "list", "exists", "destroy", "fill", "iam_token")
|
|
53
|
+
Secret = unsupported_class("Secret", _SECRET_WHY, _SECRET_METHODS)
|
|
54
|
+
AsyncSecret = unsupported_class("AsyncSecret", _SECRET_WHY, _SECRET_METHODS)
|
|
55
|
+
SecretPaginator = unsupported_class("SecretPaginator", _SECRET_WHY)
|
|
56
|
+
AsyncSecretPaginator = unsupported_class("AsyncSecretPaginator", _SECRET_WHY)
|
|
57
|
+
|
|
58
|
+
_NO_CLIENT = "use the Sandbox / AsyncSandbox / Template classes directly; the key and base URL come from SOLARI_API_KEY / SOLARI_BASE_URL or the api_key / api_url options"
|
|
59
|
+
#: E2B's client object that binds connection options to its resource classes.
|
|
60
|
+
E2B = unsupported_class("E2B", _NO_CLIENT)
|
|
61
|
+
E2BClientParams = ApiParams
|
|
62
|
+
#: E2B's generated REST client and its transport configuration objects: Solari has its own client.
|
|
63
|
+
ApiClient = unsupported_class("ApiClient", "this package talks to Solari with its own client")
|
|
64
|
+
ConnectionConfig = unsupported_class("ConnectionConfig", "connection settings are the api_key / api_url options and SOLARI_API_KEY / SOLARI_BASE_URL")
|
|
65
|
+
VolumeConnectionConfig = unsupported_class("VolumeConnectionConfig", "Solari volumes have no content API of their own")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class _UnsupportedModule:
|
|
69
|
+
"""Stands in for ``e2b.client`` (the generated REST client module): any attribute raises."""
|
|
70
|
+
|
|
71
|
+
def __getattr__(self, name: str) -> Any:
|
|
72
|
+
if name.startswith("__"):
|
|
73
|
+
raise AttributeError(name)
|
|
74
|
+
raise SolariCompatUnsupported(f"client.{name}", "E2B's generated REST client is not available; this package talks to Solari with its own client")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
client = _UnsupportedModule()
|
|
78
|
+
|
|
79
|
+
__version__ = "0.2.5"
|