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.
- agent_env/__init__.py +0 -0
- agent_env/a2a_agent/__init__.py +23 -0
- agent_env/a2a_agent/a2a_agent.py +600 -0
- agent_env/a2a_agent/conversation_store.py +356 -0
- agent_env/a2a_agent/object_transfer.py +609 -0
- agent_env/a2a_agent/protocol.py +238 -0
- agent_env/a2a_agent/store.py +201 -0
- agent_env/a2a_agent/validator.py +901 -0
- agent_env/artifact/__init__.py +48 -0
- agent_env/artifact/artifact.py +74 -0
- agent_env/artifact/artifacts/__init__.py +0 -0
- agent_env/artifact/artifacts/cli.py +83 -0
- agent_env/artifact/artifacts/docker_image.py +457 -0
- agent_env/artifact/artifacts/environment.py +89 -0
- agent_env/artifact/artifacts/environment_universe.py +156 -0
- agent_env/artifact/artifacts/file.py +214 -0
- agent_env/artifact/artifacts/file_artifact_universe.py +206 -0
- agent_env/artifact/artifacts/skill.py +206 -0
- agent_env/artifact/artifacts/vm_image.py +95 -0
- agent_env/artifact/ref.py +15 -0
- agent_env/artifact/registry.py +251 -0
- agent_env/artifact/store.py +295 -0
- agent_env/artifact/universe.py +38 -0
- agent_env/attribution.py +41 -0
- agent_env/bundle/__init__.py +4 -0
- agent_env/bundle/_fs.py +128 -0
- agent_env/bundle/authoring.py +239 -0
- agent_env/bundle/installed.py +175 -0
- agent_env/bundle/ledger.py +269 -0
- agent_env/bundle/materialize.py +204 -0
- agent_env/bundle/parse.py +594 -0
- agent_env/bundle/plan.py +414 -0
- agent_env/bundle/resolve.py +404 -0
- agent_env/bundle/run.py +361 -0
- agent_env/cli/__init__.py +69 -0
- agent_env/cli/__main__.py +10 -0
- agent_env/cli/_installers.py +576 -0
- agent_env/cli/_plugin_changes.py +947 -0
- agent_env/cli/a2a_agent/__init__.py +22 -0
- agent_env/cli/a2a_agent/add_skill.py +97 -0
- agent_env/cli/a2a_agent/deploy.py +60 -0
- agent_env/cli/a2a_agent/get.py +15 -0
- agent_env/cli/a2a_agent/get_instance.py +26 -0
- agent_env/cli/a2a_agent/put.py +78 -0
- agent_env/cli/a2a_agent/validate.py +56 -0
- agent_env/cli/artifact/__init__.py +20 -0
- agent_env/cli/artifact/cli.py +83 -0
- agent_env/cli/artifact/environment.py +44 -0
- agent_env/cli/artifact/environment_universe.py +163 -0
- agent_env/cli/artifact/file_artifact_universe.py +281 -0
- agent_env/cli/artifact/skill.py +128 -0
- agent_env/cli/banner.py +25 -0
- agent_env/cli/config.py +263 -0
- agent_env/cli/env/__init__.py +31 -0
- agent_env/cli/env/deploy.py +112 -0
- agent_env/cli/env/gateway.py +57 -0
- agent_env/cli/env/get_instance.py +40 -0
- agent_env/cli/env/mcp_server.py +410 -0
- agent_env/cli/env/multi.py +282 -0
- agent_env/cli/env/service_db.py +99 -0
- agent_env/cli/env/snapshot.py +35 -0
- agent_env/cli/env/state/__init__.py +6 -0
- agent_env/cli/env/state/init.py +108 -0
- agent_env/cli/env/state/teardown.py +44 -0
- agent_env/cli/env/website.py +216 -0
- agent_env/cli/env/website_browser.py +67 -0
- agent_env/cli/eval/__init__.py +16 -0
- agent_env/cli/eval/add_tasks.py +63 -0
- agent_env/cli/eval/create.py +49 -0
- agent_env/cli/eval/run.py +194 -0
- agent_env/cli/identity/__init__.py +5 -0
- agent_env/cli/identity/client_identity.py +37 -0
- agent_env/cli/plugin.py +438 -0
- agent_env/cli/run.py +285 -0
- agent_env/cli/task/__init__.py +21 -0
- agent_env/cli/task/create.py +109 -0
- agent_env/cli/task/get.py +17 -0
- agent_env/cli/task/get_instance.py +34 -0
- agent_env/cli/task/run.py +615 -0
- agent_env/cli/task/validate.py +31 -0
- agent_env/cli/up.py +123 -0
- agent_env/cli/utils.py +183 -0
- agent_env/config/__init__.py +50 -0
- agent_env/config/describe.py +1067 -0
- agent_env/config/errors.py +13 -0
- agent_env/config/loader.py +245 -0
- agent_env/config/model.py +154 -0
- agent_env/config/paths.py +25 -0
- agent_env/config/plugin_tables.py +101 -0
- agent_env/config/provenance.py +134 -0
- agent_env/config/runtime.py +1064 -0
- agent_env/config/snapshot.py +81 -0
- agent_env/entity_refs.py +186 -0
- agent_env/env/__init__.py +49 -0
- agent_env/env/env.py +433 -0
- agent_env/env/env_artifact_store.py +87 -0
- agent_env/env/envs/__init__.py +7 -0
- agent_env/env/envs/_deployment.py +281 -0
- agent_env/env/envs/gateway_server.py +32 -0
- agent_env/env/envs/mcp_server.py +387 -0
- agent_env/env/envs/multi_env.py +780 -0
- agent_env/env/envs/service_db/Dockerfile +20 -0
- agent_env/env/envs/service_db/Dockerfile.db-mcp +42 -0
- agent_env/env/envs/service_db/Dockerfile.db-web +8 -0
- agent_env/env/envs/service_db.py +92 -0
- agent_env/env/envs/website.py +294 -0
- agent_env/env/envs/website_browser/Dockerfile +40 -0
- agent_env/env/envs/website_browser/__init__.py +17 -0
- agent_env/env/envs/website_browser/entrypoint.sh +13 -0
- agent_env/env/gateway/Dockerfile +14 -0
- agent_env/env/gateway/__init__.py +37 -0
- agent_env/env/gateway/clock.py +184 -0
- agent_env/env/gateway/constants.py +190 -0
- agent_env/env/gateway/entrypoint.py +156 -0
- agent_env/env/gateway/gateway.py +1095 -0
- agent_env/env/gateway/get_time.py +60 -0
- agent_env/env/gateway/requirements.txt +4 -0
- agent_env/env/gateway/triggers.py +1193 -0
- agent_env/env/legacy_protocol.py +146 -0
- agent_env/env/registry.py +93 -0
- agent_env/env/snapshot_store.py +372 -0
- agent_env/env/store.py +411 -0
- agent_env/eval/__init__.py +14 -0
- agent_env/eval/eval.py +68 -0
- agent_env/eval/store.py +116 -0
- agent_env/examples/hello/README.md +9 -0
- agent_env/examples/hello/artifacts/greeting/check.sh +1 -0
- agent_env/examples/hello/artifacts/greeting/hello.txt +1 -0
- agent_env/examples/hello/tasks/hello.json +10 -0
- agent_env/explorer/__init__.py +12 -0
- agent_env/explorer/app.py +277 -0
- agent_env/explorer/openapi_docs.py +242 -0
- agent_env/explorer/plugin.py +95 -0
- agent_env/explorer/routers/__init__.py +1 -0
- agent_env/explorer/routers/common.py +174 -0
- agent_env/explorer/routers/conversations.py +25 -0
- agent_env/explorer/routers/objects.py +112 -0
- agent_env/explorer/routers/runs.py +475 -0
- agent_env/plugins/__init__.py +59 -0
- agent_env/plugins/_cli.py +244 -0
- agent_env/plugins/_discovery.py +97 -0
- agent_env/plugins/_inventory.py +262 -0
- agent_env/plugins/_registration.py +268 -0
- agent_env/plugins/_report.py +47 -0
- agent_env/plugins/_requirements.py +55 -0
- agent_env/providers/__init__.py +37 -0
- agent_env/providers/env_providers/__init__.py +12 -0
- agent_env/providers/env_providers/constants.py +13 -0
- agent_env/providers/env_providers/env_gateway_provider.py +1354 -0
- agent_env/providers/env_providers/env_provider.py +237 -0
- agent_env/providers/env_providers/env_server_provider.py +133 -0
- agent_env/providers/env_state/__init__.py +49 -0
- agent_env/providers/env_state/env_state_provider.py +554 -0
- agent_env/providers/env_state/local_postgres.py +390 -0
- agent_env/providers/env_state/store.py +112 -0
- agent_env/providers/sandbox_providers/__init__.py +29 -0
- agent_env/providers/sandbox_providers/chained_sandbox_provider.py +93 -0
- agent_env/providers/sandbox_providers/e2b/__init__.py +6 -0
- agent_env/providers/sandbox_providers/e2b/provider.py +376 -0
- agent_env/providers/sandbox_providers/e2b/sandbox.py +342 -0
- agent_env/providers/sandbox_providers/e2b/template.py +158 -0
- agent_env/providers/sandbox_providers/local_sandbox.py +408 -0
- agent_env/providers/sandbox_providers/modal_sandbox.py +500 -0
- agent_env/providers/sandbox_providers/modal_vm_sandbox.py +466 -0
- agent_env/providers/sandbox_providers/sandbox.py +387 -0
- agent_env/providers/sandbox_providers/sandbox_provider.py +614 -0
- agent_env/py.typed +0 -0
- agent_env/runner/__init__.py +16 -0
- agent_env/runner/local_runner.py +190 -0
- agent_env/runner/runner.py +127 -0
- agent_env/runner/store.py +94 -0
- agent_env/store/__init__.py +126 -0
- agent_env/store/_google.py +68 -0
- agent_env/store/base.py +33 -0
- agent_env/store/document_store/__init__.py +60 -0
- agent_env/store/document_store/document_store.py +519 -0
- agent_env/store/document_store/dynamodb_document_store.py +306 -0
- agent_env/store/document_store/evaluation.py +199 -0
- agent_env/store/document_store/firestore_mongo_document_store.py +242 -0
- agent_env/store/document_store/mongo_document_store.py +259 -0
- agent_env/store/document_store/sqlite_document_store.py +314 -0
- agent_env/store/ids.py +123 -0
- agent_env/store/image_store/__init__.py +34 -0
- agent_env/store/image_store/ecr_image_store.py +131 -0
- agent_env/store/image_store/google_credentials.py +113 -0
- agent_env/store/image_store/image_store.py +113 -0
- agent_env/store/image_store/local_registry_image_store.py +106 -0
- agent_env/store/image_store/oci_registry_credentials.py +196 -0
- agent_env/store/local_state.py +27 -0
- agent_env/store/object_store/__init__.py +24 -0
- agent_env/store/object_store/gcs_object_store.py +415 -0
- agent_env/store/object_store/local_object_store.py +143 -0
- agent_env/store/object_store/object_store.py +198 -0
- agent_env/store/object_store/s3_object_store.py +354 -0
- agent_env/store/query.py +112 -0
- agent_env/store/routing.py +609 -0
- agent_env/store/secret_store/__init__.py +19 -0
- agent_env/store/secret_store/aws_secrets_manager_secret_store.py +293 -0
- agent_env/store/secret_store/gcp_secret_manager_secret_store.py +319 -0
- agent_env/store/secret_store/local_secret_store.py +47 -0
- agent_env/store/secret_store/secret_store.py +19 -0
- agent_env/task/__init__.py +27 -0
- agent_env/task/interrupts.py +109 -0
- agent_env/task/registry.py +27 -0
- agent_env/task/step_journal.py +99 -0
- agent_env/task/store.py +940 -0
- agent_env/task/task.py +815 -0
- agent_env/task/teardown.py +142 -0
- agent_env/task_step/__init__.py +47 -0
- agent_env/task_step/context.py +195 -0
- agent_env/task_step/context_ops.py +224 -0
- agent_env/task_step/registry.py +182 -0
- agent_env/task_step/review_store.py +118 -0
- agent_env/task_step/snapshot_utils/__init__.py +2 -0
- agent_env/task_step/snapshot_utils/agent_state_capture.py +261 -0
- agent_env/task_step/snapshot_utils/snapshot_series.py +631 -0
- agent_env/task_step/store.py +129 -0
- agent_env/task_step/task_step.py +173 -0
- agent_env/task_step/task_steps/__init__.py +27 -0
- agent_env/task_step/task_steps/a2a_agent_validator/__init__.py +31 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/README.md +158 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.m4a +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.mp3 +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.mp4 +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.ogg +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/clip.wav +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/document.pdf +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.gif +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.jpg +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/fixtures/red.png +0 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_card.py +103 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_config_identity.py +69 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_agent_mcp.py +178 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_core_protocol.py +67 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_install.py +115 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_litellm_attribution.py +124 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_litellm_attribution_runtime.py +173 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_modalities.py +270 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_peer_agents.py +102 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_role.py +151 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_skill_config.py +194 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_snapshot.py +111 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_system_prompt.py +215 -0
- agent_env/task_step/task_steps/a2a_agent_validator/verify_a2a_trajectory.py +164 -0
- agent_env/task_step/task_steps/add_skills.py +240 -0
- agent_env/task_step/task_steps/apply_server_config.py +288 -0
- agent_env/task_step/task_steps/collect_artifacts.py +940 -0
- agent_env/task_step/task_steps/deploy_agent.py +626 -0
- agent_env/task_step/task_steps/deploy_env.py +197 -0
- agent_env/task_step/task_steps/deploy_human_agent.py +100 -0
- agent_env/task_step/task_steps/deploy_sandbox.py +170 -0
- agent_env/task_step/task_steps/env_card_validator/__init__.py +4 -0
- agent_env/task_step/task_steps/env_card_validator/verify_env_card.py +109 -0
- agent_env/task_step/task_steps/env_card_validator/verify_env_core_protocol.py +108 -0
- agent_env/task_step/task_steps/install_agent.py +376 -0
- agent_env/task_step/task_steps/load_artifact.py +775 -0
- agent_env/task_step/task_steps/mcp_cli_builder/__init__.py +4 -0
- agent_env/task_step/task_steps/mcp_cli_builder/build_mcp_cli.py +201 -0
- agent_env/task_step/task_steps/mcp_cli_builder/codegen.py +627 -0
- agent_env/task_step/task_steps/mcp_env_validator/__init__.py +44 -0
- agent_env/task_step/task_steps/mcp_env_validator/validation_gate_aggregator.py +102 -0
- agent_env/task_step/task_steps/mcp_env_validator/verify_mcp_env_assessment.py +78 -0
- agent_env/task_step/task_steps/mcp_env_validator/verify_mcp_tool_schema.py +152 -0
- agent_env/task_step/task_steps/mcp_env_validator/verify_spec_conformance.py +486 -0
- agent_env/task_step/task_steps/modify_env_tool_access.py +80 -0
- agent_env/task_step/task_steps/multienv_validator/__init__.py +3 -0
- agent_env/task_step/task_steps/multienv_validator/combine_universe_verdicts.py +107 -0
- agent_env/task_step/task_steps/multienv_validator/universe_comparison.py +253 -0
- agent_env/task_step/task_steps/multienv_validator/verify_universe_agent_judge.py +180 -0
- agent_env/task_step/task_steps/multienv_validator/verify_universe_roundtrip.py +241 -0
- agent_env/task_step/task_steps/peer_agents.py +92 -0
- agent_env/task_step/task_steps/prompt_agent.py +900 -0
- agent_env/task_step/task_steps/register_agent_triggers.py +113 -0
- agent_env/task_step/task_steps/register_env_triggers.py +97 -0
- agent_env/task_step/task_steps/reset_env.py +71 -0
- agent_env/task_step/task_steps/review.py +152 -0
- agent_env/task_step/task_steps/run_code.py +461 -0
- agent_env/task_step/task_steps/run_code_runner.py +52 -0
- agent_env/task_step/task_steps/run_docker_container.py +380 -0
- agent_env/task_step/task_steps/sandbox_utils/__init__.py +0 -0
- agent_env/task_step/task_steps/sandbox_utils/sandbox_utils.py +79 -0
- agent_env/task_step/task_steps/snapshot_agent_state.py +205 -0
- agent_env/task_step/task_steps/snapshot_env.py +637 -0
- agent_env/task_step/task_steps/sync_env_clock.py +132 -0
- agent_env/task_step/task_steps/teardown_sandboxes.py +170 -0
- agent_env/task_step/task_steps/verifiers/__init__.py +23 -0
- agent_env/task_step/task_steps/verifiers/agent_prompt_response_verifier.py +166 -0
- agent_env/task_step/task_steps/verifiers/aggregate_verifiers.py +90 -0
- agent_env/task_step/task_steps/verifiers/env_outcome_verifier.py +127 -0
- agent_env/task_step/task_steps/verifiers/judge_utils/__init__.py +2 -0
- agent_env/task_step/task_steps/verifiers/judge_utils/frame_selection.py +377 -0
- agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py +1293 -0
- agent_env/task_step/task_steps/verifiers/judge_utils/trajectory_filter.py +514 -0
- agent_env/task_step/task_steps/verifiers/rubrics_verifier.py +1318 -0
- agent_env/task_step/task_steps/verifiers/run_container_unit_tests_verifier.py +434 -0
- agent_env/task_step/task_steps/verifiers/scoring.py +40 -0
- agent_env/task_step/task_steps/verifiers/verify_sandbox.py +308 -0
- agent_env/task_step/thread_work.py +61 -0
- agent_env/utils/__init__.py +0 -0
- agent_env/utils/card_naming.py +108 -0
- agent_env/utils/deprecation.py +109 -0
- agent_env/utils/docker_build.py +29 -0
- agent_env/utils/exec_retry.py +77 -0
- agent_env/utils/litellm_attribution.py +59 -0
- agent_env/utils/paths.py +20 -0
- agentenv_framework-0.9.1254.dist-info/METADATA +394 -0
- agentenv_framework-0.9.1254.dist-info/RECORD +312 -0
- agentenv_framework-0.9.1254.dist-info/WHEEL +4 -0
- agentenv_framework-0.9.1254.dist-info/entry_points.txt +5 -0
- agentenv_framework-0.9.1254.dist-info/licenses/LICENSE +202 -0
- agentenv_framework-0.9.1254.dist-info/licenses/NOTICE +4 -0
- agentenv_framework-0.9.1254.dist-info/licenses/THIRD_PARTY_NOTICES.md +7665 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
|
|
8
|
+
from agent_env.artifact import DockerImageArtifact, EnvironmentArtifact
|
|
9
|
+
from agent_env.cli.utils import (
|
|
10
|
+
deployed_env_from_instance,
|
|
11
|
+
build_platform_option,
|
|
12
|
+
detect_env_metadata,
|
|
13
|
+
env_provider_type_option,
|
|
14
|
+
environment_name_options,
|
|
15
|
+
resolve_environment_name,
|
|
16
|
+
skips_local_validation,
|
|
17
|
+
)
|
|
18
|
+
from agent_env.utils.card_naming import card_name_from_github, card_name_from_source
|
|
19
|
+
from agent_env.utils.docker_build import DEFAULT_BUILD_PLATFORM, build_image
|
|
20
|
+
from agent_env.env import Env, MCPServerEnv
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@click.group(name="mcp-server")
|
|
24
|
+
def mcp_server():
|
|
25
|
+
"""MCP server environment commands."""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _read_validation_report(search_dirs) -> dict | None:
|
|
30
|
+
"""Load ``validation_report.json`` (the env-build → put handoff) from the first of
|
|
31
|
+
``search_dirs`` that has one; None if absent/unreadable."""
|
|
32
|
+
import json
|
|
33
|
+
|
|
34
|
+
for d in search_dirs:
|
|
35
|
+
if not d:
|
|
36
|
+
continue
|
|
37
|
+
p = Path(d) / "validation_report.json"
|
|
38
|
+
if p.is_file():
|
|
39
|
+
try:
|
|
40
|
+
return json.loads(p.read_text())
|
|
41
|
+
except (OSError, json.JSONDecodeError):
|
|
42
|
+
return None
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _decide_release(validation_gate: dict | None, unit_tests: dict | None, override: bool) -> dict:
|
|
47
|
+
"""Decide release from the gate verdict + unit-test verdict. Blocks on any live-server
|
|
48
|
+
gate that failed or did not run; unit tests block only when present and failed (a
|
|
49
|
+
missing verdict is unknown, not a block). ``override`` turns a block into an audited
|
|
50
|
+
publish. Returns ``{promote, blocked, reasons, overridden}``.
|
|
51
|
+
"""
|
|
52
|
+
reasons: list[str] = []
|
|
53
|
+
if validation_gate is None:
|
|
54
|
+
reasons.append("live-server validation gate did not run")
|
|
55
|
+
elif not validation_gate.get("passed", False):
|
|
56
|
+
failed = validation_gate.get("failed_gates", [])
|
|
57
|
+
missing = validation_gate.get("missing_gates", [])
|
|
58
|
+
if failed:
|
|
59
|
+
reasons.append(f"failed gates: {', '.join(failed)}")
|
|
60
|
+
if missing:
|
|
61
|
+
reasons.append(f"gates that did not run: {', '.join(missing)}")
|
|
62
|
+
if not failed and not missing:
|
|
63
|
+
reasons.append("validation gate did not pass")
|
|
64
|
+
if unit_tests is not None and not unit_tests.get("passed", False):
|
|
65
|
+
reasons.append("unit tests failed")
|
|
66
|
+
|
|
67
|
+
blocked = bool(reasons)
|
|
68
|
+
if blocked and override:
|
|
69
|
+
return {"promote": True, "blocked": True, "reasons": reasons, "overridden": True}
|
|
70
|
+
return {"promote": not blocked, "blocked": blocked, "reasons": reasons, "overridden": False}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _gate_release(env, report_dirs, override: bool) -> None:
|
|
74
|
+
"""Gate a freshly-put env: validate, read the gate + unit-test verdicts, stamp a
|
|
75
|
+
durable ``release_gate`` on the env, and exit non-zero if blocked (unless
|
|
76
|
+
``--override``). The single publish-enforcement point.
|
|
77
|
+
"""
|
|
78
|
+
click.echo("\nValidating environment...")
|
|
79
|
+
instance_id = asyncio.run(env.validate(on_progress=click.echo))
|
|
80
|
+
click.echo(f"Validation task: {instance_id}")
|
|
81
|
+
|
|
82
|
+
fresh = Env.get(env.id, env.version)
|
|
83
|
+
validation_gate = fresh.metadata.get("validation_gate")
|
|
84
|
+
report = _read_validation_report(report_dirs)
|
|
85
|
+
unit_tests = report.get("unit_tests") if report else None
|
|
86
|
+
|
|
87
|
+
decision = _decide_release(validation_gate, unit_tests, override)
|
|
88
|
+
try:
|
|
89
|
+
fresh.update_metadata({**fresh.metadata, "release_gate": {
|
|
90
|
+
"passed": not decision["blocked"],
|
|
91
|
+
"overridden": decision["overridden"],
|
|
92
|
+
"reasons": decision["reasons"],
|
|
93
|
+
}})
|
|
94
|
+
except Exception as e: # best-effort audit stamp
|
|
95
|
+
click.echo(f"Warning: could not stamp release_gate on env: {e}", err=True)
|
|
96
|
+
|
|
97
|
+
if decision["blocked"] and not decision["overridden"]:
|
|
98
|
+
click.secho(f"\nRelease gate FAILED: {'; '.join(decision['reasons'])}", fg="red", err=True)
|
|
99
|
+
click.echo("Re-run with --override to publish anyway.", err=True)
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
if decision["overridden"]:
|
|
102
|
+
click.secho(f"\nRelease gate OVERRIDDEN ({'; '.join(decision['reasons'])}); publishing anyway.", fg="yellow")
|
|
103
|
+
else:
|
|
104
|
+
click.secho("\nRelease gate PASSED.", fg="green")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@mcp_server.command()
|
|
108
|
+
@click.option("--id", "env_id", required=True, help="Env id")
|
|
109
|
+
@click.option("--dockerfile", default=None, type=click.Path(exists=True), help="Path to local Dockerfile")
|
|
110
|
+
@click.option("--context", "context_path", default=None, type=click.Path(exists=True), help="Docker build context (defaults to Dockerfile's directory)")
|
|
111
|
+
@click.option("--dockerfile-github-url", "dockerfile_github_url", default=None, help="GitHub URL to Dockerfile (e.g. https://github.com/owner/repo/tree/main/path/Dockerfile)")
|
|
112
|
+
@click.option("--docker-context-github-url", "docker_context_github_url", default=None, help="GitHub URL to build context directory (defaults to Dockerfile's parent)")
|
|
113
|
+
@environment_name_options
|
|
114
|
+
@env_provider_type_option("What deploys the env: 'gateway' (a gateway and service database in front of the server), 'server' (the "
|
|
115
|
+
"server on its own), or the type of an installed agent_env.env_providers plugin")
|
|
116
|
+
@click.option("--metadata", "metadata_pairs", multiple=True, help="Metadata key=value pair (repeatable)")
|
|
117
|
+
@click.option("--validate", "run_validation", is_flag=True, default=False,
|
|
118
|
+
help="Run the release gate after registering: validate the env and exit non-zero if it fails")
|
|
119
|
+
@click.option("--override", "override", is_flag=True, default=False,
|
|
120
|
+
help="Run the release gate but publish even if it fails (records an audited override); implies --validate")
|
|
121
|
+
@build_platform_option
|
|
122
|
+
def put(env_id: str, dockerfile: str | None, context_path: str | None, dockerfile_github_url: str | None, docker_context_github_url: str | None, environment_name: str | None, env_provider_type: str, metadata_pairs: tuple[str, ...], run_validation: bool, override: bool, build_platform: str):
|
|
123
|
+
"""Build and upload an MCP server environment."""
|
|
124
|
+
|
|
125
|
+
environment_name = resolve_environment_name(environment_name, allow_missing=True)
|
|
126
|
+
|
|
127
|
+
if dockerfile and dockerfile_github_url:
|
|
128
|
+
click.echo("Error: --dockerfile and --dockerfile-github-url are mutually exclusive", err=True)
|
|
129
|
+
sys.exit(1)
|
|
130
|
+
if not dockerfile and not dockerfile_github_url:
|
|
131
|
+
click.echo("Error: either --dockerfile or --dockerfile-github-url is required", err=True)
|
|
132
|
+
sys.exit(1)
|
|
133
|
+
if context_path and dockerfile_github_url:
|
|
134
|
+
click.echo("Error: --context cannot be used with --dockerfile-github-url", err=True)
|
|
135
|
+
sys.exit(1)
|
|
136
|
+
if docker_context_github_url and not dockerfile_github_url:
|
|
137
|
+
click.echo("Error: --docker-context-github-url requires --dockerfile-github-url", err=True)
|
|
138
|
+
sys.exit(1)
|
|
139
|
+
|
|
140
|
+
user_metadata = {}
|
|
141
|
+
for pair in metadata_pairs:
|
|
142
|
+
if "=" not in pair:
|
|
143
|
+
click.echo(f"Invalid metadata format '{pair}', expected key=value", err=True)
|
|
144
|
+
sys.exit(1)
|
|
145
|
+
key, value = pair.split("=", 1)
|
|
146
|
+
user_metadata[key] = value
|
|
147
|
+
|
|
148
|
+
if dockerfile_github_url:
|
|
149
|
+
if environment_name is None:
|
|
150
|
+
environment_name = card_name_from_github(dockerfile_github_url, docker_context_github_url, github_token=os.environ.get("GITHUB_TOKEN"))
|
|
151
|
+
if not environment_name:
|
|
152
|
+
click.echo("Error: could not read @environment_card(name=...) from the GitHub source; pass --environment-name.", err=True)
|
|
153
|
+
sys.exit(1)
|
|
154
|
+
click.echo(f"Derived environment_name={environment_name!r} from the environment card.")
|
|
155
|
+
if build_platform != DEFAULT_BUILD_PLATFORM:
|
|
156
|
+
click.echo(f"Warning: --platform {build_platform!r} is ignored for --dockerfile-github-url builds", err=True)
|
|
157
|
+
status = [""]
|
|
158
|
+
lines_printed = [0]
|
|
159
|
+
|
|
160
|
+
def _on_progress(step: str, message: str, percent: int) -> None:
|
|
161
|
+
if lines_printed[0] > 0:
|
|
162
|
+
click.echo("\033[1A", nl=False)
|
|
163
|
+
status[0] = f"[{percent:3d}%] {message}"
|
|
164
|
+
click.echo(f"\033[2K {click.style('MCP Server:', fg='cyan')} {status[0]}")
|
|
165
|
+
lines_printed[0] = 1
|
|
166
|
+
|
|
167
|
+
env = asyncio.run(MCPServerEnv.put_from_github(
|
|
168
|
+
id=env_id,
|
|
169
|
+
dockerfile_github_url=dockerfile_github_url,
|
|
170
|
+
docker_context_github_url=docker_context_github_url,
|
|
171
|
+
environment_name=environment_name,
|
|
172
|
+
env_provider_type=env_provider_type,
|
|
173
|
+
github_token=os.environ.get("GITHUB_TOKEN"),
|
|
174
|
+
metadata=user_metadata if user_metadata else None,
|
|
175
|
+
on_progress=_on_progress,
|
|
176
|
+
))
|
|
177
|
+
click.echo(f"Created MCPServerEnv: id={env.id} version={env.version} environment_name={env.environment_name} env_provider_type={env.env_provider_type}")
|
|
178
|
+
if (run_validation or override) and not skips_local_validation(env.id, "env"):
|
|
179
|
+
# GitHub-sourced build: validation_report.json lives in the repo, not
|
|
180
|
+
# locally, so the unit-test verdict is unknown here (doesn't block).
|
|
181
|
+
_gate_release(env, [], override)
|
|
182
|
+
return
|
|
183
|
+
|
|
184
|
+
dockerfile_path = Path(dockerfile)
|
|
185
|
+
context = Path(context_path) if context_path else dockerfile_path.parent
|
|
186
|
+
if environment_name is None:
|
|
187
|
+
environment_name = card_name_from_source(str(dockerfile_path), str(context))
|
|
188
|
+
if not environment_name:
|
|
189
|
+
click.echo("Error: no @environment_card(name=...) found in the build source; pass --environment-name.", err=True)
|
|
190
|
+
sys.exit(1)
|
|
191
|
+
click.echo(f"Derived environment_name={environment_name!r} from the environment card.")
|
|
192
|
+
image_tag = f"mcp-server-{env_id}"
|
|
193
|
+
|
|
194
|
+
click.echo(f"Building MCP server Docker image...")
|
|
195
|
+
build_image(dockerfile_path, context, image_tag, platform=build_platform)
|
|
196
|
+
|
|
197
|
+
click.echo(f"Creating DockerImageArtifact...")
|
|
198
|
+
artifact = DockerImageArtifact.put(
|
|
199
|
+
id=f"mcp-server-{env_id}",
|
|
200
|
+
description="Created from agent-env CLI",
|
|
201
|
+
image_name=image_tag,
|
|
202
|
+
build_context_path=str(context),
|
|
203
|
+
dockerfile_path=str(dockerfile_path),
|
|
204
|
+
)
|
|
205
|
+
click.echo(f"Created artifact: id={artifact.id} version={artifact.version}")
|
|
206
|
+
|
|
207
|
+
metadata = detect_env_metadata(dockerfile_path, context)
|
|
208
|
+
metadata.update(user_metadata)
|
|
209
|
+
|
|
210
|
+
click.echo(f"Creating MCPServerEnv...")
|
|
211
|
+
env = MCPServerEnv.put(
|
|
212
|
+
id=env_id,
|
|
213
|
+
docker_image_artifact=artifact,
|
|
214
|
+
environment_name=environment_name,
|
|
215
|
+
env_provider_type=env_provider_type,
|
|
216
|
+
metadata=metadata if metadata else None,
|
|
217
|
+
)
|
|
218
|
+
click.echo(f"Created MCPServerEnv: id={env.id} version={env.version} environment_name={env.environment_name} env_provider_type={env.env_provider_type}")
|
|
219
|
+
if (run_validation or override) and not skips_local_validation(env.id, "env"):
|
|
220
|
+
# Local build: look for the env-build handoff report next to the build context.
|
|
221
|
+
_gate_release(env, [str(context), str(dockerfile_path.parent)], override)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
_SPEC_FINDING_LIMIT = 20
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _echo_spec_conformance(spec: dict | None) -> None:
|
|
228
|
+
"""Print a ``mcp_spec_conformance`` verdict.
|
|
229
|
+
|
|
230
|
+
Findings are listed whenever there are any, not only when the verdict fails: the spec
|
|
231
|
+
is a floor, so a conformant server still reports its framework tools as informational
|
|
232
|
+
``extra_*`` findings, and keying the display off ``passed`` hid that drift entirely.
|
|
233
|
+
Blocking first, so the truncation drops noise rather than signal.
|
|
234
|
+
"""
|
|
235
|
+
click.secho("\nSpec conformance:", bold=True)
|
|
236
|
+
if not spec:
|
|
237
|
+
click.echo(" (did not run)")
|
|
238
|
+
return
|
|
239
|
+
if spec.get("skipped"):
|
|
240
|
+
click.secho(f" SKIPPED: {spec.get('reason', 'nothing to check')}", fg="yellow")
|
|
241
|
+
return
|
|
242
|
+
|
|
243
|
+
findings = spec.get("findings", [])
|
|
244
|
+
ops = spec.get("spec_operations", 0)
|
|
245
|
+
blocking = spec.get("blocking_findings", len(findings))
|
|
246
|
+
informational = len(findings) - blocking
|
|
247
|
+
|
|
248
|
+
if not findings:
|
|
249
|
+
click.secho(f" PASSED: {ops} spec operation(s) match the live tool surface", fg="green")
|
|
250
|
+
return
|
|
251
|
+
if blocking:
|
|
252
|
+
click.secho(f" {blocking} blocking finding(s), {informational} informational", fg="yellow")
|
|
253
|
+
else:
|
|
254
|
+
# Nothing blocks, so the gate passed — but the drift is still worth seeing.
|
|
255
|
+
click.secho(
|
|
256
|
+
f" PASSED: {ops} spec operation(s) match the live tool surface; "
|
|
257
|
+
f"{informational} informational finding(s)",
|
|
258
|
+
fg="green",
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
ordered = sorted(findings, key=lambda f: not f.get("blocking", True))
|
|
262
|
+
for f in ordered[:_SPEC_FINDING_LIMIT]:
|
|
263
|
+
loc = f.get("tool", "")
|
|
264
|
+
if f.get("param"):
|
|
265
|
+
loc = f"{loc}.{f['param']}"
|
|
266
|
+
click.echo(f" {f['kind']} {loc}: {f.get('detail', '')}")
|
|
267
|
+
if len(ordered) > _SPEC_FINDING_LIMIT:
|
|
268
|
+
click.echo(f" (+{len(ordered) - _SPEC_FINDING_LIMIT} more)")
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
@mcp_server.command(name="load-environment-artifact")
|
|
272
|
+
@click.option("--id", "env_id", default=None, help="MCPServerEnv id (optional; cross-checked against the instance)")
|
|
273
|
+
@click.option("--environment-artifact-id", "environment_artifact_id",
|
|
274
|
+
required=True, help="EnvironmentArtifact id")
|
|
275
|
+
@click.option("--instance-id", "instance_id", required=True,
|
|
276
|
+
help="Deployed env instance id, as printed by `env deploy`")
|
|
277
|
+
def load_environment_artifact(env_id: str | None, environment_artifact_id: str,
|
|
278
|
+
instance_id: str):
|
|
279
|
+
"""Load an environment artifact into a deployed MCP server environment."""
|
|
280
|
+
|
|
281
|
+
env = deployed_env_from_instance(env_id, instance_id)
|
|
282
|
+
click.echo(f"Found env: id={env.id} version={env.version} environment_name={env.environment_name}")
|
|
283
|
+
|
|
284
|
+
click.echo(f"Fetching environment artifact: id={environment_artifact_id}...")
|
|
285
|
+
environment_artifact = EnvironmentArtifact.get(environment_artifact_id)
|
|
286
|
+
click.echo(f"Found environment artifact: id={environment_artifact.id} version={environment_artifact.version} environment_name={environment_artifact.environment_name}")
|
|
287
|
+
|
|
288
|
+
click.echo("Loading environment artifact...")
|
|
289
|
+
try:
|
|
290
|
+
asyncio.run(env.load_environment_artifact(environment_artifact))
|
|
291
|
+
except RuntimeError as e:
|
|
292
|
+
click.echo(f"Error: {e}", err=True)
|
|
293
|
+
sys.exit(1)
|
|
294
|
+
click.echo("Loaded environment artifact into env")
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@mcp_server.command()
|
|
298
|
+
@click.argument("env_id")
|
|
299
|
+
@click.option("--version", "env_version", type=int, default=None, help="Env version (default: latest)")
|
|
300
|
+
def validate(env_id: str, env_version: int | None):
|
|
301
|
+
"""Validate an MCP server environment's tool schemas."""
|
|
302
|
+
from agent_env.store.base import NotFoundError
|
|
303
|
+
from agent_env.task import Task
|
|
304
|
+
from agent_env.task_step.task_steps.env_card_validator import VALIDATED_ENVIRONMENT_CARD_KEY
|
|
305
|
+
|
|
306
|
+
try:
|
|
307
|
+
env = Env.get(env_id, env_version)
|
|
308
|
+
except NotFoundError:
|
|
309
|
+
click.echo(f"Error: Env '{env_id}' not found", err=True)
|
|
310
|
+
sys.exit(1)
|
|
311
|
+
|
|
312
|
+
if not isinstance(env, MCPServerEnv):
|
|
313
|
+
click.echo(f"Error: Env '{env_id}' is type '{env.type}', expected mcp_server", err=True)
|
|
314
|
+
sys.exit(1)
|
|
315
|
+
|
|
316
|
+
click.echo(f"Validating env: id={env.id} version={env.version} environment_name={env.environment_name}")
|
|
317
|
+
instance_id = asyncio.run(env.validate(on_progress=click.echo))
|
|
318
|
+
|
|
319
|
+
instance = Task.get_instance(instance_id)
|
|
320
|
+
click.echo(f"Task instance: {instance_id} status={instance.status}")
|
|
321
|
+
|
|
322
|
+
env = Env.get(env_id, env.version)
|
|
323
|
+
|
|
324
|
+
# Schema validation results
|
|
325
|
+
schema = env.metadata.get("mcp_tool_schema_validation", {})
|
|
326
|
+
schema_passed = schema.get("passed")
|
|
327
|
+
total = schema.get("total_tools", 0)
|
|
328
|
+
missing = schema.get("tools_missing_description", [])
|
|
329
|
+
param_issues = schema.get("parameter_issues", {})
|
|
330
|
+
|
|
331
|
+
click.echo(click.style("\nSchema validation:", bold=True))
|
|
332
|
+
if schema_passed:
|
|
333
|
+
click.echo(click.style(f" PASSED: all {total} tool(s) have valid schemas", fg="green"))
|
|
334
|
+
else:
|
|
335
|
+
click.echo(click.style(" FAILED:", fg="red"))
|
|
336
|
+
if missing:
|
|
337
|
+
click.echo(f" Tools missing descriptions: {missing}")
|
|
338
|
+
for tool_name, issues in param_issues.items():
|
|
339
|
+
click.echo(f" {tool_name}:")
|
|
340
|
+
for issue in issues:
|
|
341
|
+
click.echo(f" - {issue}")
|
|
342
|
+
|
|
343
|
+
# Spec conformance results (live tool surface vs. the baked /openapi.yaml)
|
|
344
|
+
_echo_spec_conformance(env.metadata.get("mcp_spec_conformance"))
|
|
345
|
+
|
|
346
|
+
# Tool correctness results
|
|
347
|
+
correctness = env.metadata.get("mcp_tool_correctness_validation", {})
|
|
348
|
+
if correctness:
|
|
349
|
+
correctness_passed = correctness.get("passed")
|
|
350
|
+
correctness_total = correctness.get("total_tools", 0)
|
|
351
|
+
results = correctness.get("results", [])
|
|
352
|
+
|
|
353
|
+
click.echo(click.style("\nTool correctness:", bold=True))
|
|
354
|
+
if correctness_passed:
|
|
355
|
+
click.echo(click.style(f" PASSED: all {correctness_total} tool(s) work correctly", fg="green"))
|
|
356
|
+
else:
|
|
357
|
+
click.echo(click.style(" FAILED:", fg="red"))
|
|
358
|
+
for r in results:
|
|
359
|
+
if not r.get("passed"):
|
|
360
|
+
click.echo(f" {r['tool_name']}: {r.get('error', 'unknown error')}")
|
|
361
|
+
if r.get("justification"):
|
|
362
|
+
click.echo(f" {r['justification']}")
|
|
363
|
+
|
|
364
|
+
# Environment card
|
|
365
|
+
card_val = env.metadata.get(VALIDATED_ENVIRONMENT_CARD_KEY)
|
|
366
|
+
click.secho("\nEnvironment card:", bold=True)
|
|
367
|
+
if not card_val:
|
|
368
|
+
click.echo(" (not validated)")
|
|
369
|
+
elif card_val.get("accessible"):
|
|
370
|
+
missing = [f for f, v in card_val.get("required_fields", {}).items() if not v.get("present")]
|
|
371
|
+
click.secho(f" ACCESSIBLE: {card_val.get('children_count', 0)} child env(s); extensions={card_val.get('extensions', [])}; tools={card_val.get('tools', [])}", fg="green")
|
|
372
|
+
if missing:
|
|
373
|
+
click.secho(f" missing required fields: {missing}", fg="yellow")
|
|
374
|
+
else:
|
|
375
|
+
click.secho(f" NOT ACCESSIBLE: {card_val.get('error', 'no card')}", fg="magenta")
|
|
376
|
+
|
|
377
|
+
# Consolidated release gate (required live-server gates rolled up)
|
|
378
|
+
gate = env.metadata.get("validation_gate")
|
|
379
|
+
click.secho("\nRelease gate (required):", bold=True)
|
|
380
|
+
if not gate:
|
|
381
|
+
click.echo(" (not aggregated)")
|
|
382
|
+
elif gate.get("passed"):
|
|
383
|
+
click.secho(f" PASSED: {', '.join(gate.get('required_gates', []))}", fg="green")
|
|
384
|
+
else:
|
|
385
|
+
failed = gate.get("failed_gates", [])
|
|
386
|
+
missing = gate.get("missing_gates", [])
|
|
387
|
+
click.secho(f" FAILED — failed={failed} did-not-run={missing}", fg="red")
|
|
388
|
+
if gate and gate.get("skipped_gates"):
|
|
389
|
+
click.secho(f" skipped (nothing to check): {', '.join(gate['skipped_gates'])}", fg="yellow")
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
@mcp_server.command(name="create-cli")
|
|
393
|
+
@click.option("--id", "env_id", required=True, help="MCPServerEnv id")
|
|
394
|
+
@click.option("--version", "env_version", type=int, default=None, help="Env version (default: latest)")
|
|
395
|
+
@click.option("--command-name", default=None, help="CLI command name (defaults to env's environment_name)")
|
|
396
|
+
@click.option("--force", is_flag=True, default=False, help="Rebuild even if a CliArtifact ref exists in env metadata")
|
|
397
|
+
def create_cli(env_id: str, env_version: int | None, command_name: str | None, force: bool):
|
|
398
|
+
"""Build a Click-based CLI artifact from a deployed MCPServerEnv's tools."""
|
|
399
|
+
|
|
400
|
+
env = Env.get(env_id, env_version)
|
|
401
|
+
if not isinstance(env, MCPServerEnv):
|
|
402
|
+
click.echo(f"Error: env '{env_id}' is type '{env.type}', expected mcp_server", err=True)
|
|
403
|
+
sys.exit(1)
|
|
404
|
+
|
|
405
|
+
artifact = asyncio.run(env.create_cli(command_name=command_name, on_progress=click.echo, force=force))
|
|
406
|
+
click.echo(
|
|
407
|
+
f"Created CliArtifact: id={artifact.id} version={artifact.version} "
|
|
408
|
+
f"command_name={artifact.command_name} entrypoint={artifact.entrypoint} "
|
|
409
|
+
f"cli_s3_url={artifact.cli_object_url}"
|
|
410
|
+
)
|