solari-e2b-compat 0.2.9__tar.gz → 0.2.10__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.9 → solari_e2b_compat-0.2.10}/COMPAT.md +1 -1
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/PKG-INFO +1 -1
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/pyproject.toml +1 -1
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/__init__.py +1 -1
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_git.py +53 -35
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/.gitignore +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/LICENSE +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/LICENSE-E2B +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/NOTICE +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/README.md +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_box.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_commands.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_config.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_filesystem.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_loop.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_redact.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_request.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_sandbox.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_sync.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_template.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_vendor_user.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/_volume.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/__init__.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/charts.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/client.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/code_interpreter_async.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/code_interpreter_sync.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/constants.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/exceptions.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/models.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/exceptions.py +0 -0
- {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/models.py +0 -0
|
@@ -54,7 +54,7 @@ and the differences that are specific to Python.
|
|
|
54
54
|
| `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. |
|
|
55
55
|
| `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': ...}`). |
|
|
56
56
|
| `upload_url`, `download_url` | OK | `user=` and `use_signature_expiration=`: NO (the gateway chooses the lifetime). `get_signature(...)` reproduces E2B's signature computation. |
|
|
57
|
-
| `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. |
|
|
57
|
+
| `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 and never appear in a command line: they travel in the command's environment through a per-command credential helper (`dangerously_store_credentials=True` is the explicit opt-in to keep them in the URL); a branch or remote name that starts with `-` is refused. The sandbox image needs git. `Git` is the blocking class, `AsyncGit` the async one. |
|
|
58
58
|
| `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`. |
|
|
59
59
|
| `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`. |
|
|
60
60
|
| `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. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: solari-e2b-compat
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
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.10"
|
|
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"
|
|
@@ -109,6 +109,33 @@ def with_credentials(url: str, username: Optional[str], password: Optional[str])
|
|
|
109
109
|
return urlunparse(parsed._replace(netloc=f"{username}:{password}@{parsed.netloc}"))
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
# Inline git credential helper: answers ``get`` from the command's environment, ignores ``store``/``erase``, holds no secret.
|
|
113
|
+
GIT_CREDENTIAL_HELPER = '!f() { test "$1" = get && printf "username=%s\\npassword=%s\\n" "$SOLARI_GIT_USERNAME" "$SOLARI_GIT_PASSWORD"; }; f'
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def credential_auth(url: str, username: str, password: str) -> Tuple[List[str], Dict[str, str]]:
|
|
117
|
+
"""Credentials for ONE git command against an http(s) remote: ``(-c options, environment)``. The username and password
|
|
118
|
+
travel as environment variables of that command and git reads them back through the inline helper, so they are never in
|
|
119
|
+
the URL (not in argv, which any process in the sandbox can read from /proc/<pid>/cmdline, and not in ``.git/config``).
|
|
120
|
+
The helper is bound to the remote's origin, so git hands the password to no other host."""
|
|
121
|
+
for v in (username, password):
|
|
122
|
+
if any(ch in v for ch in "\r\n\0"):
|
|
123
|
+
raise InvalidArgumentException("Git credentials must not contain line breaks or NUL.")
|
|
124
|
+
with_credentials(url, username, password) # the same validation as before: http(s) only, both parts present
|
|
125
|
+
parsed = urlparse(url)
|
|
126
|
+
origin = f"{parsed.scheme}://{parsed.netloc.rsplit('@', 1)[-1]}"
|
|
127
|
+
if "=" in origin or any(ch.isspace() for ch in origin):
|
|
128
|
+
raise InvalidArgumentException(f"Invalid Git URL: {url}")
|
|
129
|
+
cfg = ["-c", "credential.helper=", "-c", f"credential.{origin}.helper={GIT_CREDENTIAL_HELPER}"]
|
|
130
|
+
return cfg, {"SOLARI_GIT_USERNAME": username, "SOLARI_GIT_PASSWORD": password}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def reject_option_like(what: str, value: Optional[str]) -> None:
|
|
134
|
+
"""A branch or remote name that starts with "-" would be read by git as an option; git forbids such branch names anyway."""
|
|
135
|
+
if value is not None and value.startswith("-"):
|
|
136
|
+
raise InvalidArgumentException(f'Git {what} must not start with "-": {value!r}')
|
|
137
|
+
|
|
138
|
+
|
|
112
139
|
def strip_credentials(url: str) -> str:
|
|
113
140
|
parsed = urlparse(url)
|
|
114
141
|
if parsed.scheme not in ("http", "https") or not (parsed.username or parsed.password):
|
|
@@ -272,7 +299,10 @@ class AsyncGit:
|
|
|
272
299
|
async def _run(self, cmd: str, envs: Optional[Dict[str, str]], user: Optional[str], cwd: Optional[str], timeout: Optional[float], request_timeout: Optional[float]) -> Any:
|
|
273
300
|
return await self._commands.run(cmd, envs={**DEFAULT_GIT_ENV, **(envs or {})}, user=user, cwd=cwd, timeout=timeout, request_timeout=request_timeout)
|
|
274
301
|
|
|
275
|
-
async def _git(self, args: List[str], repo_path: Optional[str], envs=None, user=None, cwd=None, timeout=None, request_timeout=None) -> Any:
|
|
302
|
+
async def _git(self, args: List[str], repo_path: Optional[str], envs=None, user=None, cwd=None, timeout=None, request_timeout=None, auth: Optional[Tuple[List[str], Dict[str, str]]] = None) -> Any:
|
|
303
|
+
if auth:
|
|
304
|
+
args = list(auth[0]) + list(args)
|
|
305
|
+
envs = {**(envs or {}), **auth[1]}
|
|
276
306
|
return await self._run(build_git_command(args, repo_path), envs, user, cwd, timeout, request_timeout)
|
|
277
307
|
|
|
278
308
|
async def _remote_url(self, path: str, remote: str, *c: Any) -> str:
|
|
@@ -289,26 +319,9 @@ class AsyncGit:
|
|
|
289
319
|
return remotes[0]
|
|
290
320
|
raise InvalidArgumentException("Remote is required when using username/password and the repository has multiple remotes.")
|
|
291
321
|
|
|
292
|
-
async def _with_remote_credentials(self, path: str, remote: str, username: str, password: str, c: Tuple[Any, ...], operation: Callable[[], Awaitable[Any]]) -> Any:
|
|
293
|
-
"""Run ``operation`` with the credentials
|
|
294
|
-
|
|
295
|
-
await self._git(["remote", "set-url", remote, with_credentials(original, username, password)], path, *c)
|
|
296
|
-
result: Any = None
|
|
297
|
-
op_error: Optional[BaseException] = None
|
|
298
|
-
try:
|
|
299
|
-
result = await operation()
|
|
300
|
-
except Exception as e: # noqa: BLE001
|
|
301
|
-
op_error = e
|
|
302
|
-
restore_error: Optional[BaseException] = None
|
|
303
|
-
try:
|
|
304
|
-
await self._git(["remote", "set-url", remote, original], path, *c)
|
|
305
|
-
except Exception as e: # noqa: BLE001
|
|
306
|
-
restore_error = e
|
|
307
|
-
if op_error:
|
|
308
|
-
raise op_error
|
|
309
|
-
if restore_error:
|
|
310
|
-
raise restore_error
|
|
311
|
-
return result
|
|
322
|
+
async def _with_remote_credentials(self, path: str, remote: str, username: str, password: str, c: Tuple[Any, ...], operation: Callable[[Tuple[List[str], Dict[str, str]]], Awaitable[Any]]) -> Any:
|
|
323
|
+
"""Run ``operation`` with the credentials on that one command (never in the remote URL; no ``remote set-url``)."""
|
|
324
|
+
return await operation(credential_auth(await self._remote_url(path, remote, *c), username, password))
|
|
312
325
|
|
|
313
326
|
async def clone(
|
|
314
327
|
self,
|
|
@@ -327,25 +340,23 @@ class AsyncGit:
|
|
|
327
340
|
) -> Any:
|
|
328
341
|
if password and not username:
|
|
329
342
|
raise InvalidArgumentException("Username is required when using a password or token for git clone.")
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if
|
|
335
|
-
|
|
336
|
-
args = ["clone"
|
|
343
|
+
reject_option_like("branch", branch)
|
|
344
|
+
# dangerously_store_credentials is the caller's explicit choice to keep the credentials in the remote URL (and so in argv and
|
|
345
|
+
# .git/config). Otherwise they go through the per-command credential helper and are never in the URL.
|
|
346
|
+
has_creds = bool(username and password)
|
|
347
|
+
auth = credential_auth(url, username, password) if has_creds and not dangerously_store_credentials else None # type: ignore[arg-type]
|
|
348
|
+
target = with_credentials(url, username, password) if has_creds and dangerously_store_credentials else url
|
|
349
|
+
args = ["clone"]
|
|
337
350
|
if branch:
|
|
338
351
|
args += ["--branch", branch, "--single-branch"]
|
|
339
352
|
if depth:
|
|
340
353
|
args += ["--depth", str(depth)]
|
|
354
|
+
# "--" ends the options: a "url" such as --upload-pack=cmd is then a (bad) repository, not an option.
|
|
355
|
+
args += ["--", target]
|
|
341
356
|
if path:
|
|
342
357
|
args.append(path)
|
|
343
|
-
c = (envs, user, cwd, timeout, request_timeout)
|
|
344
358
|
try:
|
|
345
|
-
|
|
346
|
-
if should_strip and repo_path:
|
|
347
|
-
await self._git(["remote", "set-url", "origin", sanitized], repo_path, *c)
|
|
348
|
-
return result
|
|
359
|
+
return await self._git(args, None, envs, user, cwd, timeout, request_timeout, auth=auth)
|
|
349
360
|
except CommandExitException as e:
|
|
350
361
|
if is_auth_failure(e):
|
|
351
362
|
raise GitAuthException(_auth_message("clone", bool(username) and not password)) from e
|
|
@@ -380,12 +391,15 @@ class AsyncGit:
|
|
|
380
391
|
return parse_git_branches((await self._git(["branch", "--format=%(refname:short)\t%(HEAD)"], path, envs, user, cwd, timeout, request_timeout)).stdout)
|
|
381
392
|
|
|
382
393
|
async def create_branch(self, path: str, branch: str, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
394
|
+
reject_option_like("branch name", branch)
|
|
383
395
|
return await self._git(["checkout", "-b", branch], path, envs, user, cwd, timeout, request_timeout)
|
|
384
396
|
|
|
385
397
|
async def checkout_branch(self, path: str, branch: str, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
398
|
+
reject_option_like("branch name", branch)
|
|
386
399
|
return await self._git(["checkout", branch], path, envs, user, cwd, timeout, request_timeout)
|
|
387
400
|
|
|
388
401
|
async def delete_branch(self, path: str, branch: str, force: bool = False, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
402
|
+
reject_option_like("branch name", branch)
|
|
389
403
|
return await self._git(["branch", "-D" if force else "-d", branch], path, envs, user, cwd, timeout, request_timeout)
|
|
390
404
|
|
|
391
405
|
async def add(self, path: str, files: Optional[List[str]] = None, all: bool = True, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
@@ -432,10 +446,12 @@ class AsyncGit:
|
|
|
432
446
|
async def push(self, path: str, remote: Optional[str] = None, branch: Optional[str] = None, set_upstream: bool = True, username: Optional[str] = None, password: Optional[str] = None, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
433
447
|
if password and not username:
|
|
434
448
|
raise InvalidArgumentException("Username is required when using a password or token for git push.")
|
|
449
|
+
reject_option_like("remote", remote)
|
|
450
|
+
reject_option_like("branch", branch)
|
|
435
451
|
c = (envs, user, cwd, timeout, request_timeout)
|
|
436
452
|
if username and password:
|
|
437
453
|
name = await self._remote_name(path, remote, *c)
|
|
438
|
-
return await self._with_remote_credentials(path, name, username, password, c, lambda: self._git(self._push_args(name, remote, branch, set_upstream), path, *c))
|
|
454
|
+
return await self._with_remote_credentials(path, name, username, password, c, lambda auth: self._git(self._push_args(name, remote, branch, set_upstream), path, *c, auth=auth))
|
|
439
455
|
try:
|
|
440
456
|
return await self._git(self._push_args(None, remote, branch, set_upstream), path, *c)
|
|
441
457
|
except CommandExitException as e:
|
|
@@ -453,6 +469,8 @@ class AsyncGit:
|
|
|
453
469
|
async def pull(self, path: str, remote: Optional[str] = None, branch: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
|
|
454
470
|
if password and not username:
|
|
455
471
|
raise InvalidArgumentException("Username is required when using a password or token for git pull.")
|
|
472
|
+
reject_option_like("remote", remote)
|
|
473
|
+
reject_option_like("branch", branch)
|
|
456
474
|
c = (envs, user, cwd, timeout, request_timeout)
|
|
457
475
|
if not remote and not branch:
|
|
458
476
|
try:
|
|
@@ -463,7 +481,7 @@ class AsyncGit:
|
|
|
463
481
|
raise GitUpstreamException(_upstream_message("pull"))
|
|
464
482
|
if username and password:
|
|
465
483
|
name = await self._remote_name(path, remote, *c)
|
|
466
|
-
return await self._with_remote_credentials(path, name, username, password, c, lambda: self._git(self._pull_args(remote, branch, name), path, *c))
|
|
484
|
+
return await self._with_remote_credentials(path, name, username, password, c, lambda auth: self._git(self._pull_args(remote, branch, name), path, *c, auth=auth))
|
|
467
485
|
try:
|
|
468
486
|
return await self._git(self._pull_args(remote, branch), path, *c)
|
|
469
487
|
except CommandExitException as e:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/constants.py
RENAMED
|
File without changes
|
{solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|