agentenv-daytona 0.1.0__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.
- agentenv_daytona-0.1.0/LICENSE +190 -0
- agentenv_daytona-0.1.0/PKG-INFO +275 -0
- agentenv_daytona-0.1.0/README.md +245 -0
- agentenv_daytona-0.1.0/agentenv_daytona/__init__.py +10 -0
- agentenv_daytona-0.1.0/agentenv_daytona/config.py +148 -0
- agentenv_daytona-0.1.0/agentenv_daytona/image.py +55 -0
- agentenv_daytona-0.1.0/agentenv_daytona/lifecycle.py +242 -0
- agentenv_daytona-0.1.0/agentenv_daytona/network.py +103 -0
- agentenv_daytona-0.1.0/agentenv_daytona/preview_domain.py +72 -0
- agentenv_daytona-0.1.0/agentenv_daytona/provider.py +277 -0
- agentenv_daytona-0.1.0/agentenv_daytona/py.typed +0 -0
- agentenv_daytona-0.1.0/agentenv_daytona/sandbox.py +259 -0
- agentenv_daytona-0.1.0/agentenv_daytona/transfer.py +134 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/PKG-INFO +275 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/SOURCES.txt +19 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/dependency_links.txt +1 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/entry_points.txt +2 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/requires.txt +10 -0
- agentenv_daytona-0.1.0/agentenv_daytona.egg-info/top_level.txt +1 -0
- agentenv_daytona-0.1.0/pyproject.toml +79 -0
- agentenv_daytona-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Daytona Platforms Inc.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentenv-daytona
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Daytona sandbox provider for Scale AI's AgentEnv framework
|
|
5
|
+
Author-email: "Daytona Platforms Inc." <support@daytona.io>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/daytona/integrations/tree/main/packages/agentenv-daytona#readme
|
|
8
|
+
Project-URL: Repository, https://github.com/daytona/integrations
|
|
9
|
+
Project-URL: Documentation, https://github.com/daytona/integrations/tree/main/packages/agentenv-daytona#readme
|
|
10
|
+
Project-URL: Issues, https://github.com/daytona/integrations/issues
|
|
11
|
+
Keywords: agentenv,agentenv-framework,daytona,sandbox,reinforcement-learning,agent
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.11.4
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: agentenv-framework<0.10,>=0.9.1322
|
|
21
|
+
Requires-Dist: daytona<0.225.0,>=0.224.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
|
|
25
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff<0.17,>=0.15; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# agentenv-daytona
|
|
32
|
+
|
|
33
|
+
Runs [AgentEnv Framework](https://github.com/scaleapi/agentenv-framework) sandboxes on [Daytona](https://www.daytona.io).
|
|
34
|
+
Each sandbox is a Daytona sandbox running its own Docker daemon, presented to AgentEnv as a VM. AgentEnv's
|
|
35
|
+
docker-in-VM flows run on it unchanged: the gateway's docker-compose, an agent's `docker run`, image loading
|
|
36
|
+
and building, and artifact collection.
|
|
37
|
+
|
|
38
|
+
The package is an AgentEnv plugin. Installing it registers the `daytona` sandbox provider through the
|
|
39
|
+
`agent_env.sandbox_providers` entry point, so nothing in AgentEnv itself changes.
|
|
40
|
+
|
|
41
|
+
## Set up
|
|
42
|
+
|
|
43
|
+
### 1. Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install agentenv-daytona # or: uv add agentenv-daytona
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It installs `agentenv-framework` and the Daytona Python SDK. `agent-env plugin list` then shows
|
|
50
|
+
`sandbox provider daytona`.
|
|
51
|
+
|
|
52
|
+
### 2. Get a Daytona API key
|
|
53
|
+
|
|
54
|
+
Create a key in the [Daytona dashboard](https://app.daytona.io/dashboard/keys). For local work, export it:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
export DAYTONA_API_KEY=dtn_...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
For a shared deployment, put it in your secret store instead, for example as `daytona_api_key`, and reference
|
|
61
|
+
it with `secret:daytona_api_key`. Never put the key itself in `config.toml`. The provider reads the key only
|
|
62
|
+
from its config, never from the process environment.
|
|
63
|
+
|
|
64
|
+
### 3. Configure
|
|
65
|
+
|
|
66
|
+
A complete `.agentenv/config.toml` that runs every environment and agent on Daytona, with the local stores:
|
|
67
|
+
|
|
68
|
+
```toml
|
|
69
|
+
[sandbox]
|
|
70
|
+
default = "daytona" # environments and sandboxes
|
|
71
|
+
agent_default = "daytona" # agents
|
|
72
|
+
|
|
73
|
+
[sandbox.providers.daytona.config]
|
|
74
|
+
api_key = "env:DAYTONA_API_KEY" # or "secret:daytona_api_key"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To keep the local default and use Daytona per run instead, add only the `[sandbox.providers.daytona.config]`
|
|
78
|
+
table and pass `--sandbox daytona`. `agent-env config show` prints the file in effect and masks the key.
|
|
79
|
+
|
|
80
|
+
### 4. Run something
|
|
81
|
+
|
|
82
|
+
The bundled `hello` task deploys a sandbox, loads a file into it and checks it, with no model needed:
|
|
83
|
+
|
|
84
|
+
```console
|
|
85
|
+
$ agent-env run hello --sandbox daytona
|
|
86
|
+
[tasks/hello.json] step 1/3 box (deploy_sandbox)
|
|
87
|
+
[tasks/hello.json] step 1/3 box done in 2.4s
|
|
88
|
+
[tasks/hello.json] step 2/3 load (load_artifact)
|
|
89
|
+
[tasks/hello.json] step 2/3 load done in 1.4s
|
|
90
|
+
[tasks/hello.json] step 3/3 hello (verify_sandbox)
|
|
91
|
+
[tasks/hello.json] step 3/3 hello done in 0.6s
|
|
92
|
+
[tasks/hello.json] passed in 4.4s
|
|
93
|
+
|
|
94
|
+
Tasks:
|
|
95
|
+
tasks/hello.json v1: passed (hello: 1), 4.4s, instance @local/agentenv-framework/hello/hello-qowoke74
|
|
96
|
+
|
|
97
|
+
Tore down 1 sandbox.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The first sandbox an organization creates also builds the host image (see below), which takes about half a
|
|
101
|
+
minute once.
|
|
102
|
+
|
|
103
|
+
## Configuration reference
|
|
104
|
+
|
|
105
|
+
All keys go under `[sandbox.providers.daytona.config]`. Unknown keys are refused.
|
|
106
|
+
|
|
107
|
+
| Key | Default | Meaning |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `api_key` | required | The Daytona API key, as an `env:` or `secret:` reference. |
|
|
110
|
+
| `api_url` | `"https://app.daytona.io/api"` | The Daytona API URL. |
|
|
111
|
+
| `target` | the organization's default | The Daytona region sandboxes are created in. |
|
|
112
|
+
| `snapshot` | unset | A Docker-capable snapshot in your organization to boot instead of the host image. |
|
|
113
|
+
| `base_image` | `"daytonaio/sandbox:0.9.0"` | The Debian or Ubuntu image the host image is built on. Not with `snapshot`. |
|
|
114
|
+
| `egress_hosts` | `[]` | Extra hostnames every restricted sandbox may reach, e.g. `["*.internal.example"]`. |
|
|
115
|
+
|
|
116
|
+
## Examples
|
|
117
|
+
|
|
118
|
+
**A shared deployment.** The key comes from the secret store, sandboxes go to one region, and cost is grouped
|
|
119
|
+
by attribution:
|
|
120
|
+
|
|
121
|
+
```toml
|
|
122
|
+
[sandbox]
|
|
123
|
+
default = "daytona"
|
|
124
|
+
agent_default = "daytona"
|
|
125
|
+
attribution = { team = "env-pod", project_id = "env:PROJECT_ID?unassigned" }
|
|
126
|
+
|
|
127
|
+
[sandbox.providers.daytona.config]
|
|
128
|
+
api_key = "secret:daytona_api_key"
|
|
129
|
+
target = "us"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**A pre-built snapshot.** Boot a Docker-capable snapshot you maintain instead of the built-in host image:
|
|
133
|
+
|
|
134
|
+
```toml
|
|
135
|
+
[sandbox.providers.daytona.config]
|
|
136
|
+
api_key = "env:DAYTONA_API_KEY"
|
|
137
|
+
snapshot = "my-agentenv-docker"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**A sandbox with restricted egress.** In a task, `deploy_sandbox` and `deploy_agent` take a `network_policy`;
|
|
141
|
+
Daytona enforces it for the sandbox and every container in it:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{"id": "box", "type": "deploy_sandbox", "sandbox_name": "box", "sandbox_mode": "vm", "sandbox_type": "daytona",
|
|
145
|
+
"network_policy": {"mode": "allowlist", "allow_hosts": ["pypi.org", "*.github.com"]}}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**A fallback chain.** Try Daytona first and fall back to another provider when a sandbox can't be created:
|
|
149
|
+
|
|
150
|
+
```toml
|
|
151
|
+
[sandbox]
|
|
152
|
+
default = "daytona,e2b"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**From Python.** Build the configured provider and create a VM directly:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
import asyncio
|
|
159
|
+
|
|
160
|
+
from agent_env.providers.sandbox_providers.sandbox_provider import build_sandbox_provider
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
async def main() -> None:
|
|
164
|
+
provider = build_sandbox_provider("daytona")
|
|
165
|
+
sandbox = await provider.create_vm(cpu=2, memory=4096, exposed_ports=[8080], timeout=900)
|
|
166
|
+
try:
|
|
167
|
+
print(await sandbox.exec_with_output("sudo", "docker", "info", "--format", "{{.ServerVersion}}"))
|
|
168
|
+
print(sandbox.tunnel_urls[8080]) # https://8080-<sandbox-id>.<preview domain>
|
|
169
|
+
finally:
|
|
170
|
+
await sandbox.terminate()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
asyncio.run(main())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## The host image
|
|
177
|
+
|
|
178
|
+
Sandboxes boot from a Docker host image the provider defines in code: `base_image` with Docker Engine, the
|
|
179
|
+
Compose v2 plugin and a passwordless-sudo `daytona` user added. Daytona builds it the first time a sandbox asks
|
|
180
|
+
for it and caches it as a snapshot in your organization, so nothing is hosted outside Daytona and later
|
|
181
|
+
sandboxes start from the cache in about a second. Docker's storage is left empty so the daemon prepares it at
|
|
182
|
+
boot; the provider starts `dockerd` and waits for it (up to 180 seconds) before handing the sandbox over.
|
|
183
|
+
|
|
184
|
+
With `snapshot`, the provider boots that snapshot instead. It must ship Docker Engine and the Compose v2
|
|
185
|
+
plugin, with `/var/lib/docker` empty, and a user with passwordless sudo. Sandbox class follows the snapshot, so a
|
|
186
|
+
Linux VM snapshot (created from an image reference, as Daytona requires for that class) gives VM sandboxes with
|
|
187
|
+
no change here.
|
|
188
|
+
|
|
189
|
+
## Resources and lifetime
|
|
190
|
+
|
|
191
|
+
- **Size:** CPU, memory and disk follow the request, rounded up to whole vCPUs and GiB and raised to Daytona's
|
|
192
|
+
Docker-in-Docker floor of 2 vCPU, 4 GiB memory and 10 GiB disk. With `snapshot`, the snapshot fixes the size.
|
|
193
|
+
- **Lifetime:** the sandbox's `timeout` becomes Daytona's hard time-to-live, in whole minutes. Sandboxes are
|
|
194
|
+
ephemeral: they are deleted when they stop, and never auto-stop on idleness before that.
|
|
195
|
+
- **Cleanup:** when a create fails or its caller is cancelled, the provider deletes any sandbox it made, retrying
|
|
196
|
+
through brief Daytona API errors; if Daytona stays unreachable, the sandbox runs until its time-to-live. A
|
|
197
|
+
rate-limited create gets up to 5 attempts with backoff.
|
|
198
|
+
|
|
199
|
+
## Networking
|
|
200
|
+
|
|
201
|
+
- **Ports:** each exposed port gets a public URL, `https://<port>-<sandbox-id>.<preview domain>`, which fills
|
|
202
|
+
`tunnel_urls`. Sandboxes are created public, so the URLs need no token, like the other providers' tunnels.
|
|
203
|
+
- **Preview domain:** it is read from Daytona, never written down: from the API's `/config` before the first
|
|
204
|
+
restricted sandbox, and from every sandbox's own preview URLs. It differs between organizations and regions
|
|
205
|
+
(e.g. `daytonaproxy01.net`, `daytonaproxy01.eu`) and `/config` only knows the default, so a sandbox's own URL is
|
|
206
|
+
what settles it. Each domain seen is added to every restricted sandbox's allowlist and published in the
|
|
207
|
+
provider's `EGRESS_HOSTS`, so restricted workloads reach each other's ports. As with every AgentEnv platform's
|
|
208
|
+
domain (`*.e2b.app`, `*.modal.host`, …), the wildcard admits any public Daytona sandbox on that domain, not
|
|
209
|
+
only the run's own.
|
|
210
|
+
- **Egress:** allow-all, or an allowlist of up to 100 hostnames with `*.` wildcards. Daytona keeps hostnames and
|
|
211
|
+
CIDRs in separate, mutually exclusive lists, and AgentEnv always adds its platforms' hostnames to an
|
|
212
|
+
allowlist, so policies with CIDRs or IP addresses are refused before any sandbox is created. An empty allowlist
|
|
213
|
+
blocks everything.
|
|
214
|
+
- **Downloads:** before a restricted sandbox downloads an image tarball or object from a signed URL, that URL's
|
|
215
|
+
host is added to its allowlist, and the download waits (up to 60 seconds) until the host answers. An allowlist
|
|
216
|
+
update Daytona refuses because it is still applying the previous one is retried for a few seconds.
|
|
217
|
+
- **Organization tier:** sandbox-level egress lists need a Daytona organization on Tier 3 or above. On Tier 1 and 2
|
|
218
|
+
Daytona refuses them, so a restricted policy fails with a `NetworkPolicyUnsupportedError` quoting Daytona's
|
|
219
|
+
message, and no sandbox is created. Unrestricted sandboxes there get the tier's own policy: Daytona's essential
|
|
220
|
+
services stay reachable (PyPI, GitHub, npm, Docker Hub, public ECR, S3, GCS and the OpenAI API, among others)
|
|
221
|
+
and every other host is blocked, Daytona preview URLs included. So on Tier 1 and 2 an agent in its own sandbox
|
|
222
|
+
can't reach an environment's gateway in another sandbox, or a model endpoint outside that list; tasks that keep
|
|
223
|
+
everything in one sandbox, like `hello`, work.
|
|
224
|
+
- **Reconnect:** `get_sandbox` restores the ports, their URLs and the applied egress policy. A policy it can't
|
|
225
|
+
express leaves `network_policy` unknown, and image loading then fails closed.
|
|
226
|
+
|
|
227
|
+
## Attribution and cost
|
|
228
|
+
|
|
229
|
+
Each sandbox carries labels: `agentenv.managed=true`, `agentenv.ports`, one `agentenv.attr.<key>` per
|
|
230
|
+
attribution value (values slugged, at most 255 characters) and, when it boots from the host image rather than a
|
|
231
|
+
`snapshot`, `agentenv.host-image` with the recipe version. Its name is
|
|
232
|
+
`ae-<random>-<attribution values>`. The provider logs one `agent_env.daytona_sandbox_started` event per sandbox
|
|
233
|
+
with its id, size and attribution. Running sandboxes can be filtered by these labels in the Daytona dashboard or
|
|
234
|
+
with `AsyncDaytona.list(ListSandboxesQuery(labels=...))`; deleted ones are no longer listed.
|
|
235
|
+
|
|
236
|
+
**Cost per label.** Daytona's analytics API reports usage and price per sandbox, deleted ones included:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
curl -H "Authorization: Bearer $DAYTONA_API_KEY" \
|
|
240
|
+
"https://analytics.app.daytona.io/organization/$DAYTONA_ORG_ID/usage/sandbox?from=2026-10-20T00:00:00Z&to=2026-10-23T00:00:00Z"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Each row has `sandboxId`, `totalPrice` and CPU, RAM, disk and GPU seconds, but no labels, and these sandboxes are
|
|
244
|
+
deleted when they stop, after which Daytona no longer lists them or their labels. To group cost by attribution,
|
|
245
|
+
keep the `agent_env.daytona_sandbox_started` events and join their `daytona_sandbox_id` with `sandboxId`. You'll
|
|
246
|
+
find your organization ID in the Daytona dashboard.
|
|
247
|
+
|
|
248
|
+
## Things to know
|
|
249
|
+
|
|
250
|
+
- **Commands** run as the `daytona` user through one-shot Daytona sessions, which keep stdout and stderr apart;
|
|
251
|
+
AgentEnv's own `sudo` prefixes give root.
|
|
252
|
+
- **Uploads** go through Daytona's file API in 4 MiB parts, joined as root and checked against their sha256.
|
|
253
|
+
- **No private network:** containers on different sandboxes reach each other through their public URLs.
|
|
254
|
+
|
|
255
|
+
## Testing
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
pip install -e ".[dev]"
|
|
259
|
+
pytest # unit tests, no network
|
|
260
|
+
DAYTONA_API_KEY=... pytest tests/integration_tests -v
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
The live tests create real sandboxes, delete them, and fail if any are left. The two allowlist tests also need
|
|
264
|
+
`DAYTONA_TEST_EGRESS=1` and an organization on Tier 3 or above.
|
|
265
|
+
|
|
266
|
+
## Development
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
python3.12 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
270
|
+
.venv/bin/ruff check . && .venv/bin/black --check . && .venv/bin/mypy agentenv_daytona && .venv/bin/pytest
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
Apache-2.0. See [LICENSE](LICENSE).
|