solari-e2b-compat 0.2.8__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.
Files changed (32) hide show
  1. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/COMPAT.md +2 -2
  2. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/PKG-INFO +2 -2
  3. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/pyproject.toml +2 -2
  4. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/__init__.py +1 -1
  5. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_box.py +9 -3
  6. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_git.py +53 -35
  7. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_sync.py +22 -1
  8. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/.gitignore +0 -0
  9. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/LICENSE +0 -0
  10. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/LICENSE-E2B +0 -0
  11. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/NOTICE +0 -0
  12. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/README.md +0 -0
  13. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_commands.py +0 -0
  14. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_config.py +0 -0
  15. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_filesystem.py +0 -0
  16. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_loop.py +0 -0
  17. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_redact.py +0 -0
  18. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_request.py +0 -0
  19. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_sandbox.py +0 -0
  20. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_template.py +0 -0
  21. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_vendor_user.py +0 -0
  22. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/_volume.py +0 -0
  23. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/__init__.py +0 -0
  24. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/charts.py +0 -0
  25. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/client.py +0 -0
  26. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/code_interpreter_async.py +0 -0
  27. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/code_interpreter_sync.py +0 -0
  28. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/constants.py +0 -0
  29. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/exceptions.py +0 -0
  30. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/code_interpreter/models.py +0 -0
  31. {solari_e2b_compat-0.2.8 → solari_e2b_compat-0.2.10}/solari_e2b/exceptions.py +0 -0
  32. {solari_e2b_compat-0.2.8 → 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. |
@@ -74,7 +74,7 @@ and the differences that are specific to Python.
74
74
  ## Filesystem
75
75
  | Call | Status | Notes |
76
76
  |---|---|---|
77
- | `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`. |
77
+ | `read(path, format='text' \| 'bytes' \| 'stream')` | OK, live | Relative paths resolve against the guest's `$HOME` and every path is normalised (no `.`, `..` or doubled slashes; `files.list('.')` entries are `/home/user/x`, not `/home/user/./x`). `bytes` returns a `bytearray`. `stream` returns a reader with one chunk: async-iterable in the async API, a plain iterator of `bytes` in the blocking API. A missing file raises `FileNotFoundException`. |
78
78
  | `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=)`. |
79
79
  | `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). |
80
80
  | `exists`, `make_dir`, `rename`, `remove` | OK, live | |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: solari-e2b-compat
3
- Version: 0.2.8
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
@@ -10,7 +10,7 @@ License-File: LICENSE-E2B
10
10
  License-File: NOTICE
11
11
  Keywords: code-interpreter,compatibility,e2b,sandbox,solari
12
12
  Requires-Python: >=3.9
13
- Requires-Dist: solari-core>=0.4.0
13
+ Requires-Dist: solari-core>=0.7.11
14
14
  Requires-Dist: solari-sandbox>=0.6.1
15
15
  Provides-Extra: test
16
16
  Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
@@ -4,14 +4,14 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "solari-e2b-compat"
7
- version = "0.2.8"
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"
11
11
  license = { text = "MIT" }
12
12
  authors = [{ name = "Solari" }]
13
13
  keywords = ["solari", "sandbox", "e2b", "code-interpreter", "compatibility"]
14
- dependencies = ["solari-sandbox>=0.6.1", "solari-core>=0.4.0"]
14
+ dependencies = ["solari-sandbox>=0.6.1", "solari-core>=0.7.11"]
15
15
 
16
16
  [project.optional-dependencies]
17
17
  test = ["pytest>=7", "pytest-asyncio>=0.23"]
@@ -76,4 +76,4 @@ class _UnsupportedModule:
76
76
 
77
77
  client = _UnsupportedModule()
78
78
 
79
- __version__ = "0.2.8"
79
+ __version__ = "0.2.10"
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  import asyncio
7
7
  import inspect
8
+ import posixpath
8
9
  from typing import Any, Awaitable, Callable, List, Optional, Tuple, TypeVar
9
10
  from urllib.parse import quote
10
11
 
@@ -20,6 +21,10 @@ DEFAULT_HOME = "/home/user"
20
21
  NATIVE_SHELL_SCRIPT = 'if [ -x /bin/bash ]; then exec /bin/bash -c "$1"; else exec /bin/sh -c "$1"; fi'
21
22
 
22
23
 
24
+ def _norm(path: str) -> str:
25
+ return "/" + posixpath.normpath(path).lstrip("/")
26
+
27
+
23
28
  def shell_args(native: bool, command: str) -> Tuple[str, List[str]]:
24
29
  """``(program, args)`` for an E2B-style shell string: ``bash -lc`` normally, native-image safe otherwise."""
25
30
  if native:
@@ -145,11 +150,12 @@ class Box:
145
150
  return home
146
151
 
147
152
  async def abs(self, path: str) -> str:
153
+ """An absolute, normalised path (no ``.``, ``..`` or doubled slashes), like the paths E2B returns."""
148
154
  if path.startswith("/"):
149
- return path
155
+ return _norm(path)
150
156
  home = await self.home()
151
157
  if path == "~":
152
158
  return home
153
159
  if path.startswith("~/"):
154
- return f"{home}/{path[2:]}"
155
- return f"{home}/{path}"
160
+ return _norm(f"{home}/{path[2:]}")
161
+ return _norm(f"{home}/{path}")
@@ -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 in the remote URL, then put the original URL back (also on failure)."""
294
- original = await self._remote_url(path, remote, *c)
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
- clone_url = with_credentials(url, username, password) if username and password else url
331
- sanitized = strip_credentials(clone_url)
332
- should_strip = not dangerously_store_credentials and sanitized != clone_url
333
- repo_path = path if not should_strip else path or derive_repo_dir_from_url(url)
334
- if should_strip and not repo_path:
335
- raise InvalidArgumentException("A destination path is required when using credentials without storing them.")
336
- args = ["clone", clone_url]
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
- result = await self._git(args, None, *c)
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:
@@ -11,7 +11,7 @@ import inspect
11
11
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
12
12
 
13
13
  from ._commands import BUFFER_EVENTS, DEFAULT_COMMAND_TIMEOUT, AsyncCommandHandle, AsyncCommandInputHandle, AsyncCommands, AsyncPty
14
- from ._filesystem import AsyncFilesystem, AsyncWatchHandle
14
+ from ._filesystem import AsyncFileStreamReader, AsyncFilesystem, AsyncWatchHandle
15
15
  from ._git import AsyncGit
16
16
  from ._loop import LOOP
17
17
  from ._request import bounded
@@ -206,7 +206,28 @@ for _m in [n for n in dir(AsyncGit) if not n.startswith("_") and inspect.iscorou
206
206
  del _m
207
207
 
208
208
 
209
+ class FileStreamReader:
210
+ """E2B's blocking ``files.read(format='stream')``: an iterator of bytes chunks."""
211
+
212
+ def __init__(self, reader: AsyncFileStreamReader) -> None:
213
+ self._r = reader
214
+
215
+ def __iter__(self) -> "FileStreamReader":
216
+ return self
217
+
218
+ def __next__(self) -> bytes:
219
+ try:
220
+ return LOOP.run(self._r.__anext__())
221
+ except StopAsyncIteration:
222
+ raise StopIteration from None
223
+
224
+ def close(self) -> None:
225
+ LOOP.run(self._r.aclose())
226
+
227
+
209
228
  def wrap(v: Any) -> Any:
229
+ if isinstance(v, AsyncFileStreamReader):
230
+ return FileStreamReader(v)
210
231
  if isinstance(v, AsyncFilesystem):
211
232
  return SyncFilesystem(v)
212
233
  if isinstance(v, AsyncCommands):