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,22 @@
1
+ import click
2
+
3
+ from .add_skill import add_skill
4
+ from .deploy import deploy
5
+ from .get import get
6
+ from .get_instance import get_instance
7
+ from .put import put
8
+ from .validate import validate
9
+
10
+
11
+ @click.group(name="a2a-agent")
12
+ def a2a_agent():
13
+ """A2A agent commands."""
14
+ pass
15
+
16
+
17
+ a2a_agent.add_command(put)
18
+ a2a_agent.add_command(get)
19
+ a2a_agent.add_command(deploy)
20
+ a2a_agent.add_command(get_instance)
21
+ a2a_agent.add_command(validate)
22
+ a2a_agent.add_command(add_skill)
@@ -0,0 +1,97 @@
1
+ import asyncio
2
+ from pathlib import Path
3
+ from typing import Optional
4
+
5
+ import click
6
+
7
+ from agent_env.a2a_agent import A2AAgent
8
+ from agent_env.a2a_agent.store import get_a2a_agent_instance_store
9
+ from agent_env.store.base import NotFoundError
10
+ from agent_env.task_step.task_steps.add_skills import Skill
11
+
12
+
13
+ # ---------------------------------------------------------------------------
14
+ # agent-env a2a-agent add-skill --instance-id <id> --skill-artifact-id code-review
15
+ # agent-env a2a-agent add-skill --instance-id <id> --skill-md-path ./SKILL.md
16
+ # agent-env a2a-agent add-skill --instance-id <id> --skill-s3-url s3://bucket/prefix/
17
+ # ---------------------------------------------------------------------------
18
+
19
+
20
+ @click.command("add-skill")
21
+ @click.option("--instance-id", "instance_id", required=True, help="Deployed A2A agent instance ID")
22
+ @click.option(
23
+ "--skill-artifact-id",
24
+ "skill_artifact_id",
25
+ default=None,
26
+ help="SkillArtifact id (loads the stored skill and registers it)",
27
+ )
28
+ @click.option(
29
+ "--skill-artifact-version",
30
+ "skill_artifact_version",
31
+ type=int,
32
+ default=None,
33
+ help="SkillArtifact version (default: latest)",
34
+ )
35
+ @click.option(
36
+ "--skill-md-path",
37
+ "skill_md_path",
38
+ type=click.Path(exists=True, dir_okay=False, file_okay=True, path_type=Path),
39
+ default=None,
40
+ help="Local SKILL.md file to register inline",
41
+ )
42
+ @click.option(
43
+ "--skill-s3-url",
44
+ "skill_s3_url",
45
+ default=None,
46
+ help="S3 prefix containing a skill directory",
47
+ )
48
+ def add_skill(
49
+ instance_id: str,
50
+ skill_artifact_id: Optional[str],
51
+ skill_artifact_version: Optional[int],
52
+ skill_md_path: Optional[Path],
53
+ skill_s3_url: Optional[str],
54
+ ):
55
+ """Register a skill against a deployed A2A agent's /ext/skill-config endpoint."""
56
+ sources = [bool(skill_artifact_id), bool(skill_md_path), bool(skill_s3_url)]
57
+ if sum(sources) != 1:
58
+ click.echo(
59
+ "Error: specify exactly one of --skill-artifact-id, --skill-md-path, --skill-s3-url",
60
+ err=True,
61
+ )
62
+ raise SystemExit(1)
63
+
64
+ try:
65
+ deployed = get_a2a_agent_instance_store().get(instance_id)
66
+ except NotFoundError:
67
+ click.echo(f"Error: instance '{instance_id}' not found", err=True)
68
+ raise SystemExit(1)
69
+
70
+ click.echo(f"Deployed agent: {deployed.agent_id} v{deployed.agent_version} @ {deployed.a2a_url}")
71
+
72
+ if skill_artifact_id is not None:
73
+ skill = Skill(skill_artifact_id=skill_artifact_id, skill_artifact_version=skill_artifact_version)
74
+ click.echo(f"Registering SkillArtifact '{skill_artifact_id}' v{skill_artifact_version or 'latest'}...")
75
+ elif skill_s3_url is not None:
76
+ from agent_env.artifact.artifacts.skill import _fetch_skill_md, _parse_skill_md
77
+
78
+ frontmatter, _ = _parse_skill_md(_fetch_skill_md(skill_s3_url))
79
+ skill = Skill(name=frontmatter["name"], description=frontmatter["description"], s3_url=skill_s3_url)
80
+ click.echo(f"Registering skill from {skill_s3_url} (name={skill.name})...")
81
+ else:
82
+ from agent_env.artifact.artifacts.skill import _parse_skill_md
83
+
84
+ frontmatter, body = _parse_skill_md(skill_md_path.read_bytes())
85
+ skill = Skill(
86
+ name=frontmatter["name"],
87
+ description=frontmatter["description"],
88
+ body=body,
89
+ license=frontmatter.get("license"),
90
+ compatibility=frontmatter.get("compatibility"),
91
+ metadata=frontmatter.get("metadata"),
92
+ allowed_tools=frontmatter.get("allowed-tools"),
93
+ )
94
+ click.echo(f"Registering inline skill from {skill_md_path} (name={skill.name})...")
95
+
96
+ result = asyncio.run(A2AAgent.add_skill(deployed, skill))
97
+ click.echo(f"Registered: {result}")
@@ -0,0 +1,60 @@
1
+ import asyncio
2
+ import sys
3
+
4
+ import click
5
+
6
+ from agent_env.a2a_agent import A2AAgent
7
+ from agent_env.store.routing import run_scope
8
+
9
+ MIN_TTL_SECONDS = 60
10
+ MAX_TTL_SECONDS = 1209600
11
+ DEFAULT_TTL_SECONDS = 7200
12
+
13
+
14
+ @click.command()
15
+ @click.option("--id", "agent_id", required=True, help="A2A agent id")
16
+ @click.option("--version", "agent_version", default=None, type=int, help="Agent version (defaults to latest)")
17
+ @click.option("--env-var", "env_var_pairs", multiple=True, help="Override env var KEY=VALUE (repeatable)")
18
+ @click.option("--ttl-seconds", type=click.IntRange(min=MIN_TTL_SECONDS, max=MAX_TTL_SECONDS), default=DEFAULT_TTL_SECONDS,
19
+ help=f"VM lifetime in seconds (default {DEFAULT_TTL_SECONDS})")
20
+ @click.option("--sandbox", default=None,
21
+ help="Sandbox backend(s): a built-in (modal, modal_vm, e2b, local) "
22
+ "or a name from [sandbox.providers] in .agentenv/config.toml; comma-separated for a "
23
+ "fallback chain. Defaults to [sandbox].agent_default (else local) when omitted.")
24
+ @click.option("--priority", type=int, default=0, show_default=True,
25
+ help="Sandbox priority: 0=interactive, 1=non_interactive (honoured by backends with priority tiers)")
26
+ def deploy(agent_id: str, agent_version: int | None, env_var_pairs: tuple[str, ...], ttl_seconds: int, sandbox: str, priority: int):
27
+ """Deploy an A2A agent on a sandbox VM."""
28
+ from agent_env.providers import build_sandbox_provider, set_agent_sandbox_provider
29
+
30
+ if sandbox:
31
+ try:
32
+ provider = build_sandbox_provider(sandbox)
33
+ except ValueError as e:
34
+ raise click.BadParameter(str(e), param_hint="'--sandbox'")
35
+ set_agent_sandbox_provider(provider)
36
+ click.echo(f"Sandbox backend: {sandbox or 'config default'}")
37
+
38
+ env_vars = {}
39
+ for pair in env_var_pairs:
40
+ if "=" not in pair:
41
+ click.echo(f"Invalid env-var format '{pair}', expected KEY=VALUE", err=True)
42
+ sys.exit(1)
43
+ key, value = pair.split("=", 1)
44
+ env_vars[key] = value
45
+
46
+ click.echo(f"Fetching A2A agent: id={agent_id} version={agent_version or 'latest'}...")
47
+ agent = A2AAgent.get(agent_id, agent_version)
48
+ click.echo(f"Found: id={agent.id} version={agent.version} image={agent.docker_image_artifact.id}")
49
+
50
+ click.echo(f"Deploying (ttl={ttl_seconds}s)...")
51
+ with run_scope(agent.id):
52
+ deployed = asyncio.run(agent.deploy(ttl_seconds=ttl_seconds, env_vars=env_vars if env_vars else None, priority=priority))
53
+
54
+ click.echo("Deployed!")
55
+ click.echo("Instance ID: " + click.style(deployed.instance_id, fg="green"))
56
+ click.echo("A2A URL: " + click.style(deployed.a2a_url, fg="green"))
57
+ click.echo("Sandbox ID: " + click.style(deployed.sandbox_id, fg="yellow"))
58
+ click.echo(f"Agent Card: {deployed.agent_card.get('name', 'unknown')}")
59
+ if deployed.expires_at_utc:
60
+ click.echo(f"Expires At (UTC): {deployed.expires_at_utc}")
@@ -0,0 +1,15 @@
1
+ import json
2
+
3
+ import click
4
+
5
+ from agent_env.a2a_agent import A2AAgent
6
+
7
+
8
+ @click.command()
9
+ @click.option("--id", "agent_id", required=True, help="A2A agent id")
10
+ @click.option("--version", "agent_version", default=None, type=int, help="Agent version (defaults to latest)")
11
+ def get(agent_id: str, agent_version: int | None):
12
+ """Get an A2A agent and output its definition as JSON."""
13
+
14
+ agent = A2AAgent.get(agent_id, agent_version)
15
+ click.echo(json.dumps(agent.to_dict(), indent=2))
@@ -0,0 +1,26 @@
1
+ import click
2
+
3
+
4
+ @click.command("get-instance")
5
+ @click.option("--id", "instance_id", required=True, help="Instance ID")
6
+ def get_instance(instance_id: str):
7
+ """Look up a deployed A2A agent instance."""
8
+ from agent_env.a2a_agent.store import get_a2a_agent_instance_store
9
+ from agent_env.store.base import NotFoundError
10
+
11
+ try:
12
+ deployed = get_a2a_agent_instance_store().get(instance_id)
13
+ except NotFoundError:
14
+ click.echo(f"Error: Instance '{instance_id}' not found", err=True)
15
+ raise SystemExit(1)
16
+
17
+ click.echo(f"Instance ID: {deployed.instance_id}")
18
+ click.echo(f"Agent ID: {deployed.agent_id}")
19
+ click.echo(f"Agent Version: {deployed.agent_version}")
20
+ click.echo(f"A2A URL: {deployed.a2a_url}")
21
+ click.echo(f"Sandbox ID: {deployed.sandbox_id}")
22
+ click.echo(f"Agent Card: {deployed.agent_card.get('name', 'unknown')}")
23
+ if deployed.created_at_utc:
24
+ click.echo(f"Created At (UTC): {deployed.created_at_utc}")
25
+ if deployed.expires_at_utc:
26
+ click.echo(f"Expires At (UTC): {deployed.expires_at_utc}")
@@ -0,0 +1,78 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ import click
5
+
6
+ from agent_env.a2a_agent import A2AAgent
7
+ from agent_env.artifact import DockerImageArtifact
8
+ from agent_env.cli.utils import build_platform_option, detect_env_metadata, skips_local_validation
9
+ from agent_env.utils.docker_build import build_image
10
+
11
+
12
+ @click.command()
13
+ @click.option("--id", "agent_id", required=True, help="A2A agent id")
14
+ @click.option("--dockerfile", required=True, type=click.Path(exists=True), help="Path to Dockerfile")
15
+ @click.option("--context", "context_path", default=None, type=click.Path(exists=True), help="Docker build context (defaults to Dockerfile's directory)")
16
+ @click.option("--env-var", "env_var_pairs", multiple=True, help="Default env var KEY=VALUE (repeatable)")
17
+ @click.option("--metadata", "metadata_pairs", multiple=True, help="Metadata key=value pair (repeatable)")
18
+ @click.option("--min-disk-size-gb", type=float, default=None, help="Minimum disk size in GB for agent deployment")
19
+ @click.option("--default-model", type=str, default=None, help="Default model for agent prompts (e.g., claude-sonnet-4-6)")
20
+ @click.option("--skip-validation", is_flag=True, default=False, help="Skip A2A agent validation after registration")
21
+ @click.option("--litellm-api-key", type=str, default=None, help="LiteLLM API key for validation prompts")
22
+ @build_platform_option
23
+ def put(agent_id: str, dockerfile: str, context_path: str | None, env_var_pairs: tuple[str, ...], metadata_pairs: tuple[str, ...], min_disk_size_gb: float | None, default_model: str | None, skip_validation: bool, litellm_api_key: str | None, build_platform: str):
24
+ """Build a Docker image and register an A2A agent."""
25
+
26
+ default_env_vars = {}
27
+ for pair in env_var_pairs:
28
+ if "=" not in pair:
29
+ click.echo(f"Invalid env-var format '{pair}', expected KEY=VALUE", err=True)
30
+ sys.exit(1)
31
+ key, value = pair.split("=", 1)
32
+ default_env_vars[key] = value
33
+
34
+ user_metadata = {}
35
+ for pair in metadata_pairs:
36
+ if "=" not in pair:
37
+ click.echo(f"Invalid metadata format '{pair}', expected key=value", err=True)
38
+ sys.exit(1)
39
+ key, value = pair.split("=", 1)
40
+ user_metadata[key] = value
41
+
42
+ dockerfile_path = Path(dockerfile)
43
+ context = Path(context_path) if context_path else dockerfile_path.parent
44
+ image_tag = f"a2a-agent-{agent_id}"
45
+
46
+ click.echo(f"Building Docker image...")
47
+ build_image(dockerfile_path, context, image_tag, platform=build_platform)
48
+
49
+ click.echo(f"Creating DockerImageArtifact...")
50
+ artifact = DockerImageArtifact.put(
51
+ id=f"a2a-agent-{agent_id}",
52
+ description=f"A2A agent image for {agent_id}",
53
+ image_name=image_tag,
54
+ build_context_path=str(context),
55
+ dockerfile_path=str(dockerfile_path),
56
+ )
57
+ click.echo(f"Created artifact: id={artifact.id} version={artifact.version}")
58
+
59
+ metadata = detect_env_metadata(dockerfile_path, context)
60
+ metadata.update(user_metadata)
61
+ if min_disk_size_gb is not None:
62
+ metadata["min_disk_size_gb"] = min_disk_size_gb
63
+ if default_model is not None:
64
+ metadata["default_model"] = default_model
65
+
66
+ click.echo(f"Registering A2A agent...")
67
+ agent = A2AAgent.put(
68
+ id=agent_id,
69
+ docker_image_artifact=artifact,
70
+ default_env_vars=default_env_vars if default_env_vars else None,
71
+ metadata=metadata if metadata else None,
72
+ )
73
+ click.echo(f"Created A2A agent: id={agent.id} version={agent.version} image={artifact.id}:{artifact.version}")
74
+
75
+ if not skip_validation and not skips_local_validation(agent_id, "agent"):
76
+ from agent_env.cli.a2a_agent.validate import run_validation
77
+ click.echo()
78
+ run_validation(agent, litellm_api_key=litellm_api_key)
@@ -0,0 +1,56 @@
1
+ import asyncio
2
+ import json
3
+ import sys
4
+
5
+ import click
6
+
7
+ from agent_env.a2a_agent import A2AAgent
8
+
9
+
10
+ def run_validation(agent: A2AAgent, litellm_api_key: str | None = None) -> dict:
11
+ """Run validation and display results. Returns verifications dict."""
12
+ click.echo(f"Validating agent: id={agent.id} version={agent.version} image={agent.docker_image_artifact.id}")
13
+
14
+ verifications = asyncio.run(agent.validate(on_progress=click.echo, litellm_api_key=litellm_api_key))
15
+
16
+ # Re-fetch agent to get the persisted metadata
17
+ agent = A2AAgent.get(agent.id, agent.version)
18
+
19
+ for key in ("validated_agent_card", "validated_a2a_protocol", "validated_a2a_extensions", "validated_data_extensions", "validated_litellm_attribution", "validated_litellm_attribution_runtime"):
20
+ value = agent.metadata.get(key, {})
21
+ click.echo(click.style(f"\n{key}:", bold=True))
22
+ click.echo(json.dumps(value, indent=2))
23
+
24
+ return verifications
25
+
26
+
27
+ @click.command()
28
+ @click.option("--id", "agent_id", required=True, help="A2A agent id")
29
+ @click.option("--version", "agent_version", default=None, type=int, help="Agent version (defaults to latest)")
30
+ @click.option("--litellm-api-key", type=str, default=None, help="LiteLLM API key for agent prompts")
31
+ @click.option("--sandbox", default=None,
32
+ help="Sandbox backend(s): a built-in or a [sandbox.providers] name from .agentenv/config.toml; "
33
+ "comma-separated for a fallback chain. Defaults to [sandbox].agent_default when omitted.")
34
+ def validate(agent_id: str, agent_version: int | None, litellm_api_key: str | None, sandbox: str):
35
+ """Deploy an A2A agent, validate its agent card and MCP extension."""
36
+ from agent_env.providers import build_sandbox_provider, set_agent_sandbox_provider
37
+ from agent_env.store.base import NotFoundError
38
+
39
+ if sandbox:
40
+ try:
41
+ provider = build_sandbox_provider(sandbox)
42
+ except ValueError as e:
43
+ raise click.BadParameter(str(e), param_hint="'--sandbox'")
44
+ set_agent_sandbox_provider(provider)
45
+ click.echo(f"Sandbox backend: {sandbox or 'config default'}")
46
+
47
+ try:
48
+ agent = A2AAgent.get(agent_id, agent_version)
49
+ except NotFoundError:
50
+ click.echo(click.style(f"Error: A2AAgent '{agent_id}' not found", fg="red"), err=True)
51
+ sys.exit(1)
52
+
53
+ verifications = run_validation(agent, litellm_api_key=litellm_api_key)
54
+
55
+ if not verifications.get("a2a_agent_mcp", {}).get("passed", False):
56
+ sys.exit(1)
@@ -0,0 +1,20 @@
1
+ import click
2
+
3
+ from .cli import cli
4
+ from .file_artifact_universe import file_artifact_universe
5
+ from .environment import environment
6
+ from .environment_universe import environment_universe
7
+ from .skill import skill
8
+
9
+
10
+ @click.group()
11
+ def artifact():
12
+ """Artifact commands."""
13
+ pass
14
+
15
+
16
+ artifact.add_command(cli)
17
+ artifact.add_command(file_artifact_universe)
18
+ artifact.add_command(environment)
19
+ artifact.add_command(environment_universe)
20
+ artifact.add_command(skill)
@@ -0,0 +1,83 @@
1
+ from pathlib import Path
2
+ from typing import Optional
3
+
4
+ import click
5
+
6
+ from agent_env.artifact import CliArtifact
7
+
8
+
9
+ @click.group(name="cli")
10
+ def cli():
11
+ """CliArtifact commands."""
12
+ pass
13
+
14
+
15
+ @cli.command("put")
16
+ @click.option("--id", "artifact_id", required=True, help="CliArtifact id")
17
+ @click.option(
18
+ "--cli-dir",
19
+ required=True,
20
+ type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path),
21
+ help="Local directory containing the CLI tree",
22
+ )
23
+ @click.option("--entrypoint", required=True, help="Relative path within --cli-dir to the executable file (e.g. 'bin/slack')")
24
+ @click.option("--command-name", required=True, help="Command name installed on PATH (e.g. 'slack' -> /usr/local/bin/slack)")
25
+ @click.option("--env-id", default=None, help="Optional source env id this CLI was generated from")
26
+ @click.option("--env-version", type=int, default=None, help="Optional source env version this CLI was generated from")
27
+ def cli_put(
28
+ artifact_id: str,
29
+ cli_dir: Path,
30
+ entrypoint: str,
31
+ command_name: str,
32
+ env_id: Optional[str],
33
+ env_version: Optional[int],
34
+ ):
35
+ """Upload a CLI directory as a CliArtifact."""
36
+
37
+ file_count = sum(1 for p in cli_dir.rglob("*") if p.is_file())
38
+ click.echo(f"Uploading CliArtifact bundle ({file_count} file(s)) from {cli_dir}...")
39
+ result = CliArtifact.put(
40
+ id=artifact_id,
41
+ command_name=command_name,
42
+ entrypoint=entrypoint,
43
+ cli_dir=cli_dir,
44
+ env_id=env_id,
45
+ env_version=env_version,
46
+ )
47
+ click.echo(
48
+ f"Created CliArtifact: id={result.id} version={result.version} "
49
+ f"command_name={result.command_name} entrypoint={result.entrypoint} "
50
+ f"cli_files_id={result.cli_files_id} cli_s3_url={result.cli_object_url}"
51
+ )
52
+
53
+
54
+ @cli.command("get")
55
+ @click.option("--id", "artifact_id", required=True, help="CliArtifact id")
56
+ @click.option("--version", "artifact_version", type=int, default=None, help="Version (default: latest)")
57
+ @click.option(
58
+ "--output-dir",
59
+ required=True,
60
+ type=click.Path(file_okay=False, dir_okay=True, path_type=Path),
61
+ help="Local directory to download the CLI into",
62
+ )
63
+ def cli_get(artifact_id: str, artifact_version: Optional[int], output_dir: Path):
64
+ """Download a CliArtifact's files to a local directory."""
65
+
66
+ click.echo(f"Fetching CliArtifact: id={artifact_id} version={artifact_version or 'latest'}...")
67
+ cli_artifact = CliArtifact.get(artifact_id, artifact_version)
68
+ click.echo(
69
+ f"Found: id={cli_artifact.id} version={cli_artifact.version} "
70
+ f"command_name={cli_artifact.command_name} entrypoint={cli_artifact.entrypoint}"
71
+ )
72
+
73
+ output_dir.mkdir(parents=True, exist_ok=True)
74
+ file_artifacts = cli_artifact.get_cli_files().get_file_artifacts()
75
+ click.echo(f"Downloading {len(file_artifacts)} file(s)...")
76
+ for rel_path, fa in file_artifacts.items():
77
+ dest = output_dir / rel_path
78
+ dest.parent.mkdir(parents=True, exist_ok=True)
79
+ dest.write_bytes(fa.load())
80
+ click.echo(f" {rel_path} -> {dest}")
81
+
82
+ click.echo(f"Done. Files written to {output_dir}")
83
+ click.echo(f"Entrypoint: {output_dir / cli_artifact.entrypoint}")
@@ -0,0 +1,44 @@
1
+ from pathlib import Path
2
+
3
+ import click
4
+
5
+ from agent_env.artifact import FileArtifact, EnvironmentArtifact
6
+ from agent_env.cli.utils import environment_name_options, resolve_environment_name
7
+
8
+
9
+ @click.group(name="environment")
10
+ def environment():
11
+ """EnvironmentArtifact commands."""
12
+ pass
13
+
14
+
15
+ @environment.command()
16
+ @click.argument("filepath", type=click.Path(exists=True, dir_okay=False, path_type=Path))
17
+ @click.option("--id", "artifact_id", required=True, help="EnvironmentArtifact id")
18
+ @click.option("--description", required=True, help="Artifact description")
19
+ @environment_name_options
20
+ def put(artifact_id: str, description: str, environment_name: str | None, filepath: Path):
21
+ """Create an EnvironmentArtifact (and underlying FileArtifact) from a local file."""
22
+ environment_name = resolve_environment_name(environment_name)
23
+
24
+ click.echo("Creating FileArtifact...")
25
+ file_artifact = FileArtifact.put(
26
+ id=f"{artifact_id}-file",
27
+ description=description,
28
+ file_path=str(filepath),
29
+ )
30
+ click.echo(
31
+ f"Created FileArtifact: id={file_artifact.id} version={file_artifact.version} filename={file_artifact.filename}"
32
+ )
33
+
34
+ click.echo("Creating EnvironmentArtifact...")
35
+ environment_artifact = EnvironmentArtifact.put(
36
+ id=artifact_id,
37
+ environment_name=environment_name,
38
+ file_artifact=file_artifact,
39
+ )
40
+ click.echo(
41
+ f"Created EnvironmentArtifact: id={environment_artifact.id} version={environment_artifact.version} "
42
+ f"environment_name={environment_artifact.environment_name}"
43
+ )
44
+ click.echo(f" pinned FileArtifact: {environment_artifact.file_artifact_ref}")
@@ -0,0 +1,163 @@
1
+ from pathlib import Path
2
+ from typing import Optional, Tuple
3
+
4
+ import click
5
+
6
+ from agent_env.artifact import FileArtifact, EnvironmentArtifact, EnvironmentUniverseArtifact
7
+ from agent_env.cli.utils import parse_artifact_ref
8
+
9
+
10
+ # ---------------------------------------------------------------------------
11
+ # EnvironmentUniverseArtifact
12
+ # agent-env artifact environment-universe put --id scenario_001 --environment-artifact slack-data --environment-artifact email-data
13
+ # ---------------------------------------------------------------------------
14
+
15
+ @click.group(name="environment-universe")
16
+ def environment_universe():
17
+ """EnvironmentUniverseArtifact commands."""
18
+ pass
19
+
20
+
21
+ @environment_universe.command("put")
22
+ @click.option("--id", "artifact_id", required=True, help="EnvironmentUniverseArtifact id")
23
+ @click.option(
24
+ "--environment-artifact",
25
+ "environment_artifacts",
26
+ multiple=True,
27
+ required=True,
28
+ help="EnvironmentArtifact id[:version] (repeatable). Omit :version to pin to current latest.",
29
+ )
30
+ @click.option(
31
+ "--metadata",
32
+ "metadata_entries",
33
+ multiple=True,
34
+ help="Metadata entry as key=/path/to/file (repeatable)",
35
+ )
36
+ def environment_universe_put(
37
+ artifact_id: str,
38
+ environment_artifacts: Tuple[str, ...],
39
+ metadata_entries: Tuple[str, ...],
40
+ ):
41
+ """Create an EnvironmentUniverseArtifact bundling existing EnvironmentArtifacts."""
42
+
43
+ resolved = []
44
+ for ref in environment_artifacts:
45
+ sa_id, sa_version = parse_artifact_ref(ref)
46
+ click.echo(f"Fetching EnvironmentArtifact: id={sa_id} version={sa_version or 'latest'}...")
47
+ sa = EnvironmentArtifact.get(sa_id, version=sa_version)
48
+ click.echo(f" Found: id={sa.id} version={sa.version}")
49
+ resolved.append(sa)
50
+
51
+ metadata = None
52
+ if metadata_entries:
53
+ keys = [entry.split("=", 1)[0] for entry in metadata_entries if "=" in entry]
54
+ if len(keys) != len(set(keys)):
55
+ click.echo("Error: duplicate keys in --metadata entries", err=True)
56
+ raise SystemExit(1)
57
+ metadata = {}
58
+ for entry in metadata_entries:
59
+ if "=" not in entry:
60
+ click.echo(f"Error: --metadata value must be key=/path/to/file, got '{entry}'", err=True)
61
+ raise SystemExit(1)
62
+ key, file_path = entry.split("=", 1)
63
+ p = Path(file_path)
64
+ if not p.is_file():
65
+ click.echo(f"Error: metadata file not found: {file_path}", err=True)
66
+ raise SystemExit(1)
67
+ fa_id = f"{artifact_id}-metadata-{key}"
68
+ click.echo(f"Creating metadata FileArtifact: key={key} file={file_path}...")
69
+ fa = FileArtifact.put(
70
+ id=fa_id,
71
+ description=f"Metadata '{key}' for EnvironmentUniverseArtifact '{artifact_id}'",
72
+ file_path=str(p),
73
+ )
74
+ metadata[key] = fa
75
+ click.echo(f" Created FileArtifact: id={fa.id} version={fa.version} filename={fa.filename}")
76
+
77
+ click.echo("Creating EnvironmentUniverseArtifact...")
78
+ result = EnvironmentUniverseArtifact.put(
79
+ id=artifact_id,
80
+ environment_artifacts=resolved,
81
+ metadata=metadata,
82
+ )
83
+ refs_summary = [str(r) for r in result.environment_artifact_refs]
84
+ md_summary = (
85
+ {k: str(r) for k, r in result.metadata_refs.items()}
86
+ if result.metadata_refs
87
+ else None
88
+ )
89
+ click.echo(
90
+ f"Created EnvironmentUniverseArtifact: id={result.id} version={result.version} "
91
+ f"environment_artifacts={refs_summary} metadata={md_summary}"
92
+ )
93
+
94
+
95
+ @environment_universe.command("get")
96
+ @click.option("--id", "artifact_id", required=True, help="EnvironmentUniverseArtifact id")
97
+ @click.option("--version", "artifact_version", type=int, default=None, help="Version (default: latest)")
98
+ @click.option("--output-dir", required=True, type=click.Path(), help="Local directory to download files into")
99
+ def environment_universe_get(
100
+ artifact_id: str,
101
+ artifact_version: Optional[int],
102
+ output_dir: str,
103
+ ):
104
+ """Download an EnvironmentUniverseArtifact's files to a local directory."""
105
+
106
+ click.echo(f"Fetching EnvironmentUniverseArtifact: id={artifact_id} version={artifact_version or 'latest'}...")
107
+ universe = EnvironmentUniverseArtifact.get(artifact_id, artifact_version)
108
+ if universe.environment_artifact_refs:
109
+ children = [str(r) for r in universe.environment_artifact_refs]
110
+ else:
111
+ children = universe.legacy_environment_artifact_ids or []
112
+ if universe.metadata_refs:
113
+ md = {k: str(r) for k, r in universe.metadata_refs.items()}
114
+ else:
115
+ md = universe.legacy_metadata
116
+ click.echo(
117
+ f"Found: id={universe.id} version={universe.version} "
118
+ f"environment_artifacts={children} metadata={md}"
119
+ )
120
+
121
+ out = Path(output_dir)
122
+ out.mkdir(parents=True, exist_ok=True)
123
+
124
+ environment_artifacts = universe.get_environment_artifacts()
125
+ click.echo(f"Downloading {len(environment_artifacts)} environment artifact(s)...")
126
+ for sa in environment_artifacts:
127
+ file_artifact = sa.get_file_artifact()
128
+ data = file_artifact.load()
129
+ sa_dir = out / sa.environment_name
130
+ sa_dir.mkdir(parents=True, exist_ok=True)
131
+ dest = sa_dir / file_artifact.filename
132
+ dest.write_bytes(data)
133
+ click.echo(f" {sa.environment_name} -> {dest}")
134
+
135
+ metadata_artifacts = universe.get_metadata()
136
+ if metadata_artifacts:
137
+ click.echo(f"Downloading {len(metadata_artifacts)} metadata file(s)...")
138
+ for key, file_artifact in metadata_artifacts.items():
139
+ data = file_artifact.load()
140
+ metadata_dir = out / "metadata" / key
141
+ metadata_dir.mkdir(parents=True, exist_ok=True)
142
+ dest = metadata_dir / file_artifact.filename
143
+ dest.write_bytes(data)
144
+ click.echo(f" {key} -> {dest}")
145
+
146
+ click.echo(f"Done. Files written to {out}")
147
+
148
+
149
+ @environment_universe.command("compatible-envs")
150
+ @click.option("--id", "artifact_id", required=True, help="EnvironmentUniverseArtifact id")
151
+ def compatible_envs(artifact_id: str):
152
+ """List env compatibility results for a universe."""
153
+ from agent_env.env.env_artifact_store import get_env_artifact_store
154
+
155
+ from agent_env.env.env_artifact_store import EnvArtifactType
156
+ results = get_env_artifact_store().get_by_artifact(artifact_id, type=EnvArtifactType.UNIVERSE_COMPATIBILITY)
157
+ if not results:
158
+ click.echo(f"No compatibility results found for universe {artifact_id}")
159
+ return
160
+ for r in results:
161
+ compat = r["data"].get("compatible", False)
162
+ status = click.style("COMPATIBLE", fg="green") if compat else click.style("INCOMPATIBLE", fg="magenta")
163
+ click.echo(f" env={r['env_id']} v{r['env_version']}: {status}")