a13n-environment 0.0.4__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 (79) hide show
  1. a13n_environment-0.0.4/.gitignore +69 -0
  2. a13n_environment-0.0.4/LICENSE +201 -0
  3. a13n_environment-0.0.4/PKG-INFO +131 -0
  4. a13n_environment-0.0.4/README.md +115 -0
  5. a13n_environment-0.0.4/a13n_environment/__init__.py +336 -0
  6. a13n_environment-0.0.4/a13n_environment/_json.py +75 -0
  7. a13n_environment-0.0.4/a13n_environment/_local_identity.py +40 -0
  8. a13n_environment-0.0.4/a13n_environment/_windows_job.py +207 -0
  9. a13n_environment-0.0.4/a13n_environment/attachments.py +326 -0
  10. a13n_environment-0.0.4/a13n_environment/catalog.py +513 -0
  11. a13n_environment-0.0.4/a13n_environment/commands.py +326 -0
  12. a13n_environment-0.0.4/a13n_environment/direct_local/__init__.py +15 -0
  13. a13n_environment-0.0.4/a13n_environment/direct_local/configuration.py +126 -0
  14. a13n_environment-0.0.4/a13n_environment/direct_local/files.py +1194 -0
  15. a13n_environment-0.0.4/a13n_environment/direct_local/processes.py +1013 -0
  16. a13n_environment-0.0.4/a13n_environment/direct_local/provider.py +380 -0
  17. a13n_environment-0.0.4/a13n_environment/direct_local/retention.py +348 -0
  18. a13n_environment-0.0.4/a13n_environment/docker/__init__.py +55 -0
  19. a13n_environment-0.0.4/a13n_environment/docker/_errors.py +99 -0
  20. a13n_environment-0.0.4/a13n_environment/docker/configuration.py +230 -0
  21. a13n_environment-0.0.4/a13n_environment/docker/factory.py +115 -0
  22. a13n_environment-0.0.4/a13n_environment/docker/identity.py +24 -0
  23. a13n_environment-0.0.4/a13n_environment/docker/provider.py +895 -0
  24. a13n_environment-0.0.4/a13n_environment/docker/runtime.py +674 -0
  25. a13n_environment-0.0.4/a13n_environment/e2b/__init__.py +16 -0
  26. a13n_environment-0.0.4/a13n_environment/e2b/commands.py +103 -0
  27. a13n_environment-0.0.4/a13n_environment/e2b/configuration.py +61 -0
  28. a13n_environment-0.0.4/a13n_environment/e2b/errors.py +57 -0
  29. a13n_environment-0.0.4/a13n_environment/e2b/factory.py +70 -0
  30. a13n_environment-0.0.4/a13n_environment/e2b/files.py +237 -0
  31. a13n_environment-0.0.4/a13n_environment/e2b/guest/__init__.py +1 -0
  32. a13n_environment-0.0.4/a13n_environment/e2b/guest/files.py +247 -0
  33. a13n_environment-0.0.4/a13n_environment/e2b/guest/ports.py +10 -0
  34. a13n_environment-0.0.4/a13n_environment/e2b/output.py +207 -0
  35. a13n_environment-0.0.4/a13n_environment/e2b/ports.py +38 -0
  36. a13n_environment-0.0.4/a13n_environment/e2b/processes.py +392 -0
  37. a13n_environment-0.0.4/a13n_environment/e2b/provider.py +317 -0
  38. a13n_environment-0.0.4/a13n_environment/e2b/runtime.py +19 -0
  39. a13n_environment-0.0.4/a13n_environment/eip/__init__.py +3 -0
  40. a13n_environment-0.0.4/a13n_environment/eip/_common.py +130 -0
  41. a13n_environment-0.0.4/a13n_environment/eip/binding.py +253 -0
  42. a13n_environment-0.0.4/a13n_environment/eip/files.py +373 -0
  43. a13n_environment-0.0.4/a13n_environment/eip/output.py +344 -0
  44. a13n_environment-0.0.4/a13n_environment/eip/processes.py +649 -0
  45. a13n_environment-0.0.4/a13n_environment/errors.py +134 -0
  46. a13n_environment-0.0.4/a13n_environment/files.py +218 -0
  47. a13n_environment-0.0.4/a13n_environment/local_envd/__init__.py +29 -0
  48. a13n_environment-0.0.4/a13n_environment/local_envd/configuration.py +108 -0
  49. a13n_environment-0.0.4/a13n_environment/local_envd/provider.py +866 -0
  50. a13n_environment-0.0.4/a13n_environment/local_envd/runtime.py +120 -0
  51. a13n_environment-0.0.4/a13n_environment/management.py +354 -0
  52. a13n_environment-0.0.4/a13n_environment/models.py +366 -0
  53. a13n_environment-0.0.4/a13n_environment/operations.py +18 -0
  54. a13n_environment-0.0.4/a13n_environment/py.typed +0 -0
  55. a13n_environment-0.0.4/a13n_environment/remote_envd/__init__.py +27 -0
  56. a13n_environment-0.0.4/a13n_environment/remote_envd/configuration.py +72 -0
  57. a13n_environment-0.0.4/a13n_environment/remote_envd/connections.py +235 -0
  58. a13n_environment-0.0.4/a13n_environment/remote_envd/environment.py +162 -0
  59. a13n_environment-0.0.4/a13n_environment/remote_envd/http.py +120 -0
  60. a13n_environment-0.0.4/a13n_environment/remote_envd/provider.py +35 -0
  61. a13n_environment-0.0.4/a13n_environment/remote_envd/websocket.py +80 -0
  62. a13n_environment-0.0.4/a13n_environment/retention.py +225 -0
  63. a13n_environment-0.0.4/a13n_environment/text.py +87 -0
  64. a13n_environment-0.0.4/pyproject.toml +34 -0
  65. a13n_environment-0.0.4/tests/test_catalog.py +401 -0
  66. a13n_environment-0.0.4/tests/test_direct_local.py +178 -0
  67. a13n_environment-0.0.4/tests/test_direct_local_processes.py +278 -0
  68. a13n_environment-0.0.4/tests/test_docker.py +583 -0
  69. a13n_environment-0.0.4/tests/test_e2b_files.py +90 -0
  70. a13n_environment-0.0.4/tests/test_e2b_lifecycle.py +304 -0
  71. a13n_environment-0.0.4/tests/test_e2b_live.py +243 -0
  72. a13n_environment-0.0.4/tests/test_e2b_processes.py +617 -0
  73. a13n_environment-0.0.4/tests/test_local_envd.py +257 -0
  74. a13n_environment-0.0.4/tests/test_local_identity.py +28 -0
  75. a13n_environment-0.0.4/tests/test_management.py +193 -0
  76. a13n_environment-0.0.4/tests/test_models_and_errors.py +84 -0
  77. a13n_environment-0.0.4/tests/test_package.py +7 -0
  78. a13n_environment-0.0.4/tests/test_remote_envd.py +435 -0
  79. a13n_environment-0.0.4/tests/test_remote_envd_e2e.py +308 -0
