langchain-e2b 0.0.4__tar.gz → 0.0.6__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.
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/CHANGELOG.md +11 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/PKG-INFO +18 -2
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/README.md +16 -0
- langchain_e2b-0.0.6/langchain_e2b/__init__.py +11 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/langchain_e2b/_version.py +1 -1
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/langchain_e2b/provider.py +94 -1
- langchain_e2b-0.0.6/langchain_e2b/sandbox.py +791 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/pyproject.toml +2 -2
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/integration_tests/test_integration.py +52 -1
- langchain_e2b-0.0.6/tests/unit_tests/test_async_sandbox.py +345 -0
- langchain_e2b-0.0.6/tests/unit_tests/test_import.py +24 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/unit_tests/test_provider.py +136 -4
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/uv.lock +5 -5
- langchain_e2b-0.0.4/langchain_e2b/__init__.py +0 -5
- langchain_e2b-0.0.4/langchain_e2b/sandbox.py +0 -180
- langchain_e2b-0.0.4/tests/unit_tests/test_import.py +0 -13
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/.github/workflows/ci.yml +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/.github/workflows/release.yml +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/.gitignore +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/LICENSE +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/Makefile +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/__init__.py +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/integration_tests/__init__.py +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/test_import.py +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/unit_tests/__init__.py +0 -0
- {langchain_e2b-0.0.4 → langchain_e2b-0.0.6}/tests/unit_tests/test_sandbox.py +0 -0
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## 0.0.6
|
|
6
|
+
|
|
7
|
+
- Tagged E2B SDK traffic with `langchain-e2b/<package-version>` for integration
|
|
8
|
+
attribution.
|
|
9
|
+
- Raised the minimum `e2b` SDK to `2.32.0`.
|
|
10
|
+
|
|
11
|
+
## 0.0.5
|
|
12
|
+
|
|
13
|
+
- Added `AsyncE2BSandbox` backed by `e2b.AsyncSandbox`.
|
|
14
|
+
- Added async E2B provider lifecycle methods for `dcode` async flows.
|
|
15
|
+
|
|
5
16
|
## 0.0.4
|
|
6
17
|
|
|
7
18
|
- Added a Deep Agents Code sandbox provider entry point so `dcode --sandbox e2b`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-e2b
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: E2B sandbox integration for Deep Agents
|
|
5
5
|
Project-URL: Homepage, https://github.com/e2b-dev/langchain-e2b
|
|
6
6
|
Project-URL: Repository, https://github.com/e2b-dev/langchain-e2b
|
|
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
18
18
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
19
|
Requires-Python: <4.0,>=3.11
|
|
20
20
|
Requires-Dist: deepagents<0.7.0,>=0.6.0
|
|
21
|
-
Requires-Dist: e2b<3.0.0,>=2.
|
|
21
|
+
Requires-Dist: e2b<3.0.0,>=2.32.0
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
24
24
|
# langchain-e2b
|
|
@@ -49,6 +49,22 @@ finally:
|
|
|
49
49
|
e2b_sandbox.kill()
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
For async agents, use E2B's async SDK with the async backend:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from e2b import AsyncSandbox
|
|
56
|
+
from langchain_e2b import AsyncE2BSandbox
|
|
57
|
+
|
|
58
|
+
e2b_sandbox = await AsyncSandbox.create()
|
|
59
|
+
backend = AsyncE2BSandbox(sandbox=e2b_sandbox)
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
result = await backend.aexecute("echo hello")
|
|
63
|
+
print(result.output)
|
|
64
|
+
finally:
|
|
65
|
+
await e2b_sandbox.kill()
|
|
66
|
+
```
|
|
67
|
+
|
|
52
68
|
## Deep Agents Code
|
|
53
69
|
|
|
54
70
|
Install `langchain-e2b` into the `dcode` environment, then run with the E2B
|
|
@@ -26,6 +26,22 @@ finally:
|
|
|
26
26
|
e2b_sandbox.kill()
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
For async agents, use E2B's async SDK with the async backend:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from e2b import AsyncSandbox
|
|
33
|
+
from langchain_e2b import AsyncE2BSandbox
|
|
34
|
+
|
|
35
|
+
e2b_sandbox = await AsyncSandbox.create()
|
|
36
|
+
backend = AsyncE2BSandbox(sandbox=e2b_sandbox)
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
result = await backend.aexecute("echo hello")
|
|
40
|
+
print(result.output)
|
|
41
|
+
finally:
|
|
42
|
+
await e2b_sandbox.kill()
|
|
43
|
+
```
|
|
44
|
+
|
|
29
45
|
## Deep Agents Code
|
|
30
46
|
|
|
31
47
|
Install `langchain-e2b` into the `dcode` environment, then run with the E2B
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""E2B sandbox integration for Deep Agents."""
|
|
2
|
+
|
|
3
|
+
from e2b import ConnectionConfig as _ConnectionConfig
|
|
4
|
+
|
|
5
|
+
from langchain_e2b._version import __version__ as _package_version
|
|
6
|
+
from langchain_e2b.sandbox import AsyncE2BSandbox, E2BSandbox
|
|
7
|
+
|
|
8
|
+
# Tag E2B SDK traffic before callers can construct a connection configuration.
|
|
9
|
+
_ConnectionConfig.set_integration(f"langchain-e2b/{_package_version}")
|
|
10
|
+
|
|
11
|
+
__all__ = ["AsyncE2BSandbox", "E2BSandbox"]
|
|
@@ -14,7 +14,7 @@ from deepagents_code.integrations.sandbox_provider import (
|
|
|
14
14
|
SandboxProviderMetadata,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
-
from langchain_e2b.sandbox import DEFAULT_WORKDIR, E2BSandbox
|
|
17
|
+
from langchain_e2b.sandbox import DEFAULT_WORKDIR, AsyncE2BSandbox, E2BSandbox
|
|
18
18
|
|
|
19
19
|
DEFAULT_SANDBOX_TIMEOUT = 30 * 60
|
|
20
20
|
DEFAULT_COMMAND_TIMEOUT = 30 * 60
|
|
@@ -193,6 +193,99 @@ class E2BProvider(SandboxProvider):
|
|
|
193
193
|
except e2b.SandboxNotFoundException as exc:
|
|
194
194
|
raise SandboxNotFoundError(sandbox_id) from exc
|
|
195
195
|
|
|
196
|
+
async def aget_or_create(
|
|
197
|
+
self,
|
|
198
|
+
*,
|
|
199
|
+
sandbox_id: str | None = None,
|
|
200
|
+
timeout: int | str | None = None, # noqa: ASYNC109
|
|
201
|
+
template: str | None = None,
|
|
202
|
+
workdir: str = DEFAULT_WORKDIR,
|
|
203
|
+
command_timeout: int | str | None = None,
|
|
204
|
+
**kwargs: object,
|
|
205
|
+
) -> AsyncE2BSandbox:
|
|
206
|
+
"""Get or create an async E2B sandbox backend.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
sandbox_id: Existing E2B sandbox ID, or `None` to create one.
|
|
210
|
+
timeout: E2B sandbox lifetime in seconds.
|
|
211
|
+
template: E2B template for new sandboxes.
|
|
212
|
+
workdir: Working directory used by command execution.
|
|
213
|
+
command_timeout: Default command timeout for the backend.
|
|
214
|
+
**kwargs: Unsupported provider options.
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
Async E2B sandbox backend.
|
|
218
|
+
|
|
219
|
+
Raises:
|
|
220
|
+
SandboxNotFoundError: If `sandbox_id` does not exist.
|
|
221
|
+
TypeError: If unsupported provider options are passed.
|
|
222
|
+
ValueError: If credentials or timeout settings are invalid.
|
|
223
|
+
"""
|
|
224
|
+
if kwargs:
|
|
225
|
+
_raise_unsupported_kwargs(kwargs)
|
|
226
|
+
|
|
227
|
+
api_key = self._resolve_api_key()
|
|
228
|
+
sandbox_timeout = self._resolve_sandbox_timeout(timeout)
|
|
229
|
+
default_command_timeout = _resolve_int(
|
|
230
|
+
command_timeout,
|
|
231
|
+
name="command_timeout",
|
|
232
|
+
default=DEFAULT_COMMAND_TIMEOUT,
|
|
233
|
+
allow_zero=True,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
try:
|
|
237
|
+
if sandbox_id is not None:
|
|
238
|
+
sandbox = await e2b.AsyncSandbox.connect(
|
|
239
|
+
sandbox_id,
|
|
240
|
+
timeout=sandbox_timeout,
|
|
241
|
+
api_key=api_key,
|
|
242
|
+
)
|
|
243
|
+
else:
|
|
244
|
+
resolved_template = template or _resolve_optional_env_var(
|
|
245
|
+
self._resolve_env_var,
|
|
246
|
+
"E2B_TEMPLATE",
|
|
247
|
+
)
|
|
248
|
+
if resolved_template:
|
|
249
|
+
sandbox = await e2b.AsyncSandbox.create(
|
|
250
|
+
template=resolved_template,
|
|
251
|
+
timeout=sandbox_timeout,
|
|
252
|
+
api_key=api_key,
|
|
253
|
+
)
|
|
254
|
+
else:
|
|
255
|
+
sandbox = await e2b.AsyncSandbox.create(
|
|
256
|
+
timeout=sandbox_timeout,
|
|
257
|
+
api_key=api_key,
|
|
258
|
+
)
|
|
259
|
+
except e2b.SandboxNotFoundException as exc:
|
|
260
|
+
if sandbox_id is None:
|
|
261
|
+
raise
|
|
262
|
+
raise SandboxNotFoundError(sandbox_id) from exc
|
|
263
|
+
|
|
264
|
+
return AsyncE2BSandbox(
|
|
265
|
+
sandbox=sandbox,
|
|
266
|
+
workdir=workdir,
|
|
267
|
+
timeout=default_command_timeout,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
async def adelete(self, *, sandbox_id: str, **kwargs: object) -> None:
|
|
271
|
+
"""Kill an E2B sandbox asynchronously.
|
|
272
|
+
|
|
273
|
+
Args:
|
|
274
|
+
sandbox_id: E2B sandbox ID.
|
|
275
|
+
**kwargs: Unsupported provider options.
|
|
276
|
+
|
|
277
|
+
Raises:
|
|
278
|
+
SandboxNotFoundError: If `sandbox_id` does not exist.
|
|
279
|
+
TypeError: If unsupported provider options are passed.
|
|
280
|
+
ValueError: If credentials are missing.
|
|
281
|
+
"""
|
|
282
|
+
if kwargs:
|
|
283
|
+
_raise_unsupported_kwargs(kwargs)
|
|
284
|
+
try:
|
|
285
|
+
await e2b.AsyncSandbox.kill(sandbox_id, api_key=self._resolve_api_key())
|
|
286
|
+
except e2b.SandboxNotFoundException as exc:
|
|
287
|
+
raise SandboxNotFoundError(sandbox_id) from exc
|
|
288
|
+
|
|
196
289
|
def _resolve_api_key(self) -> str:
|
|
197
290
|
api_key = _resolve_optional_env_var(self._resolve_env_var, "E2B_API_KEY")
|
|
198
291
|
if not api_key:
|