agentenv-framework 0.9.1254__py3-none-any.whl

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 (312) hide show
  1. agent_env/__init__.py +0 -0
  2. agent_env/a2a_agent/__init__.py +23 -0
  3. agent_env/a2a_agent/a2a_agent.py +600 -0
  4. agent_env/a2a_agent/conversation_store.py +356 -0
  5. agent_env/a2a_agent/object_transfer.py +609 -0
  6. agent_env/a2a_agent/protocol.py +238 -0
  7. agent_env/a2a_agent/store.py +201 -0
  8. agent_env/a2a_agent/validator.py +901 -0
  9. agent_env/artifact/__init__.py +48 -0
  10. agent_env/artifact/artifact.py +74 -0
  11. agent_env/artifact/artifacts/__init__.py +0 -0
  12. agent_env/artifact/artifacts/cli.py +83 -0
  13. agent_env/artifact/artifacts/docker_image.py +457 -0
  14. agent_env/artifact/artifacts/environment.py +89 -0
  15. agent_env/artifact/artifacts/environment_universe.py +156 -0
  16. agent_env/artifact/artifacts/file.py +214 -0
  17. agent_env/artifact/artifacts/file_artifact_universe.py +206 -0
  18. agent_env/artifact/artifacts/skill.py +206 -0
  19. agent_env/artifact/artifacts/vm_image.py +95 -0
  20. agent_env/artifact/ref.py +15 -0
  21. agent_env/artifact/registry.py +251 -0
  22. agent_env/artifact/store.py +295 -0
  23. agent_env/artifact/universe.py +38 -0
  24. agent_env/attribution.py +41 -0
  25. agent_env/bundle/__init__.py +4 -0
  26. agent_env/bundle/_fs.py +128 -0
  27. agent_env/bundle/authoring.py +239 -0
  28. agent_env/bundle/installed.py +175 -0
  29. agent_env/bundle/ledger.py +269 -0
  30. agent_env/bundle/materialize.py +204 -0
  31. agent_env/bundle/parse.py +594 -0
  32. agent_env/bundle/plan.py +414 -0
  33. agent_env/bundle/resolve.py +404 -0
  34. agent_env/bundle/run.py +361 -0
  35. agent_env/cli/__init__.py +69 -0
  36. agent_env/cli/__main__.py +10 -0
  37. agent_env/cli/_installers.py +576 -0
  38. agent_env/cli/_plugin_changes.py +947 -0
  39. agent_env/cli/a2a_agent/__init__.py +22 -0
  40. agent_env/cli/a2a_agent/add_skill.py +97 -0
  41. agent_env/cli/a2a_agent/deploy.py +60 -0
  42. agent_env/cli/a2a_agent/get.py +15 -0
  43. agent_env/cli/a2a_agent/get_instance.py +26 -0
  44. agent_env/cli/a2a_agent/put.py +78 -0
  45. agent_env/cli/a2a_agent/validate.py +56 -0
  46. agent_env/cli/artifact/__init__.py +20 -0
  47. agent_env/cli/artifact/cli.py +83 -0
  48. agent_env/cli/artifact/environment.py +44 -0
  49. agent_env/cli/artifact/environment_universe.py +163 -0
  50. agent_env/cli/artifact/file_artifact_universe.py +281 -0
  51. agent_env/cli/artifact/skill.py +128 -0
  52. agent_env/cli/banner.py +25 -0
  53. agent_env/cli/config.py +263 -0
  54. agent_env/cli/env/__init__.py +31 -0
  55. agent_env/cli/env/deploy.py +112 -0
  56. agent_env/cli/env/gateway.py +57 -0
  57. agent_env/cli/env/get_instance.py +40 -0
  58. agent_env/cli/env/mcp_server.py +410 -0
  59. agent_env/cli/env/multi.py +282 -0
  60. agent_env/cli/env/service_db.py +99 -0
  61. agent_env/cli/env/snapshot.py +35 -0
  62. agent_env/cli/env/state/__init__.py +6 -0
  63. agent_env/cli/env/state/init.py +108 -0
  64. agent_env/cli/env/state/teardown.py +44 -0
  65. agent_env/cli/env/website.py +216 -0
  66. agent_env/cli/env/website_browser.py +67 -0
  67. agent_env/cli/eval/__init__.py +16 -0
  68. agent_env/cli/eval/add_tasks.py +63 -0
  69. agent_env/cli/eval/create.py +49 -0
  70. agent_env/cli/eval/run.py +194 -0
  71. agent_env/cli/identity/__init__.py +5 -0
  72. agent_env/cli/identity/client_identity.py +37 -0
  73. agent_env/cli/plugin.py +438 -0
  74. agent_env/cli/run.py +285 -0
  75. agent_env/cli/task/__init__.py +21 -0
  76. agent_env/cli/task/create.py +109 -0
  77. agent_env/cli/task/get.py +17 -0
  78. agent_env/cli/task/get_instance.py +34 -0
  79. agent_env/cli/task/run.py +615 -0
  80. agent_env/cli/task/validate.py +31 -0
  81. agent_env/cli/up.py +123 -0
  82. agent_env/cli/utils.py +183 -0
  83. agent_env/config/__init__.py +50 -0
  84. agent_env/config/describe.py +1067 -0
  85. agent_env/config/errors.py +13 -0
  86. agent_env/config/loader.py +245 -0
  87. agent_env/config/model.py +154 -0
  88. agent_env/config/paths.py +25 -0
  89. agent_env/config/plugin_tables.py +101 -0
  90. agent_env/config/provenance.py +134 -0
  91. agent_env/config/runtime.py +1064 -0
  92. agent_env/config/snapshot.py +81 -0
  93. agent_env/entity_refs.py +186 -0
  94. agent_env/env/__init__.py +49 -0
  95. agent_env/env/env.py +433 -0
  96. agent_env/env/env_artifact_store.py +87 -0
  97. agent_env/env/envs/__init__.py +7 -0
  98. agent_env/env/envs/_deployment.py +281 -0
  99. agent_env/env/envs/gateway_server.py +32 -0
  100. agent_env/env/envs/mcp_server.py +387 -0
  101. agent_env/env/envs/multi_env.py +780 -0
  102. agent_env/env/envs/service_db/Dockerfile +20 -0
  103. agent_env/env/envs/service_db/Dockerfile.db-mcp +42 -0
  104. agent_env/env/envs/service_db/Dockerfile.db-web +8 -0
  105. agent_env/env/envs/service_db.py +92 -0
  106. agent_env/env/envs/website.py +294 -0
  107. agent_env/env/envs/website_browser/Dockerfile +40 -0
  108. agent_env/env/envs/website_browser/__init__.py +17 -0
  109. agent_env/env/envs/website_browser/entrypoint.sh +13 -0
  110. agent_env/env/gateway/Dockerfile +14 -0
  111. agent_env/env/gateway/__init__.py +37 -0
  112. agent_env/env/gateway/clock.py +184 -0
  113. agent_env/env/gateway/constants.py +190 -0
  114. agent_env/env/gateway/entrypoint.py +156 -0
  115. agent_env/env/gateway/gateway.py +1095 -0
  116. agent_env/env/gateway/get_time.py +60 -0
  117. agent_env/env/gateway/requirements.txt +4 -0
  118. agent_env/env/gateway/triggers.py +1193 -0
  119. agent_env/env/legacy_protocol.py +146 -0
  120. agent_env/env/registry.py +93 -0
  121. agent_env/env/snapshot_store.py +372 -0
  122. agent_env/env/store.py +411 -0
  123. agent_env/eval/__init__.py +14 -0
  124. agent_env/eval/eval.py +68 -0
  125. agent_env/eval/store.py +116 -0
  126. agent_env/examples/hello/README.md +9 -0
  127. agent_env/examples/hello/artifacts/greeting/check.sh +1 -0
  128. agent_env/examples/hello/artifacts/greeting/hello.txt +1 -0
  129. agent_env/examples/hello/tasks/hello.json +10 -0
  130. agent_env/explorer/__init__.py +12 -0
  131. agent_env/explorer/app.py +277 -0
  132. agent_env/explorer/openapi_docs.py +242 -0
  133. agent_env/explorer/plugin.py +95 -0
  134. agent_env/explorer/routers/__init__.py +1 -0
  135. agent_env/explorer/routers/common.py +174 -0
  136. agent_env/explorer/routers/conversations.py +25 -0
  137. agent_env/explorer/routers/objects.py +112 -0
  138. agent_env/explorer/routers/runs.py +475 -0
  139. agent_env/plugins/__init__.py +59 -0
  140. agent_env/plugins/_cli.py +244 -0
  141. agent_env/plugins/_discovery.py +97 -0
  142. agent_env/plugins/_inventory.py +262 -0
  143. agent_env/plugins/_registration.py +268 -0
  144. agent_env/plugins/_report.py +47 -0
  145. agent_env/plugins/_requirements.py +55 -0
  146. agent_env/providers/__init__.py +37 -0
  147. agent_env/providers/env_providers/__init__.py +12 -0
  148. agent_env/providers/env_providers/constants.py +13 -0
  149. agent_env/providers/env_providers/env_gateway_provider.py +1354 -0
  150. agent_env/providers/env_providers/env_provider.py +237 -0
  151. agent_env/providers/env_providers/env_server_provider.py +133 -0
  152. agent_env/providers/env_state/__init__.py +49 -0
  153. agent_env/providers/env_state/env_state_provider.py +554 -0
  154. agent_env/providers/env_state/local_postgres.py +390 -0
  155. agent_env/providers/env_state/store.py +112 -0
  156. agent_env/providers/sandbox_providers/__init__.py +29 -0
  157. agent_env/providers/sandbox_providers/chained_sandbox_provider.py +93 -0
  158. agent_env/providers/sandbox_providers/e2b/__init__.py +6 -0
  159. agent_env/providers/sandbox_providers/e2b/provider.py +376 -0
  160. agent_env/providers/sandbox_providers/e2b/sandbox.py +342 -0
  161. agent_env/providers/sandbox_providers/e2b/template.py +158 -0
  162. agent_env/providers/sandbox_providers/local_sandbox.py +408 -0
  163. agent_env/providers/sandbox_providers/modal_sandbox.py +500 -0
  164. agent_env/providers/sandbox_providers/modal_vm_sandbox.py +466 -0
  165. agent_env/providers/sandbox_providers/sandbox.py +387 -0
  166. agent_env/providers/sandbox_providers/sandbox_provider.py +614 -0
  167. agent_env/py.typed +0 -0
  168. agent_env/runner/__init__.py +16 -0
  169. agent_env/runner/local_runner.py +190 -0
  170. agent_env/runner/runner.py +127 -0
  171. agent_env/runner/store.py +94 -0
  172. agent_env/store/__init__.py +126 -0
  173. agent_env/store/_google.py +68 -0
  174. agent_env/store/base.py +33 -0
  175. agent_env/store/document_store/__init__.py +60 -0
  176. agent_env/store/document_store/document_store.py +519 -0
  177. agent_env/store/document_store/dynamodb_document_store.py +306 -0
  178. agent_env/store/document_store/evaluation.py +199 -0
  179. agent_env/store/document_store/firestore_mongo_document_store.py +242 -0
  180. agent_env/store/document_store/mongo_document_store.py +259 -0
  181. agent_env/store/document_store/sqlite_document_store.py +314 -0
  182. agent_env/store/ids.py +123 -0
  183. agent_env/store/image_store/__init__.py +34 -0
  184. agent_env/store/image_store/ecr_image_store.py +131 -0
  185. agent_env/store/image_store/google_credentials.py +113 -0
  186. agent_env/store/image_store/image_store.py +113 -0
  187. agent_env/store/image_store/local_registry_image_store.py +106 -0
  188. agent_env/store/image_store/oci_registry_credentials.py +196 -0
  189. agent_env/store/local_state.py +27 -0
  190. agent_env/store/object_store/__init__.py +24 -0
  191. agent_env/store/object_store/gcs_object_store.py +415 -0
  192. agent_env/store/object_store/local_object_store.py +143 -0
  193. agent_env/store/object_store/object_store.py +198 -0
  194. agent_env/store/object_store/s3_object_store.py +354 -0
  195. agent_env/store/query.py +112 -0
  196. agent_env/store/routing.py +609 -0
  197. agent_env/store/secret_store/__init__.py +19 -0
  198. agent_env/store/secret_store/aws_secrets_manager_secret_store.py +293 -0
  199. agent_env/store/secret_store/gcp_secret_manager_secret_store.py +319 -0
  200. agent_env/store/secret_store/local_secret_store.py +47 -0
  201. agent_env/store/secret_store/secret_store.py +19 -0
  202. agent_env/task/__init__.py +27 -0
  203. agent_env/task/interrupts.py +109 -0
  204. agent_env/task/registry.py +27 -0
  205. agent_env/task/step_journal.py +99 -0
  206. agent_env/task/store.py +940 -0
  207. agent_env/task/task.py +815 -0
  208. agent_env/task/teardown.py +142 -0
  209. agent_env/task_step/__init__.py +47 -0
  210. agent_env/task_step/context.py +195 -0
  211. agent_env/task_step/context_ops.py +224 -0
  212. agent_env/task_step/registry.py +182 -0
  213. agent_env/task_step/review_store.py +118 -0
  214. agent_env/task_step/snapshot_utils/__init__.py +2 -0
  215. agent_env/task_step/snapshot_utils/agent_state_capture.py +261 -0
  216. agent_env/task_step/snapshot_utils/snapshot_series.py +631 -0
  217. agent_env/task_step/store.py +129 -0
  218. agent_env/task_step/task_step.py +173 -0
  219. agent_env/task_step/task_steps/__init__.py +27 -0
  220. agent_env/task_step/task_steps/a2a_agent_validator/__init__.py +31 -0
  221. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/README.md +158 -0
  222. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.m4a +0 -0
  223. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.mp3 +0 -0
  224. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.mp4 +0 -0
  225. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.ogg +0 -0
  226. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.wav +0 -0
  227. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/document.pdf +0 -0
  228. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.gif +0 -0
  229. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.jpg +0 -0
  230. agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.png +0 -0
  231. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_card.py +103 -0
  232. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_config_identity.py +69 -0
  233. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_mcp.py +178 -0
  234. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_core_protocol.py +67 -0
  235. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_install.py +115 -0
  236. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_litellm_attribution.py +124 -0
  237. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_litellm_attribution_runtime.py +173 -0
  238. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_modalities.py +270 -0
  239. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_peer_agents.py +102 -0
  240. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_role.py +151 -0
  241. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_skill_config.py +194 -0
  242. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_snapshot.py +111 -0
  243. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_system_prompt.py +215 -0
  244. agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_trajectory.py +164 -0
  245. agent_env/task_step/task_steps/add_skills.py +240 -0
  246. agent_env/task_step/task_steps/apply_server_config.py +288 -0
  247. agent_env/task_step/task_steps/collect_artifacts.py +940 -0
  248. agent_env/task_step/task_steps/deploy_agent.py +626 -0
  249. agent_env/task_step/task_steps/deploy_env.py +197 -0
  250. agent_env/task_step/task_steps/deploy_human_agent.py +100 -0
  251. agent_env/task_step/task_steps/deploy_sandbox.py +170 -0
  252. agent_env/task_step/task_steps/env_card_validator/__init__.py +4 -0
  253. agent_env/task_step/task_steps/env_card_validator/verify_env_card.py +109 -0
  254. agent_env/task_step/task_steps/env_card_validator/verify_env_core_protocol.py +108 -0
  255. agent_env/task_step/task_steps/install_agent.py +376 -0
  256. agent_env/task_step/task_steps/load_artifact.py +775 -0
  257. agent_env/task_step/task_steps/mcp_cli_builder/__init__.py +4 -0
  258. agent_env/task_step/task_steps/mcp_cli_builder/build_mcp_cli.py +201 -0
  259. agent_env/task_step/task_steps/mcp_cli_builder/codegen.py +627 -0
  260. agent_env/task_step/task_steps/mcp_env_validator/__init__.py +44 -0
  261. agent_env/task_step/task_steps/mcp_env_validator/validation_gate_aggregator.py +102 -0
  262. agent_env/task_step/task_steps/mcp_env_validator/verify_mcp_env_assessment.py +78 -0
  263. agent_env/task_step/task_steps/mcp_env_validator/verify_mcp_tool_schema.py +152 -0
  264. agent_env/task_step/task_steps/mcp_env_validator/verify_spec_conformance.py +486 -0
  265. agent_env/task_step/task_steps/modify_env_tool_access.py +80 -0
  266. agent_env/task_step/task_steps/multienv_validator/__init__.py +3 -0
  267. agent_env/task_step/task_steps/multienv_validator/combine_universe_verdicts.py +107 -0
  268. agent_env/task_step/task_steps/multienv_validator/universe_comparison.py +253 -0
  269. agent_env/task_step/task_steps/multienv_validator/verify_universe_agent_judge.py +180 -0
  270. agent_env/task_step/task_steps/multienv_validator/verify_universe_roundtrip.py +241 -0
  271. agent_env/task_step/task_steps/peer_agents.py +92 -0
  272. agent_env/task_step/task_steps/prompt_agent.py +900 -0
  273. agent_env/task_step/task_steps/register_agent_triggers.py +113 -0
  274. agent_env/task_step/task_steps/register_env_triggers.py +97 -0
  275. agent_env/task_step/task_steps/reset_env.py +71 -0
  276. agent_env/task_step/task_steps/review.py +152 -0
  277. agent_env/task_step/task_steps/run_code.py +461 -0
  278. agent_env/task_step/task_steps/run_code_runner.py +52 -0
  279. agent_env/task_step/task_steps/run_docker_container.py +380 -0
  280. agent_env/task_step/task_steps/sandbox_utils/__init__.py +0 -0
  281. agent_env/task_step/task_steps/sandbox_utils/sandbox_utils.py +79 -0
  282. agent_env/task_step/task_steps/snapshot_agent_state.py +205 -0
  283. agent_env/task_step/task_steps/snapshot_env.py +637 -0
  284. agent_env/task_step/task_steps/sync_env_clock.py +132 -0
  285. agent_env/task_step/task_steps/teardown_sandboxes.py +170 -0
  286. agent_env/task_step/task_steps/verifiers/__init__.py +23 -0
  287. agent_env/task_step/task_steps/verifiers/agent_prompt_response_verifier.py +166 -0
  288. agent_env/task_step/task_steps/verifiers/aggregate_verifiers.py +90 -0
  289. agent_env/task_step/task_steps/verifiers/env_outcome_verifier.py +127 -0
  290. agent_env/task_step/task_steps/verifiers/judge_utils/__init__.py +2 -0
  291. agent_env/task_step/task_steps/verifiers/judge_utils/frame_selection.py +377 -0
  292. agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py +1293 -0
  293. agent_env/task_step/task_steps/verifiers/judge_utils/trajectory_filter.py +514 -0
  294. agent_env/task_step/task_steps/verifiers/rubrics_verifier.py +1318 -0
  295. agent_env/task_step/task_steps/verifiers/run_container_unit_tests_verifier.py +434 -0
  296. agent_env/task_step/task_steps/verifiers/scoring.py +40 -0
  297. agent_env/task_step/task_steps/verifiers/verify_sandbox.py +308 -0
  298. agent_env/task_step/thread_work.py +61 -0
  299. agent_env/utils/__init__.py +0 -0
  300. agent_env/utils/card_naming.py +108 -0
  301. agent_env/utils/deprecation.py +109 -0
  302. agent_env/utils/docker_build.py +29 -0
  303. agent_env/utils/exec_retry.py +77 -0
  304. agent_env/utils/litellm_attribution.py +59 -0
  305. agent_env/utils/paths.py +20 -0
  306. agentenv_framework-0.9.1254.dist-info/METADATA +394 -0
  307. agentenv_framework-0.9.1254.dist-info/RECORD +312 -0
  308. agentenv_framework-0.9.1254.dist-info/WHEEL +4 -0
  309. agentenv_framework-0.9.1254.dist-info/entry_points.txt +5 -0
  310. agentenv_framework-0.9.1254.dist-info/licenses/LICENSE +202 -0
  311. agentenv_framework-0.9.1254.dist-info/licenses/NOTICE +4 -0
  312. agentenv_framework-0.9.1254.dist-info/licenses/THIRD_PARTY_NOTICES.md +7665 -0
