langchain-daytona 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,225 @@
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
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # LangGraph
210
+ .langgraph_api
211
+
212
+ #claude
213
+ .claude
214
+
215
+ .idea
216
+ TEXTUAL_REFACTOR_PLAN.md
217
+ libs/cli/TEXTUAL_PROGRESS.md
218
+
219
+ /tmp/
220
+
221
+ # macOS
222
+ .DS_Store
223
+ */tmp/.DS_Store
224
+
225
+ CLAUDE.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) LangChain, Inc.
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,57 @@
1
+ .PHONY: all format lint test tests integration_test integration_tests test_watch benchmark help
2
+
3
+ all: help
4
+
5
+ .EXPORT_ALL_VARIABLES:
6
+ UV_FROZEN = true
7
+
8
+ ######################
9
+ # TESTING
10
+ ######################
11
+
12
+ TEST_FILE ?= tests/
13
+
14
+ integration_test integration_tests: TEST_FILE=tests/integration_tests/
15
+
16
+ test tests:
17
+ uv run --group test pytest -vvv --disable-socket --allow-unix-socket $(TEST_FILE)
18
+
19
+ integration_test integration_tests:
20
+ uv run --group test pytest -n auto -vvv --timeout 30 $(TEST_FILE)
21
+
22
+ test_watch:
23
+ uv run --group test ptw --now . -- -vv $(TEST_FILE)
24
+
25
+ benchmark:
26
+ uv run --group test pytest ./tests -m benchmark
27
+
28
+ ######################
29
+ # LINTING AND FORMATTING
30
+ ######################
31
+
32
+ PYTHON_FILES=.
33
+ lint format: PYTHON_FILES=.
34
+ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/partners/daytona --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
35
+ lint_package: PYTHON_FILES=langchain_daytona
36
+
37
+ lint lint_diff lint_package:
38
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES)
39
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff
40
+
41
+ format format_diff:
42
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES)
43
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES)
44
+
45
+ ######################
46
+ # HELP
47
+ ######################
48
+
49
+ help:
50
+ @echo '----'
51
+ @echo 'format - run code formatters'
52
+ @echo 'lint - run linters'
53
+ @echo 'lint_package - lint only the package'
54
+ @echo 'test - run unit tests'
55
+ @echo 'integration_test - run integration tests'
56
+ @echo 'test_watch - run tests in watch mode'
57
+ @echo 'benchmark - run benchmark tests'
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain_daytona
3
+ Version: 0.0.1
4
+ Summary: Daytona sandbox integration for deepagents
5
+ Project-URL: Homepage, https://github.com/langchain-ai/deepagents/tree/master/libs/partners/daytona
6
+ Project-URL: Repository, https://github.com/langchain-ai/deepagents
7
+ Project-URL: Documentation, https://github.com/langchain-ai/deepagents/tree/master/libs/partners/daytona
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: <4.0,>=3.11
19
+ Requires-Dist: daytona
20
+ Requires-Dist: deepagents
21
+ Description-Content-Type: text/markdown
22
+
23
+ # langchain_daytona
24
+
25
+ Daytona sandbox integration for deepagents.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install langchain_daytona
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from langchain_daytona import DaytonaProvider
37
+
38
+ provider = DaytonaProvider()
39
+ sandbox = provider.get_or_create()
40
+ result = sandbox.execute("echo hello")
41
+ print(result.output)
42
+ ```
43
+
@@ -0,0 +1,21 @@
1
+ # langchain_daytona
2
+
3
+ Daytona sandbox integration for deepagents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install langchain_daytona
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from langchain_daytona import DaytonaProvider
15
+
16
+ provider = DaytonaProvider()
17
+ sandbox = provider.get_or_create()
18
+ result = sandbox.execute("echo hello")
19
+ print(result.output)
20
+ ```
21
+
@@ -0,0 +1,5 @@
1
+ """Daytona sandbox integration for deepagents."""
2
+
3
+ from langchain_daytona.sandbox import DaytonaBackend, DaytonaProvider
4
+
5
+ __all__ = ["DaytonaBackend", "DaytonaProvider"]
@@ -0,0 +1,155 @@
1
+ """Daytona sandbox backend implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import time
7
+ from typing import TYPE_CHECKING, Any
8
+
9
+ from daytona import Daytona, DaytonaConfig, FileDownloadRequest, FileUpload
10
+ from deepagents.backends.protocol import (
11
+ ExecuteResponse,
12
+ FileDownloadResponse,
13
+ FileUploadResponse,
14
+ SandboxBackendProtocol,
15
+ )
16
+ from deepagents.backends.sandbox import (
17
+ BaseSandbox,
18
+ SandboxListResponse,
19
+ SandboxProvider,
20
+ )
21
+
22
+ if TYPE_CHECKING:
23
+ from daytona import Sandbox
24
+
25
+
26
+ class DaytonaBackend(BaseSandbox):
27
+ """Daytona backend implementation conforming to SandboxBackendProtocol.
28
+
29
+ This implementation inherits all file operation methods from BaseSandbox
30
+ and only implements the execute() method using Daytona's API.
31
+ """
32
+
33
+ def __init__(self, sandbox: Sandbox) -> None:
34
+ """Create a backend wrapping an existing Daytona sandbox."""
35
+ self._sandbox = sandbox
36
+ self._timeout: int = 30 * 60
37
+
38
+ @property
39
+ def id(self) -> str:
40
+ """Return the Daytona sandbox id."""
41
+ return self._sandbox.id
42
+
43
+ def execute(
44
+ self,
45
+ command: str,
46
+ ) -> ExecuteResponse:
47
+ """Execute a shell command inside the sandbox."""
48
+ result = self._sandbox.process.exec(command, timeout=self._timeout)
49
+
50
+ return ExecuteResponse(
51
+ output=result.result,
52
+ exit_code=result.exit_code,
53
+ truncated=False,
54
+ )
55
+
56
+ def download_files(self, paths: list[str]) -> list[FileDownloadResponse]:
57
+ """Download files from the sandbox."""
58
+ download_requests = [FileDownloadRequest(source=path) for path in paths]
59
+ daytona_responses = self._sandbox.fs.download_files(download_requests)
60
+
61
+ return [
62
+ FileDownloadResponse(
63
+ path=resp.source,
64
+ content=resp.result,
65
+ error=None,
66
+ )
67
+ for resp in daytona_responses
68
+ ]
69
+
70
+ def upload_files(self, files: list[tuple[str, bytes]]) -> list[FileUploadResponse]:
71
+ """Upload files into the sandbox."""
72
+ upload_requests = [
73
+ FileUpload(source=content, destination=path) for path, content in files
74
+ ]
75
+ self._sandbox.fs.upload_files(upload_requests)
76
+
77
+ return [FileUploadResponse(path=path, error=None) for path, _ in files]
78
+
79
+
80
+ class DaytonaProvider(SandboxProvider[dict[str, Any]]):
81
+ """Daytona sandbox provider implementation."""
82
+
83
+ def __init__(self, api_key: str | None = None) -> None:
84
+ """Create a provider backed by the Daytona SDK."""
85
+ self._api_key = api_key or os.environ.get("DAYTONA_API_KEY")
86
+ if not self._api_key:
87
+ msg = "DAYTONA_API_KEY environment variable not set"
88
+ raise ValueError(msg)
89
+ self._client = Daytona(DaytonaConfig(api_key=self._api_key))
90
+
91
+ def list(
92
+ self,
93
+ *,
94
+ cursor: str | None = None,
95
+ **kwargs: Any,
96
+ ) -> SandboxListResponse[dict[str, Any]]:
97
+ """List sandboxes (not yet implemented for Daytona SDK)."""
98
+ if cursor is not None:
99
+ msg = "DaytonaProvider.list() does not support cursor"
100
+ raise ValueError(msg)
101
+ if kwargs:
102
+ keys = sorted(kwargs.keys())
103
+ msg = f"DaytonaProvider.list() got unsupported kwargs: {keys}"
104
+ raise ValueError(msg)
105
+ msg = "Listing with Daytona SDK not yet implemented"
106
+ raise NotImplementedError(msg)
107
+
108
+ def get_or_create(
109
+ self,
110
+ *,
111
+ sandbox_id: str | None = None,
112
+ timeout: int = 180,
113
+ **kwargs: Any,
114
+ ) -> SandboxBackendProtocol:
115
+ """Create a new sandbox and wait until it's ready."""
116
+ if kwargs:
117
+ keys = sorted(kwargs.keys())
118
+ msg = f"DaytonaProvider.get_or_create() got unsupported kwargs: {keys}"
119
+ raise ValueError(msg)
120
+ if sandbox_id:
121
+ msg = (
122
+ "Connecting to existing Daytona sandbox by ID not yet supported. "
123
+ "Create a new sandbox by omitting sandbox_id parameter."
124
+ )
125
+ raise NotImplementedError(msg)
126
+
127
+ sandbox = self._client.create()
128
+
129
+ for _ in range(timeout // 2):
130
+ try:
131
+ result = sandbox.process.exec("echo ready", timeout=5)
132
+ if result.exit_code == 0:
133
+ break
134
+ except Exception: # noqa: BLE001
135
+ # Ok: startup errors vary; we retry then timeout.
136
+ time.sleep(2)
137
+ continue
138
+ time.sleep(2)
139
+ else:
140
+ try:
141
+ sandbox.delete()
142
+ finally:
143
+ msg = f"Daytona sandbox failed to start within {timeout} seconds"
144
+ raise RuntimeError(msg)
145
+
146
+ return DaytonaBackend(sandbox)
147
+
148
+ def delete(self, *, sandbox_id: str, **kwargs: Any) -> None:
149
+ """Delete a sandbox by id."""
150
+ if kwargs:
151
+ keys = sorted(kwargs.keys())
152
+ msg = f"DaytonaProvider.delete() got unsupported kwargs: {keys}"
153
+ raise ValueError(msg)
154
+ sandbox = self._client.get(sandbox_id)
155
+ self._client.delete(sandbox)
@@ -0,0 +1,91 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "langchain_daytona"
7
+ description = "Daytona sandbox integration for deepagents"
8
+ license = { text = "MIT" }
9
+ readme = "README.md"
10
+
11
+ classifiers = [
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ ]
21
+
22
+ version = "0.0.1"
23
+ requires-python = ">=3.11,<4.0"
24
+ dependencies = [
25
+ "deepagents",
26
+ "daytona",
27
+ ]
28
+
29
+ [tool.hatch.build.targets.wheel]
30
+ packages = ["langchain_daytona"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/langchain-ai/deepagents/tree/master/libs/partners/daytona"
34
+ Repository = "https://github.com/langchain-ai/deepagents"
35
+ Documentation = "https://github.com/langchain-ai/deepagents/tree/master/libs/partners/daytona"
36
+
37
+ [dependency-groups]
38
+ test = [
39
+ "pytest>=7.3.0,<9.0.0",
40
+ "pytest-cov",
41
+ "pytest-socket",
42
+ "pytest-xdist",
43
+ "pytest-timeout>=2.3.1,<3.0.0",
44
+ "pytest-asyncio>=1.3.0",
45
+ "ruff>=0.13.1,<0.14.0",
46
+ "mypy>=1.17.1,<2.0.0",
47
+ ]
48
+
49
+ [tool.uv.sources]
50
+ deepagents = { path = "../../deepagents", editable = true }
51
+
52
+ [tool.uv]
53
+ constraint-dependencies = ["urllib3>=2.6.3"]
54
+
55
+ [tool.mypy]
56
+ disallow_untyped_defs = true
57
+
58
+ [tool.ruff.format]
59
+ docstring-code-format = true
60
+
61
+ [tool.ruff.lint]
62
+ select = ["ALL"]
63
+ ignore = [
64
+ "COM812",
65
+ "ISC001",
66
+ "ANN401",
67
+ ]
68
+
69
+ [tool.ruff.lint.pydocstyle]
70
+ convention = "google"
71
+ ignore-var-parameters = true # ignore missing documentation for *args and **kwargs parameters
72
+
73
+ [tool.ruff.lint.flake8-tidy-imports]
74
+ ban-relative-imports = "all"
75
+
76
+ [tool.coverage.run]
77
+ omit = ["tests/*"]
78
+
79
+ [tool.pytest.ini_options]
80
+ addopts = "--strict-markers --strict-config --durations=5 --cov=langchain_daytona"
81
+ testpaths = ["tests"]
82
+ markers = [
83
+ "requires: mark tests as requiring a specific library",
84
+ "compile: mark placeholder test used to compile integration tests without running them",
85
+ "scheduled: mark tests to run in scheduled testing",
86
+ ]
87
+ asyncio_mode = "auto"
88
+ filterwarnings = []
89
+
90
+ [tool.ruff.lint.extend-per-file-ignores]
91
+ "tests/**/*.py" = ["D", "S101"]
File without changes
@@ -0,0 +1,5 @@
1
+ import langchain_daytona
2
+
3
+
4
+ def test_import_daytona() -> None:
5
+ assert langchain_daytona is not None