@@ -0,0 +1,69 @@
1
+ # Local reference and discussion material
2
+ discussion/
3
+ local-reference/
4
+ tmp/
5
+
6
+ # Local runtime storage and caches
7
+ /var/
8
+
9
+ # Python bytecode and native extensions
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+ *.so
14
+
15
+ # Python packaging
16
+ build/
17
+ dist/
18
+ *.egg-info/
19
+ .eggs/
20
+ wheels/
21
+
22
+ # Python environments
23
+ .env
24
+ /dev/live_tests/.state/
25
+ .env.*
26
+ !.env.example
27
+ !.env.harness.example
28
+ .venv/
29
+ env/
30
+ venv/
31
+
32
+ # Tests, coverage, and static analysis
33
+ .coverage
34
+ .coverage.*
35
+ .cache/
36
+ .hypothesis/
37
+ .mypy_cache/
38
+ .nox/
39
+ .pyright/
40
+ .pytest_cache/
41
+ .ruff_cache/
42
+ .tox/
43
+ coverage.xml
44
+ htmlcov/
45
+
46
+ # Documentation output
47
+ site/
48
+
49
+ # Cloudflare Wrangler local state
50
+ .wrangler/
51
+
52
+ # Rust
53
+ target/
54
+ **/*.rs.bk
55
+
56
+ # Frontend tooling
57
+ node_modules/
58
+ *.tsbuildinfo
59
+ /apps/a13n-harness-ui/dist/
60
+ /packages/a13n-harness-ui/a13n_harness_ui/static/
61
+
62
+ # Editors and operating systems
63
+ .DS_Store
64
+ .idea/
65
+
66
+ # Logs and temporary files
67
+ *.log
68
+ *.tmp
69
+ .anycap/
@@ -0,0 +1,201 @@
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 Liability. 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Converge AI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.5
2
+ Name: a13n-environment
3
+ Version: 0.0.4
4
+ Summary: Shared environment provider boundary for Agent Foundation agents
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.13
8
+ Requires-Dist: a13n-envd-client
9
+ Requires-Dist: anyio<5,>=4
10
+ Requires-Dist: docker<8,>=7.2
11
+ Requires-Dist: e2b<3,>=2.46.4
12
+ Requires-Dist: pathspec<2,>=1.1
13
+ Requires-Dist: pydantic-core<3,>=2.41
14
+ Requires-Dist: pydantic<3,>=2.12
15
+ Description-Content-Type: text/markdown
16
+
17
+ # a13n Environment
18
+
19
+ `a13n-environment` is the shared Host-facing Environment provider library for Agent Foundation. The repository directory is `packages/a13n-environment`, the Python distribution is `a13n-environment`, and the import package is `a13n_environment`.
20
+
21
+ The package owns:
22
+
23
+ - credential-free `EnvironmentProviderSpec` envelopes and exact versioned configuration validation;
24
+ - metadata-only installed Provider discovery and immutable built-in, extension, and explicit-object catalogs;
25
+ - inert `EnvironmentProvider` plugins that construct fresh adapters;
26
+ - single-use `Environment` adapters with creation or re-entry, readiness, provider-neutral operations, cached state, non-destructive close, and explicit destruction;
27
+ - portable provider-owned `EnvironmentState` soft references;
28
+ - typed Provider errors with bounded safe projections;
29
+ - Native Direct Local/E2B and Envd Local/Docker/HTTP/WebSocket built-ins;
30
+ - EIP session sources and reusable stdio-carrier values shared with managed sandbox Providers.
31
+
32
+ Embedding code resolves a trusted Provider, validates configuration, supplies current state and fresh runtime collaborators, and constructs one new adapter per independent Harness Run:
33
+
34
+ ```python
35
+ configuration = provider.validate_configuration(
36
+ schema_version=spec.schema_version,
37
+ value=spec.configuration,
38
+ )
39
+ environment = provider.create_environment(
40
+ configuration=configuration,
41
+ environment_id="workspace",
42
+ state=current_state,
43
+ runtime=fresh_runtime,
44
+ )
45
+
46
+ try:
47
+ result = await executable.run("Use the workspace", environment=environment)
48
+ finally:
49
+ current_state = environment.dump_state()
50
+ ```
51
+
52
+ Provider validation and adapter construction perform no external I/O. Harness enters and closes the adapter exactly once. `close()` releases process-local resources without deleting the target; Harness never calls `destroy()`. When Host retention policy selects removal, the Host constructs a separate fresh adapter from the exact current state and calls `destroy()` explicitly.
53
+
54
+ The package does not own durable storage, Host authorization or scheduling, Harness Runs, model-facing tools, mount names, access ceilings, or target retention policy. The Host persists authoritative `EnvironmentState`; Harness owns only Run-local aggregate routing and state mapping.
55
+
56
+ Direct Local exposes an existing Host directory and never deletes, tags, locks, or claims ownership of it. Local Envd launches one compatible Host-selected `a13n-envd` generation for each fresh adapter and removes only its private runtime on close. Docker creates or re-enters one exact local container, exposes authenticated HTTP EIP operations, and preserves the container on close; explicit destruction removes the container and its Provider-owned bootstrap material. Docker never uses exec, archive, copy, or logs for Harness operations. E2B implements native SDK operations with bounded command-local byte capture, state re-entry, pause/resume, keepalive and explicit destruction; it requires no envd installation or custom template. The catalog contains no placeholder or fallback selection.
57
+
58
+ ## Choose a Provider
59
+
60
+ | Route | Provider | Use it for | Operation and ownership boundary |
61
+ | ------ | --------------------------- | ---------------------------------------- | --------------------------------------------------------- |
62
+ | Native | `a13n.direct-local` | Trusted local automation | Host OS operations; existing directory, no sandbox claim |
63
+ | Native | `a13n.e2b` | Native managed cloud sandbox | E2B SDK; sandbox create/pause/resume/renew/destroy |
64
+ | Envd | `a13n.local-envd` | CLI and local Agents | Private stdio daemon; close preserves workspace |
65
+ | Envd | `a13n.docker` (Docker Envd) | Small single-node self-hosted services | Docker lifecycle plus HTTP EIP; close preserves container |
66
+ | Envd | `a13n.http-envd` | Network-reachable external environments | HTTP(S) EIP; connect-only |
67
+ | Envd | `a13n.websocket-envd` | Environments that connect back to a Host | Reverse WebSocket EIP; Host-integrated SDK, connect-only |
68
+
69
+ See [Remote Envd](../../docs/a13n-environment/remote-envd.md) for one-command local demos, external HTTP connection and Host-owned reverse WebSocket integration. The SDK starts no listener; close preserves the external daemon and workspace.
70
+
71
+ ## Docker development
72
+
73
+ The default Docker recipe is empty; the Host passes its instance ID separately to `create_environment()`. It uses `ghcr.io/converge-ai-labs/a13n-sandbox:latest`, pulls when the image is missing, exposes the container-backed `/workspace` virtual mount, and enables Bash. Hosts supply a local Engine adapter and a bootstrap store rooted at a Host-selected directory:
74
+
75
+ ```python
76
+ from pathlib import Path
77
+
78
+ from a13n_environment import (
79
+ DirectoryDockerBootstrapStore,
80
+ DockerProviderRuntime,
81
+ DockerSDKEngine,
82
+ )
83
+
84
+ runtime = DockerProviderRuntime(
85
+ engine=DockerSDKEngine.from_env(),
86
+ bootstrap_store=DirectoryDockerBootstrapStore(Path("/var/lib/my-host/docker-bootstrap")),
87
+ )
88
+ ```
89
+
90
+ The Engine client uses ordinary Host Docker authentication, credential-helper, mirror, and proxy configuration. Bind mounts and existing named volumes are optional Host overrides; named volumes remain externally owned. Run the focused real-image lifecycle test with:
91
+
92
+ ```bash
93
+ make docker-provider-test
94
+ ```
95
+
96
+ ## Local Envd development
97
+
98
+ Hosts select the daemon executable once when constructing `LocalEnvdProviderRuntime`. The convenience resolver uses this precedence:
99
+
100
+ 1. an explicit path passed to `resolve_a13n_envd_executable()`;
101
+ 2. `A13N_ENVD_EXECUTABLE`;
102
+ 3. `a13n-envd` (or `a13n-envd.exe`) discovered through `PATH` with `shutil.which()`.
103
+
104
+ The resolver expands path values, resolves them against the caller's current directory, validates one executable regular file, and returns an absolute path. The package never reads `.env`, changes `PATH`, installs a daemon, or rediscovers the executable after runtime construction.
105
+
106
+ ```python
107
+ from a13n_environment import (
108
+ LocalEnvdProviderRuntime,
109
+ TemporaryLocalEnvdRuntimeAllocator,
110
+ resolve_a13n_envd_executable,
111
+ )
112
+
113
+ runtime = LocalEnvdProviderRuntime(
114
+ executable=resolve_a13n_envd_executable(),
115
+ allocate_private_runtime=TemporaryLocalEnvdRuntimeAllocator(),
116
+ )
117
+ ```
118
+
119
+ Repository developers can optionally copy the `A13N_ENVD_EXECUTABLE` entry from `.env.harness.example` into the root `.env`. The focused target builds the source-tree daemon, loads `.env` only inside the target shell, defaults the variable to `target/debug/a13n-envd`, and runs the real Local Envd tests:
120
+
121
+ ```bash
122
+ make local-envd-test
123
+ ```
124
+
125
+ See the [Environment guide](../../docs/a13n-environment/index.md) for Harness usage, state re-entry, explicit destruction, and third-party plugin development. The runnable [built-in Provider example](../../examples/environment-provider/README.md) exercises Direct Local, Local Envd, and Docker from Host code.
126
+
127
+ ## Versioning
128
+
129
+ `a13n-environment`, `a13n-harness`, and `a13n-stream-protocol` form the Harness release group. A `release/a13n-harness-v<version>` tag publishes all three distributions at exactly the same version, where `<version>` is stable `X.Y.Z` or RC `X.Y.Z-rc.N`. Python package metadata represents the RC as `X.Y.ZrcN`.
130
+
131
+ The accepted architecture and compatibility contract are defined in the [a13n Environment specification](../../spec/a13n-environment/README.md).
@@ -0,0 +1,115 @@
1
+ # a13n Environment
2
+
3
+ `a13n-environment` is the shared Host-facing Environment provider library for Agent Foundation. The repository directory is `packages/a13n-environment`, the Python distribution is `a13n-environment`, and the import package is `a13n_environment`.
4
+
5
+ The package owns:
6
+
7
+ - credential-free `EnvironmentProviderSpec` envelopes and exact versioned configuration validation;
8
+ - metadata-only installed Provider discovery and immutable built-in, extension, and explicit-object catalogs;
9
+ - inert `EnvironmentProvider` plugins that construct fresh adapters;
10
+ - single-use `Environment` adapters with creation or re-entry, readiness, provider-neutral operations, cached state, non-destructive close, and explicit destruction;
11
+ - portable provider-owned `EnvironmentState` soft references;
12
+ - typed Provider errors with bounded safe projections;
13
+ - Native Direct Local/E2B and Envd Local/Docker/HTTP/WebSocket built-ins;
14
+ - EIP session sources and reusable stdio-carrier values shared with managed sandbox Providers.
15
+
16
+ Embedding code resolves a trusted Provider, validates configuration, supplies current state and fresh runtime collaborators, and constructs one new adapter per independent Harness Run:
17
+
18
+ ```python
19
+ configuration = provider.validate_configuration(
20
+ schema_version=spec.schema_version,
21
+ value=spec.configuration,
22
+ )
23
+ environment = provider.create_environment(
24
+ configuration=configuration,
25
+ environment_id="workspace",
26
+ state=current_state,
27
+ runtime=fresh_runtime,
28
+ )
29
+
30
+ try:
31
+ result = await executable.run("Use the workspace", environment=environment)
32
+ finally:
33
+ current_state = environment.dump_state()
34
+ ```
35
+
36
+ Provider validation and adapter construction perform no external I/O. Harness enters and closes the adapter exactly once. `close()` releases process-local resources without deleting the target; Harness never calls `destroy()`. When Host retention policy selects removal, the Host constructs a separate fresh adapter from the exact current state and calls `destroy()` explicitly.
37
+
38
+ The package does not own durable storage, Host authorization or scheduling, Harness Runs, model-facing tools, mount names, access ceilings, or target retention policy. The Host persists authoritative `EnvironmentState`; Harness owns only Run-local aggregate routing and state mapping.
39
+
40
+ Direct Local exposes an existing Host directory and never deletes, tags, locks, or claims ownership of it. Local Envd launches one compatible Host-selected `a13n-envd` generation for each fresh adapter and removes only its private runtime on close. Docker creates or re-enters one exact local container, exposes authenticated HTTP EIP operations, and preserves the container on close; explicit destruction removes the container and its Provider-owned bootstrap material. Docker never uses exec, archive, copy, or logs for Harness operations. E2B implements native SDK operations with bounded command-local byte capture, state re-entry, pause/resume, keepalive and explicit destruction; it requires no envd installation or custom template. The catalog contains no placeholder or fallback selection.
41
+
42
+ ## Choose a Provider
43
+
44
+ | Route | Provider | Use it for | Operation and ownership boundary |
45
+ | ------ | --------------------------- | ---------------------------------------- | --------------------------------------------------------- |
46
+ | Native | `a13n.direct-local` | Trusted local automation | Host OS operations; existing directory, no sandbox claim |
47
+ | Native | `a13n.e2b` | Native managed cloud sandbox | E2B SDK; sandbox create/pause/resume/renew/destroy |
48
+ | Envd | `a13n.local-envd` | CLI and local Agents | Private stdio daemon; close preserves workspace |
49
+ | Envd | `a13n.docker` (Docker Envd) | Small single-node self-hosted services | Docker lifecycle plus HTTP EIP; close preserves container |
50
+ | Envd | `a13n.http-envd` | Network-reachable external environments | HTTP(S) EIP; connect-only |
51
+ | Envd | `a13n.websocket-envd` | Environments that connect back to a Host | Reverse WebSocket EIP; Host-integrated SDK, connect-only |
52
+
53
+ See [Remote Envd](../../docs/a13n-environment/remote-envd.md) for one-command local demos, external HTTP connection and Host-owned reverse WebSocket integration. The SDK starts no listener; close preserves the external daemon and workspace.
54
+
55
+ ## Docker development
56
+
57
+ The default Docker recipe is empty; the Host passes its instance ID separately to `create_environment()`. It uses `ghcr.io/converge-ai-labs/a13n-sandbox:latest`, pulls when the image is missing, exposes the container-backed `/workspace` virtual mount, and enables Bash. Hosts supply a local Engine adapter and a bootstrap store rooted at a Host-selected directory:
58
+
59
+ ```python
60
+ from pathlib import Path
61
+
62
+ from a13n_environment import (
63
+ DirectoryDockerBootstrapStore,
64
+ DockerProviderRuntime,
65
+ DockerSDKEngine,
66
+ )
67
+
68
+ runtime = DockerProviderRuntime(
69
+ engine=DockerSDKEngine.from_env(),
70
+ bootstrap_store=DirectoryDockerBootstrapStore(Path("/var/lib/my-host/docker-bootstrap")),
71
+ )
72
+ ```
73
+
74
+ The Engine client uses ordinary Host Docker authentication, credential-helper, mirror, and proxy configuration. Bind mounts and existing named volumes are optional Host overrides; named volumes remain externally owned. Run the focused real-image lifecycle test with:
75
+
76
+ ```bash
77
+ make docker-provider-test
78
+ ```
79
+
80
+ ## Local Envd development
81
+
82
+ Hosts select the daemon executable once when constructing `LocalEnvdProviderRuntime`. The convenience resolver uses this precedence:
83
+
84
+ 1. an explicit path passed to `resolve_a13n_envd_executable()`;
85
+ 2. `A13N_ENVD_EXECUTABLE`;
86
+ 3. `a13n-envd` (or `a13n-envd.exe`) discovered through `PATH` with `shutil.which()`.
87
+
88
+ The resolver expands path values, resolves them against the caller's current directory, validates one executable regular file, and returns an absolute path. The package never reads `.env`, changes `PATH`, installs a daemon, or rediscovers the executable after runtime construction.
89
+
90
+ ```python
91
+ from a13n_environment import (
92
+ LocalEnvdProviderRuntime,
93
+ TemporaryLocalEnvdRuntimeAllocator,
94
+ resolve_a13n_envd_executable,
95
+ )
96
+
97
+ runtime = LocalEnvdProviderRuntime(
98
+ executable=resolve_a13n_envd_executable(),
99
+ allocate_private_runtime=TemporaryLocalEnvdRuntimeAllocator(),
100
+ )
101
+ ```
102
+
103
+ Repository developers can optionally copy the `A13N_ENVD_EXECUTABLE` entry from `.env.harness.example` into the root `.env`. The focused target builds the source-tree daemon, loads `.env` only inside the target shell, defaults the variable to `target/debug/a13n-envd`, and runs the real Local Envd tests:
104
+
105
+ ```bash
106
+ make local-envd-test
107
+ ```
108
+
109
+ See the [Environment guide](../../docs/a13n-environment/index.md) for Harness usage, state re-entry, explicit destruction, and third-party plugin development. The runnable [built-in Provider example](../../examples/environment-provider/README.md) exercises Direct Local, Local Envd, and Docker from Host code.
110
+
111
+ ## Versioning
112
+
113
+ `a13n-environment`, `a13n-harness`, and `a13n-stream-protocol` form the Harness release group. A `release/a13n-harness-v<version>` tag publishes all three distributions at exactly the same version, where `<version>` is stable `X.Y.Z` or RC `X.Y.Z-rc.N`. Python package metadata represents the RC as `X.Y.ZrcN`.
114
+
115
+ The accepted architecture and compatibility contract are defined in the [a13n Environment specification](../../spec/a13n-environment/README.md).