deepagents-docker 0.0.1__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.
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepAgents Docker Sandbox contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepagents-docker
3
+ Version: 0.0.1
4
+ Summary: Docker-backed sandbox backend for DeepAgents
5
+ Project-URL: Homepage, https://github.com/andybbruno/deepagents-docker
6
+ Project-URL: Repository, https://github.com/andybbruno/deepagents-docker
7
+ Author: Andrea Bruno
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,deepagents,docker,langchain,langgraph,sandbox
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: deepagents>=0.6.7
20
+ Description-Content-Type: text/markdown
21
+
22
+ <p align="center">
23
+ <img src="assets/deepagents-docker-banner.png" width="800" />
24
+ </p>
25
+ <div align="center">
26
+ <h3>Docker sandbox backend for <a href="https://github.com/langchain-ai/deepagents">Deep Agents</a>.</h3>
27
+ </div>
28
+
29
+
30
+ <div align="center">
31
+
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
33
+ [![Python](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/downloads/)
34
+ [![deepagents](https://img.shields.io/badge/built%20for-deepagents-orange)](https://github.com/langchain-ai/deepagents)
35
+
36
+ </div>
37
+
38
+
39
+ ## Quickstart
40
+
41
+ Requires [Docker](https://docs.docker.com/get-docker/) on your machine.
42
+
43
+ Install with `uv`:
44
+ ```bash
45
+ uv add deepagents-docker
46
+ ```
47
+ or with `pip`:
48
+ ```bash
49
+ pip install deepagents-docker
50
+ ```
51
+
52
+ ```python
53
+ from deepagents import create_deep_agent
54
+ from deepagents_docker import DockerSandbox
55
+
56
+ agent = create_deep_agent(
57
+ model="openai:gpt-5.5",
58
+ backend=DockerSandbox(),
59
+ system_prompt="You are a research assistant.",
60
+ )
61
+
62
+ result = agent.invoke({"messages": "Research the latest trends in AI and write a summary."})
63
+ ```
64
+
65
+ ## Configuration
66
+
67
+ Constructor options let you change the image, workspace path, command timeout, resource limits, outbound network access, and any extra `docker run` flags:
68
+
69
+ ```python
70
+ DockerSandbox(
71
+ image="python:3.12-bookworm", # default image (Debian-based, includes curl, etc.)
72
+ allow_outbound_traffic=True, # False → no network; True (default) → allow outbound traffic
73
+ workspace_dir="/path/to/project", # host dir for agent files; see note below
74
+ timeout=120, # per-command timeout (seconds)
75
+ max_output_bytes=100_000, # combined stdout/stderr cap per command
76
+ memory="512m",
77
+ cpus=1.0,
78
+ pids_limit=128,
79
+ auto_remove=True, # remove container on close()
80
+ extra_run_args=["--env", "FOO=bar"],
81
+ )
82
+ ```
83
+
84
+ > [!NOTE]
85
+ > When `workspace_dir` is omitted, a temporary directory is created under the host temp folder and **removed on `close()`** when the sandbox owns it. Pass an explicit path to keep files after the container stops.
86
+
87
+
88
+ ## How it works
89
+
90
+ `DockerSandbox` implements the Deep Agents backend protocol by splitting work across the host and a container:
91
+
92
+ - **File tools** (`read`, `write`, `edit`, `grep`, `glob`, `ls`) run against a workspace directory on your machine.
93
+ - **`execute`** runs shell commands in a long-lived Docker container. The same directory is bind-mounted at `/workspace`, so files stay in sync between tools and commands.
94
+
95
+ On startup, the sandbox creates a container with conservative defaults:
96
+
97
+ - [`python:3.12-bookworm`](https://hub.docker.com/_/python) as the default image
98
+ - Outbound traffic allowed by default
99
+ - No elevated Linux privileges
100
+ - Read-only root filesystem (with small `tmpfs` mounts for `/tmp` and `/var/tmp`)
101
+ - Memory, CPU, and PID limits
102
+
103
+
104
+ > [!NOTE]
105
+ > The container is stopped and removed automatically when the Python process exits (`atexit`). Use a context manager (below) to tear down earlier.
106
+
107
+
108
+ ### Using a context manager
109
+
110
+ Use a context manager when you want the container stopped and removed as soon as you leave the block:
111
+
112
+ ```python
113
+ from deepagents import create_deep_agent
114
+ from deepagents_docker import DockerSandbox
115
+
116
+ with DockerSandbox() as backend:
117
+ agent = create_deep_agent(model="openai:gpt-5.5", backend=backend)
118
+ agent.invoke({"messages": "..."})
119
+
120
+ # Container stopped and removed here.
121
+ print("Done!")
122
+ ```
123
+
124
+ ## Development
125
+
126
+ ```bash
127
+ git clone https://github.com/andybbruno/deepagents-docker.git
128
+ cd deepagents-docker
129
+ uv sync
130
+ uv run pytest
131
+ ```
132
+
133
+ ## Security
134
+
135
+ Use this for trusted workloads and development, not as a hard multi-tenant boundary. Do not put secrets in the workspace. See [Deep Agents security](https://github.com/langchain-ai/deepagents?tab=security-ov-file).
136
+
137
+ ## License
138
+
139
+ MIT — [LICENSE](LICENSE).
@@ -0,0 +1,118 @@
1
+ <p align="center">
2
+ <img src="assets/deepagents-docker-banner.png" width="800" />
3
+ </p>
4
+ <div align="center">
5
+ <h3>Docker sandbox backend for <a href="https://github.com/langchain-ai/deepagents">Deep Agents</a>.</h3>
6
+ </div>
7
+
8
+
9
+ <div align="center">
10
+
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
12
+ [![Python](https://img.shields.io/badge/python-3.12%2B-blue)](https://www.python.org/downloads/)
13
+ [![deepagents](https://img.shields.io/badge/built%20for-deepagents-orange)](https://github.com/langchain-ai/deepagents)
14
+
15
+ </div>
16
+
17
+
18
+ ## Quickstart
19
+
20
+ Requires [Docker](https://docs.docker.com/get-docker/) on your machine.
21
+
22
+ Install with `uv`:
23
+ ```bash
24
+ uv add deepagents-docker
25
+ ```
26
+ or with `pip`:
27
+ ```bash
28
+ pip install deepagents-docker
29
+ ```
30
+
31
+ ```python
32
+ from deepagents import create_deep_agent
33
+ from deepagents_docker import DockerSandbox
34
+
35
+ agent = create_deep_agent(
36
+ model="openai:gpt-5.5",
37
+ backend=DockerSandbox(),
38
+ system_prompt="You are a research assistant.",
39
+ )
40
+
41
+ result = agent.invoke({"messages": "Research the latest trends in AI and write a summary."})
42
+ ```
43
+
44
+ ## Configuration
45
+
46
+ Constructor options let you change the image, workspace path, command timeout, resource limits, outbound network access, and any extra `docker run` flags:
47
+
48
+ ```python
49
+ DockerSandbox(
50
+ image="python:3.12-bookworm", # default image (Debian-based, includes curl, etc.)
51
+ allow_outbound_traffic=True, # False → no network; True (default) → allow outbound traffic
52
+ workspace_dir="/path/to/project", # host dir for agent files; see note below
53
+ timeout=120, # per-command timeout (seconds)
54
+ max_output_bytes=100_000, # combined stdout/stderr cap per command
55
+ memory="512m",
56
+ cpus=1.0,
57
+ pids_limit=128,
58
+ auto_remove=True, # remove container on close()
59
+ extra_run_args=["--env", "FOO=bar"],
60
+ )
61
+ ```
62
+
63
+ > [!NOTE]
64
+ > When `workspace_dir` is omitted, a temporary directory is created under the host temp folder and **removed on `close()`** when the sandbox owns it. Pass an explicit path to keep files after the container stops.
65
+
66
+
67
+ ## How it works
68
+
69
+ `DockerSandbox` implements the Deep Agents backend protocol by splitting work across the host and a container:
70
+
71
+ - **File tools** (`read`, `write`, `edit`, `grep`, `glob`, `ls`) run against a workspace directory on your machine.
72
+ - **`execute`** runs shell commands in a long-lived Docker container. The same directory is bind-mounted at `/workspace`, so files stay in sync between tools and commands.
73
+
74
+ On startup, the sandbox creates a container with conservative defaults:
75
+
76
+ - [`python:3.12-bookworm`](https://hub.docker.com/_/python) as the default image
77
+ - Outbound traffic allowed by default
78
+ - No elevated Linux privileges
79
+ - Read-only root filesystem (with small `tmpfs` mounts for `/tmp` and `/var/tmp`)
80
+ - Memory, CPU, and PID limits
81
+
82
+
83
+ > [!NOTE]
84
+ > The container is stopped and removed automatically when the Python process exits (`atexit`). Use a context manager (below) to tear down earlier.
85
+
86
+
87
+ ### Using a context manager
88
+
89
+ Use a context manager when you want the container stopped and removed as soon as you leave the block:
90
+
91
+ ```python
92
+ from deepagents import create_deep_agent
93
+ from deepagents_docker import DockerSandbox
94
+
95
+ with DockerSandbox() as backend:
96
+ agent = create_deep_agent(model="openai:gpt-5.5", backend=backend)
97
+ agent.invoke({"messages": "..."})
98
+
99
+ # Container stopped and removed here.
100
+ print("Done!")
101
+ ```
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ git clone https://github.com/andybbruno/deepagents-docker.git
107
+ cd deepagents-docker
108
+ uv sync
109
+ uv run pytest
110
+ ```
111
+
112
+ ## Security
113
+
114
+ Use this for trusted workloads and development, not as a hard multi-tenant boundary. Do not put secrets in the workspace. See [Deep Agents security](https://github.com/langchain-ai/deepagents?tab=security-ov-file).
115
+
116
+ ## License
117
+
118
+ MIT — [LICENSE](LICENSE).
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "deepagents-docker"
7
+ version = "0.0.1"
8
+ description = "Docker-backed sandbox backend for DeepAgents"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.12"
12
+ authors = [{ name = "Andrea Bruno" }]
13
+ keywords = ["deepagents", "docker", "sandbox", "langchain", "langgraph", "agents"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ ]
23
+ dependencies = [
24
+ "deepagents>=0.6.7",
25
+ ]
26
+
27
+ [dependency-groups]
28
+ dev = [
29
+ "pytest>=9.0.0",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/andybbruno/deepagents-docker"
34
+ Repository = "https://github.com/andybbruno/deepagents-docker"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/deepagents_docker"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+
42
+
@@ -0,0 +1,7 @@
1
+ """Docker-backed sandbox backend for DeepAgents."""
2
+
3
+ from deepagents_docker.backend import (
4
+ DockerSandbox,
5
+ )
6
+
7
+ __all__ = ["DockerSandbox"]
@@ -0,0 +1,82 @@
1
+ """Low-level helpers for invoking the Docker CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import subprocess
7
+ from collections.abc import Sequence
8
+ from dataclasses import dataclass
9
+
10
+
11
+ class DockerError(RuntimeError):
12
+ """Raised when a Docker CLI invocation fails."""
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class DockerRunResult:
17
+ """Captured output from a Docker CLI subprocess."""
18
+
19
+ returncode: int
20
+ stdout: str
21
+ stderr: str
22
+
23
+
24
+ def run_docker(
25
+ args: Sequence[str],
26
+ *,
27
+ timeout: float | None = None,
28
+ input_text: str | None = None,
29
+ ) -> DockerRunResult:
30
+ """Run `docker` with the given arguments."""
31
+ try:
32
+ completed = subprocess.run( # noqa: S603
33
+ ["docker", *args],
34
+ check=False,
35
+ capture_output=True,
36
+ text=True,
37
+ timeout=timeout,
38
+ input=input_text,
39
+ )
40
+ except subprocess.TimeoutExpired as exc:
41
+ msg = f"docker command timed out after {timeout} seconds"
42
+ raise DockerError(msg) from exc
43
+ except FileNotFoundError as exc:
44
+ msg = "docker executable not found on PATH"
45
+ raise DockerError(msg) from exc
46
+
47
+ return DockerRunResult(
48
+ returncode=completed.returncode,
49
+ stdout=completed.stdout or "",
50
+ stderr=completed.stderr or "",
51
+ )
52
+
53
+
54
+ def docker_available() -> bool:
55
+ """Return True when the Docker daemon responds to `docker info`."""
56
+ result = run_docker(["info", "--format", "{{.ServerVersion}}"])
57
+ return result.returncode == 0
58
+
59
+
60
+ def inspect_container_id(container_name: str) -> str:
61
+ """Return the container ID for a running container name."""
62
+ result = run_docker(
63
+ ["inspect", "--format", "{{.Id}}", container_name],
64
+ )
65
+ if result.returncode != 0:
66
+ msg = result.stderr.strip() or f"failed to inspect container {container_name!r}"
67
+ raise DockerError(msg)
68
+ return result.stdout.strip()
69
+
70
+
71
+ def format_docker_error(result: DockerRunResult) -> str:
72
+ """Combine stderr/stdout into a single error string."""
73
+ detail = (result.stderr or result.stdout).strip()
74
+ if not detail:
75
+ detail = f"exit code {result.returncode}"
76
+ try:
77
+ payload = json.loads(detail)
78
+ except json.JSONDecodeError:
79
+ return detail
80
+ if isinstance(payload, dict) and "message" in payload:
81
+ return str(payload["message"])
82
+ return detail