@@ -0,0 +1,614 @@
1
+ """Pluggable sandbox provider — the compute backend behind every env and agent sandbox."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import logging
7
+ import os
8
+ import shlex
9
+ from abc import ABC, abstractmethod
10
+ from typing import TYPE_CHECKING, Any, ClassVar, Optional, Self
11
+ from urllib.parse import urlparse
12
+
13
+ from agent_env.plugins import _registration
14
+ from agent_env.attribution import Attribution
15
+ from agent_env.config import runtime
16
+ from agent_env.config import ENV_REF_PREFIX
17
+ from agent_env.config.errors import ConfigError
18
+ from agent_env.providers.sandbox_providers.sandbox import (
19
+ NetworkPolicy,
20
+ NetworkPolicyUnsupportedError,
21
+ Sandbox,
22
+ VmSandbox,
23
+ )
24
+
25
+ if TYPE_CHECKING:
26
+ from agent_env.config.runtime import Config
27
+
28
+ logger = logging.getLogger(__name__)
29
+
30
+ SANDBOX_MODE_VM = "vm"
31
+ SANDBOX_MODE_CONTAINER = "container"
32
+
33
+
34
+ class SandboxProviderTypeError(ConfigError):
35
+ """A config-registered provider produced a Sandbox whose ``.type`` != its ``[sandbox.providers.<name>]`` key."""
36
+
37
+
38
+ class SandboxProvider(ABC):
39
+ """Compute backend that provisions sandboxes. Selected via [sandbox] default / build_sandbox_provider(); swap via set_sandbox_provider()."""
40
+
41
+ @abstractmethod
42
+ async def create_sandbox(
43
+ self,
44
+ *,
45
+ image_name: str,
46
+ port: int,
47
+ env: dict[str, str],
48
+ cpu: float = 1.0,
49
+ memory: int = 8192,
50
+ disk_size_gb: float = 10,
51
+ timeout: int = 3600 * 2,
52
+ attribution: Optional[Attribution] = None,
53
+ priority: Optional[int] = None,
54
+ network_policy: Optional[NetworkPolicy] = None,
55
+ ) -> Sandbox: ...
56
+
57
+ async def create_vm(
58
+ self,
59
+ *,
60
+ image: Optional[str] = None,
61
+ boot_mode: Optional[str] = None,
62
+ cpu: float = 1.0,
63
+ memory: int = 8192,
64
+ disk_size_gb: float = 10,
65
+ timeout: int = 3600 * 2,
66
+ exposed_ports: Optional[list[int]] = None,
67
+ setup_for_gateway: bool = True,
68
+ attribution: Optional[Attribution] = None,
69
+ priority: Optional[int] = None,
70
+ network_policy: Optional[NetworkPolicy] = None,
71
+ ) -> VmSandbox:
72
+ raise NotImplementedError(f"{type(self).__name__} does not support create_vm")
73
+
74
+ async def create_container(
75
+ self,
76
+ *,
77
+ image_name: str,
78
+ port: int,
79
+ env: dict[str, str],
80
+ cpu: float = 1.0,
81
+ memory: int = 8192,
82
+ disk_size_gb: float = 10,
83
+ timeout: int = 3600 * 2,
84
+ attribution: Optional[Attribution] = None,
85
+ priority: Optional[int] = None,
86
+ network_policy: Optional[NetworkPolicy] = None,
87
+ ) -> Sandbox:
88
+ """Provision a sandbox with the registry image already running as a container.
89
+
90
+ On return, ``tunnel_urls[port]`` is populated and the container listens on ``port``.
91
+ Caller still owns readiness polling for the container's own endpoints.
92
+
93
+ Default implementation: create_vm, authenticate Docker to ECR if applicable, docker pull,
94
+ docker run. Backends that bake the image in at sandbox-creation time (Modal) override.
95
+ """
96
+ sandbox = await self.create_vm(
97
+ cpu=cpu, memory=memory, disk_size_gb=disk_size_gb,
98
+ exposed_ports=[port], timeout=timeout,
99
+ attribution=attribution,
100
+ priority=priority, network_policy=network_policy,
101
+ )
102
+ try:
103
+ from agent_env.config import get_config
104
+
105
+ auth = await asyncio.to_thread(get_config().get_image_store().auth, image_name)
106
+ if auth is not None:
107
+ await sandbox.exec_script(
108
+ f"echo {shlex.quote(auth.password)} | docker login "
109
+ f"--username {shlex.quote(auth.username)} --password-stdin {shlex.quote(auth.registry)}"
110
+ )
111
+ await sandbox.exec_script(f"docker pull {shlex.quote(image_name)}")
112
+ env_flags = " \\\n ".join(
113
+ f"-e {shlex.quote(k)}={shlex.quote(v)}" for k, v in env.items()
114
+ )
115
+ extra_args = f"{self.EXTRA_CONTAINER_RUN_ARGS} " if self.EXTRA_CONTAINER_RUN_ARGS else ""
116
+ host_side = sandbox.host_port(port)
117
+ await sandbox.exec_script(
118
+ f"docker run -d --name {shlex.quote(sandbox.container_name)} -p {host_side}:{port} {extra_args}\\\n "
119
+ f"{env_flags} \\\n {shlex.quote(image_name)} > /dev/null"
120
+ )
121
+ sandbox.mode = SANDBOX_MODE_CONTAINER
122
+ return sandbox
123
+ except Exception:
124
+ try:
125
+ await sandbox.terminate()
126
+ except Exception:
127
+ pass
128
+ raise
129
+
130
+ async def get_sandbox(self, sandbox_id: str) -> Sandbox:
131
+ raise NotImplementedError(f"{type(self).__name__} does not support get_sandbox")
132
+
133
+ async def close(self) -> None:
134
+ pass
135
+
136
+ @classmethod
137
+ def from_config(cls, **config: Any) -> Self:
138
+ """Construct from a resolved config table; backends that need custom wiring override this."""
139
+ return cls(**config)
140
+
141
+ # Internal→external host rewrites for URLs issued on this platform ({} = none).
142
+ URL_REWRITES: ClassVar[dict[str, str]] = {}
143
+
144
+ # Extra flags spliced into the agent container's `docker run` in create_container ("" = none).
145
+ # Backends set this for host-specific needs (e.g. local Linux needs --add-host so the
146
+ # externalized host.docker.internal endpoint resolves inside the container).
147
+ EXTRA_CONTAINER_RUN_ARGS: ClassVar[str] = ""
148
+
149
+ @classmethod
150
+ def get_external_url(cls, url: str) -> str:
151
+ """Rewrite a platform-issued URL to its externally reachable form.
152
+
153
+ Applies ``URL_REWRITES`` longest-key-first (keys may nest); identity
154
+ when nothing matches.
155
+ """
156
+ for host in sorted(cls.URL_REWRITES, key=len, reverse=True):
157
+ if host in url:
158
+ return url.replace(host, cls.URL_REWRITES[host])
159
+ return url
160
+
161
+ @classmethod
162
+ def shares_network_with(cls, sandbox_type: Optional[str]) -> bool:
163
+ """Whether a workload on ``sandbox_type`` can reach this platform's internal URLs.
164
+
165
+ Default: sandboxes of the same provider share a network. Override to widen
166
+ (multi-type platform families) or narrow (isolated tenancy).
167
+ """
168
+ if sandbox_type is None:
169
+ return False
170
+ try:
171
+ return _sandbox_provider_class(sandbox_type) is cls
172
+ except Exception:
173
+ return False
174
+
175
+ # Env vars workloads need to reach this platform's URLs: name -> env:/secret: ref or literal.
176
+ CONTAINER_ENV: ClassVar[dict[str, str]] = {}
177
+
178
+ # Headers for this platform's URLs: host pattern ("*.suffix" or exact) -> header -> env:NAME
179
+ # (a CONTAINER_ENV entry) or literal.
180
+ REQUEST_HEADERS: ClassVar[dict[str, dict[str, str]]] = {}
181
+
182
+ # Hosts on this platform a restricted workload must still reach.
183
+ EGRESS_HOSTS: ClassVar[tuple[str, ...]] = ()
184
+
185
+ @classmethod
186
+ def supports_network_policy(cls, policy: NetworkPolicy) -> bool:
187
+ """Whether this backend can enforce ``policy``. Default: unrestricted only."""
188
+ return not policy.restricts_egress
189
+
190
+ @classmethod
191
+ def effective_network_policy(cls, policy: Optional[NetworkPolicy]) -> NetworkPolicy:
192
+ """``policy`` with the platform's own hosts unioned in; identity unless it allowlists."""
193
+ if policy is None:
194
+ return NetworkPolicy()
195
+ return policy.with_hosts(all_sandbox_egress_hosts())
196
+
197
+
198
+ # --- Provider registry: built-ins + config.toml [sandbox.providers] ---
199
+
200
+ _DEFAULT_SANDBOX_SPEC = "local"
201
+ _DEFAULT_AGENT_SANDBOX_SPEC = "local"
202
+
203
+ _BUILTIN_SANDBOX_PROVIDERS: dict[str, str] = {
204
+ "modal": "agent_env.providers.sandbox_providers.modal_sandbox:ModalSandboxProvider",
205
+ "modal_vm": "agent_env.providers.sandbox_providers.modal_vm_sandbox:ModalVmSandboxProvider",
206
+ "e2b": "agent_env.providers.sandbox_providers.e2b:E2BSandboxProvider",
207
+ "local": "agent_env.providers.sandbox_providers.local_sandbox:LocalSandboxProvider",
208
+ }
209
+
210
+
211
+
212
+ def _sandbox_config(source: Config | None = None) -> dict:
213
+
214
+
215
+ return (source or runtime.get_config()).section("sandbox")
216
+
217
+
218
+ def apply_default_attribution(attribution: Attribution) -> Attribution:
219
+ """``attribution`` with every dimension the caller left unset (absent or None) filled
220
+ from config.toml ``[sandbox.attribution]``. Values take ``env:NAME?default`` references."""
221
+ from agent_env.config import interpolate
222
+
223
+ resolved = dict(attribution)
224
+ for name, value in interpolate(_sandbox_config().get("attribution", {})).items():
225
+ if resolved.get(name) is None:
226
+ resolved[name] = value
227
+ return resolved
228
+
229
+
230
+ def _default_sandbox_spec() -> str:
231
+ return _sandbox_config().get("default", _DEFAULT_SANDBOX_SPEC)
232
+
233
+
234
+ def _agent_sandbox_spec() -> str:
235
+ return _sandbox_config().get("agent_default", _DEFAULT_AGENT_SANDBOX_SPEC)
236
+
237
+
238
+ def _build_registry(source: Config | None = None) -> dict[str, dict]:
239
+ """Built-ins, then ``agent_env.sandbox_providers`` plugins, then config.toml
240
+ ``[sandbox.providers]`` declared in ``source``."""
241
+ registry: dict[str, dict] = {name: {"impl": impl} for name, impl in _BUILTIN_SANDBOX_PROVIDERS.items()}
242
+ from_plugins = _registration.merge(
243
+ registry,
244
+ _registration.SANDBOX_PROVIDERS,
245
+ _validate_plugin,
246
+ source=source,
247
+ entry=lambda cls: {"impl": cls},
248
+ )
249
+ _merge_config_toml_sandbox_providers(registry, source=source, from_plugins=from_plugins)
250
+ return registry
251
+
252
+
253
+ def _validate_plugin(name: str, loaded: Any) -> type[SandboxProvider]:
254
+ cls = _registration.require_subclass(loaded, SandboxProvider)
255
+ if problem := _registration.unimplemented(cls, SandboxProvider):
256
+ raise TypeError(problem)
257
+ return cls
258
+
259
+
260
+ def _get_sandbox_registry() -> dict[str, dict]:
261
+ from agent_env.config import runtime
262
+
263
+ return runtime.get_config().sandbox_registry()
264
+
265
+
266
+ def _merge_config_toml_sandbox_providers(
267
+ registry: dict[str, dict],
268
+ *,
269
+ source: Config | None = None,
270
+ from_plugins: _registration.Registrations | None = None,
271
+ ) -> None:
272
+ """Register ``[sandbox.providers]`` entries (a ``module:Class`` string or a table with ``impl`` +
273
+ optional ``config``) under their name. A table for a BUILT-IN name may carry ``config`` only —
274
+ a built-in's impl cannot be replaced from config. A table for a PLUGIN's name may carry
275
+ ``config`` only, or an ``impl`` that replaces the plugin's with a warning. Other collisions
276
+ and bad impls fail loud."""
277
+ from agent_env.config import ConfigError, load_impl
278
+
279
+ from_plugins = from_plugins if from_plugins is not None else _registration.Registrations.empty()
280
+ for name, entry in _sandbox_config(source).get("providers", {}).items():
281
+ where = f"[sandbox.providers.{name}]"
282
+ plugin = from_plugins.plugin(name)
283
+ config_only = isinstance(entry, dict) and "impl" not in entry
284
+ if config_only and name not in registry and from_plugins.failed(name):
285
+ if not from_plugins.refuse(name, where):
286
+ logger.warning("%s configures a plugin that failed to load; skipped", where)
287
+ continue
288
+ if name in registry and (config_only or plugin is None):
289
+ if not config_only:
290
+ raise ConfigError(
291
+ f"config.toml sandbox provider {name!r} collides with a built-in backend: "
292
+ "a built-in's impl cannot be replaced; supply a config-only table instead"
293
+ )
294
+ owner = "a built-in backend" if plugin is None else f"plugin {plugin}"
295
+ unknown = sorted(set(entry) - {"config"})
296
+ if unknown:
297
+ raise ConfigError(
298
+ f"[sandbox.providers.{name}] configures {owner} and accepts "
299
+ f"only a 'config' table; got {unknown}"
300
+ )
301
+ config = entry.get("config", {})
302
+ if not isinstance(config, dict):
303
+ raise ConfigError(f"[sandbox.providers.{name}].config must be a table, got {type(config).__name__}")
304
+ registry[name] = {**registry[name], "config": dict(config)}
305
+ continue
306
+ section = {"impl": entry} if isinstance(entry, str) else dict(entry)
307
+ impl = section.get("impl")
308
+ if not impl:
309
+ raise ConfigError(f"config.toml sandbox provider {name!r} is missing an 'impl' dotted path")
310
+ cls = load_impl(impl, SandboxProvider)
311
+ if problem := _registration.unimplemented(cls, SandboxProvider):
312
+ raise ConfigError(f"{where} impl {impl!r}: {problem}")
313
+ if from_plugins.refuse(name, where):
314
+ continue
315
+ from_plugins.release(name, f"sandbox.providers.{name}", impl, cls)
316
+ registry[name] = section
317
+
318
+
319
+ def _sandbox_provider_class(sandbox_type: str) -> type[SandboxProvider]:
320
+ """The provider class registered for a single sandbox type (no instantiation)."""
321
+ from agent_env.config import load_impl
322
+
323
+ registry = _get_sandbox_registry()
324
+ if sandbox_type not in registry:
325
+ raise ValueError(
326
+ f"Unknown sandbox type {sandbox_type!r}{_registration.failure_note(_registration.SANDBOX_PROVIDERS, sandbox_type)}; "
327
+ f"known: {sorted(registry)}"
328
+ )
329
+ return load_impl(registry[sandbox_type]["impl"], SandboxProvider)
330
+
331
+
332
+ def reachable_url(url: str, *, from_sandbox_type: Optional[str], to_sandbox_type: Optional[str]) -> str:
333
+ """``url``, issued on ``from_sandbox_type``, in the form reachable by a
334
+ workload on ``to_sandbox_type``.
335
+
336
+ Internal URLs are kept when both sides share a network. Unknown platforms
337
+ leave the URL unchanged; ``from_sandbox_type=None`` resolves to the default
338
+ spec's primary provider.
339
+ """
340
+ from_type = (from_sandbox_type or _default_sandbox_spec()).split(",")[0].strip()
341
+ try:
342
+ provider_cls = _sandbox_provider_class(from_type)
343
+ except ValueError:
344
+ return url
345
+ if provider_cls.shares_network_with(to_sandbox_type):
346
+ return url
347
+ return provider_cls.get_external_url(url)
348
+
349
+
350
+ def registered_sandbox_provider_classes() -> list[type[SandboxProvider]]:
351
+ """Every registered provider class, de-duplicated, in registry order.
352
+
353
+ Best-effort: an unbuildable registry or an unloadable provider is skipped
354
+ rather than raised. These feed *contribution* helpers on deploy paths — a
355
+ provider nobody is deploying to must not be able to fail a deploy. Genuine
356
+ config errors still fail loud wherever a provider is actually built.
357
+ """
358
+ try:
359
+ names = list(_get_sandbox_registry())
360
+ except Exception:
361
+ logger.warning("Sandbox registry unavailable; no provider reachability contributions", exc_info=True)
362
+ return []
363
+ classes: list[type[SandboxProvider]] = []
364
+ for name in names:
365
+ try:
366
+ cls = _sandbox_provider_class(name)
367
+ except Exception:
368
+ logger.debug("Skipping reachability contributions for unloadable sandbox provider %r", name)
369
+ continue
370
+ if cls not in classes:
371
+ classes.append(cls)
372
+ return classes
373
+
374
+
375
+ def all_sandbox_url_rewrites() -> dict[str, str]:
376
+ """Union of every registered provider's ``URL_REWRITES``."""
377
+ rewrites: dict[str, str] = {}
378
+ for cls in registered_sandbox_provider_classes():
379
+ rewrites.update(cls.URL_REWRITES)
380
+ return rewrites
381
+
382
+
383
+ def all_sandbox_container_env() -> dict[str, str]:
384
+ """Union of every registered provider's resolved ``CONTAINER_ENV``.
385
+
386
+ Deliberately provider-agnostic: a workload gets the credentials for every
387
+ registered platform, because at injection time we do not know which
388
+ platform's URLs it will be handed.
389
+ """
390
+ env: dict[str, str] = {}
391
+ for cls in registered_sandbox_provider_classes():
392
+ try:
393
+ env.update(_resolve_container_env(cls))
394
+ except Exception:
395
+ logger.warning("Provider %s failed to contribute container env; skipping", cls.__name__, exc_info=True)
396
+ return env
397
+
398
+
399
+ def all_sandbox_egress_hosts() -> tuple[str, ...]:
400
+ """Every sandbox platform's own hosts, so a restricted workload can still reach its env.
401
+
402
+ Provider-agnostic like ``all_sandbox_container_env``: at deploy time we do not know
403
+ which platform's URLs the workload will be handed.
404
+ """
405
+ hosts: list[str] = []
406
+ for cls in registered_sandbox_provider_classes():
407
+ hosts += [*cls.URL_REWRITES, *cls.URL_REWRITES.values(), *cls.EGRESS_HOSTS]
408
+ kept: dict[str, None] = {}
409
+ for host in hosts:
410
+ if host == "*":
411
+ logger.warning("Dropping a bare '*' egress host; it would defeat the allowlist")
412
+ elif host:
413
+ kept.setdefault(host, None)
414
+ return tuple(kept)
415
+
416
+
417
+ def sandbox_request_headers_for_url(url: str) -> dict[str, str]:
418
+ """Union of every registered provider's headers for ``url``.
419
+
420
+ Each provider's host patterns gate it, so a URL only collects headers
421
+ from the platform that issued it.
422
+ """
423
+ headers: dict[str, str] = {}
424
+ for cls in registered_sandbox_provider_classes():
425
+ try:
426
+ if not cls.REQUEST_HEADERS:
427
+ continue
428
+ host = urlparse(url).hostname or ""
429
+ wanted = {
430
+ header: value
431
+ for pattern, entries in cls.REQUEST_HEADERS.items()
432
+ if (host.endswith(pattern[1:]) if pattern.startswith("*.") else host == pattern)
433
+ for header, value in entries.items()
434
+ }
435
+ if not wanted:
436
+ continue
437
+ needs_env = any(v.startswith(ENV_REF_PREFIX) for v in wanted.values())
438
+ env = _resolve_container_env(cls) if needs_env else {}
439
+ if needs_env and not env:
440
+ if not cls.CONTAINER_ENV:
441
+ logger.warning("%s REQUEST_HEADERS reference env vars but CONTAINER_ENV is empty", cls.__name__)
442
+ continue
443
+ headers.update({
444
+ header: env[value[len(ENV_REF_PREFIX):]] if value.startswith(ENV_REF_PREFIX) else value
445
+ for header, value in wanted.items()
446
+ })
447
+ except Exception:
448
+ logger.warning("Provider %s failed to contribute request headers; skipping", cls.__name__, exc_info=True)
449
+ return headers
450
+
451
+
452
+ def _resolve_container_env(provider_cls: type[SandboxProvider]) -> dict[str, str]:
453
+ """``provider_cls.CONTAINER_ENV`` resolved to values.
454
+
455
+ A process env var named like the entry wins over its reference. All-or-nothing:
456
+ when any entry is unresolvable the provider contributes nothing, so a
457
+ half-configured platform cannot inject half its credentials.
458
+ """
459
+ from agent_env.config import get_config, interpolate
460
+
461
+ env: dict[str, str] = {}
462
+ for name, ref in provider_cls.CONTAINER_ENV.items():
463
+ value = os.environ.get(name)
464
+ if not value:
465
+ try:
466
+ value = interpolate(ref, secret_resolver=lambda key: get_config().get_secret_store().get(key))
467
+ except Exception:
468
+ logger.warning(
469
+ "%s container env unresolvable (%s); workloads off its network may not reach its URLs",
470
+ provider_cls.__name__, name,
471
+ )
472
+ return {}
473
+ env[name] = value
474
+ return env
475
+
476
+
477
+ def refuse_unenforceable_policy(provider: SandboxProvider, policy: Optional[NetworkPolicy]) -> None:
478
+ """Fail before provisioning rather than return a sandbox that ignores ``policy``."""
479
+ if policy is not None and not provider.supports_network_policy(policy):
480
+ raise NetworkPolicyUnsupportedError(
481
+ f"{type(provider).__name__} cannot enforce network policy mode {policy.mode.value!r}"
482
+ )
483
+
484
+
485
+ def _install_sandbox_type_guard(provider: SandboxProvider, name: str) -> SandboxProvider:
486
+ """Wrap the provider's ``create_*`` so every sandbox it makes has ``.type == name``; on mismatch,
487
+ terminate it and raise. Decorated in place to preserve provider identity."""
488
+ import functools
489
+
490
+ def _guarded(method):
491
+ @functools.wraps(method)
492
+ async def wrapper(*args, **kwargs):
493
+ sandbox = await method(*args, **kwargs)
494
+ if sandbox is not None and sandbox.type != name:
495
+ actual = sandbox.type
496
+ try:
497
+ await sandbox.terminate()
498
+ except Exception as e:
499
+ logger.warning(f"Failed to terminate mis-typed sandbox from [sandbox.providers.{name}]: {e}")
500
+ raise SandboxProviderTypeError(
501
+ f"[sandbox.providers.{name}] produced a sandbox with .type={actual!r}; the config name "
502
+ f"must equal the produced Sandbox.type. Rename the key to {actual!r} or set the type to {name!r}."
503
+ )
504
+ return sandbox
505
+
506
+ return wrapper
507
+
508
+ for method_name in ("create_sandbox", "create_vm", "create_container"):
509
+ try:
510
+ setattr(provider, method_name, _guarded(getattr(provider, method_name)))
511
+ except AttributeError as e:
512
+ raise ConfigError(
513
+ f"Cannot install the deploy-time type guard on sandbox provider {name!r} "
514
+ f"({type(provider).__name__}): its instances don't allow attribute assignment "
515
+ f"(e.g. __slots__ without __dict__)."
516
+ ) from e
517
+ return provider
518
+
519
+
520
+ def _build_sandbox_provider_from_section(name: str, section: dict) -> SandboxProvider:
521
+ from agent_env.config import interpolate, load_impl
522
+ from agent_env.config import get_config
523
+
524
+ cls = load_impl(section["impl"], SandboxProvider)
525
+ config = interpolate(
526
+ section.get("config", {}), secret_resolver=lambda key: get_config().get_secret_store().get(key)
527
+ )
528
+ provider = cls.from_config(**config)
529
+ if name in _BUILTIN_SANDBOX_PROVIDERS:
530
+ return provider
531
+ return _install_sandbox_type_guard(provider, name)
532
+
533
+
534
+ def build_sandbox_provider(spec: str) -> SandboxProvider:
535
+ """Build a provider (or a comma-separated fallback chain) from backend names,
536
+ resolved through the open registry (built-ins + config.toml [sandbox.providers])."""
537
+ registry = _get_sandbox_registry()
538
+ names = [s.strip() for s in spec.split(",") if s.strip()]
539
+ if not names:
540
+ raise ValueError("sandbox spec must include at least one backend")
541
+ for n in names:
542
+ if n not in registry:
543
+ raise ValueError(
544
+ f"Unknown sandbox backend: {n!r}{_registration.failure_note(_registration.SANDBOX_PROVIDERS, n)} "
545
+ f"(expected one of {sorted(registry)})"
546
+ )
547
+ providers = [_build_sandbox_provider_from_section(n, registry[n]) for n in names]
548
+ if len(providers) == 1:
549
+ return providers[0]
550
+ from agent_env.providers.sandbox_providers.chained_sandbox_provider import ChainedSandboxProvider
551
+
552
+ return ChainedSandboxProvider(providers)
553
+
554
+
555
+ # --- Default sandbox provider (envs, agent provider, CLI, task steps) ---
556
+
557
+ _sandbox_provider: Optional[SandboxProvider] = None
558
+
559
+
560
+ def get_sandbox_provider() -> SandboxProvider:
561
+ global _sandbox_provider
562
+ if _sandbox_provider is None:
563
+ _sandbox_provider = build_sandbox_provider(_default_sandbox_spec())
564
+ return _sandbox_provider
565
+
566
+
567
+ def set_sandbox_provider(provider: SandboxProvider) -> None:
568
+ global _sandbox_provider
569
+ _sandbox_provider = provider
570
+
571
+
572
+ def reset_sandbox_provider() -> None:
573
+ global _sandbox_provider
574
+ _sandbox_provider = None
575
+
576
+
577
+ _env_sandbox_provider: Optional[SandboxProvider] = None
578
+
579
+
580
+ def get_env_sandbox_provider() -> SandboxProvider:
581
+ global _env_sandbox_provider
582
+ if _env_sandbox_provider is None:
583
+ _env_sandbox_provider = build_sandbox_provider(_default_sandbox_spec())
584
+ return _env_sandbox_provider
585
+
586
+
587
+ def set_env_sandbox_provider(provider: SandboxProvider) -> None:
588
+ global _env_sandbox_provider
589
+ _env_sandbox_provider = provider
590
+
591
+
592
+ def reset_env_sandbox_provider() -> None:
593
+ global _env_sandbox_provider
594
+ _env_sandbox_provider = None
595
+
596
+
597
+ _agent_sandbox_provider: Optional[SandboxProvider] = None
598
+
599
+
600
+ def get_agent_sandbox_provider() -> SandboxProvider:
601
+ global _agent_sandbox_provider
602
+ if _agent_sandbox_provider is None:
603
+ _agent_sandbox_provider = build_sandbox_provider(_agent_sandbox_spec())
604
+ return _agent_sandbox_provider
605
+
606
+
607
+ def set_agent_sandbox_provider(provider: SandboxProvider) -> None:
608
+ global _agent_sandbox_provider
609
+ _agent_sandbox_provider = provider
610
+
611
+
612
+ def reset_agent_sandbox_provider() -> None:
613
+ global _agent_sandbox_provider
614
+ _agent_sandbox_provider = None
agent_env/py.typed ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ """Run dispatch: the seam between "run this task" and ``Task.run()``."""
2
+
3
+ from agent_env.runner.runner import RunHandle, RunRecord, Runner, RunStatus
4
+
5
+ __all__ = ["RunHandle", "RunRecord", "Runner", "RunStatus", "LocalRunner", "get_runner"]
6
+
7
+
8
+ def __getattr__(name: str):
9
+ # Lazy so importing the package does not pull the store/config chain.
10
+ if name == "LocalRunner":
11
+ from agent_env.runner.local_runner import LocalRunner
12
+ return LocalRunner
13
+ if name == "get_runner":
14
+ from agent_env.config import get_config
15
+ return get_config().get_runner
16
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")