Use public SDK DSL compiler
All checks were successful
build / build (push) Successful in 3s

This commit is contained in:
robert
2026-06-04 17:16:46 -03:00
parent 2a4f31bd97
commit a49bebd8d9

View File

@@ -1153,7 +1153,9 @@ def _files_from_tarball(bundle: bytes) -> dict[str, bytes]:
def _compile_agent_dsl_json(bundle: bytes) -> str: def _compile_agent_dsl_json(bundle: bytes) -> str:
from a2a_pack.cli.main import _compile_project_dsl import yaml
from a2a_pack import apply_project_manifest, compile_agent_to_dsl
from a2a_pack.cli.loader import load_agent_class
files = _files_from_tarball(bundle) files = _files_from_tarball(bundle)
with tempfile.TemporaryDirectory(prefix="agent-builder-dsl-") as tmp: with tempfile.TemporaryDirectory(prefix="agent-builder-dsl-") as tmp:
@@ -1162,7 +1164,30 @@ def _compile_agent_dsl_json(bundle: bytes) -> str:
path = root / rel path = root / rel
path.parent.mkdir(parents=True, exist_ok=True) path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(body) path.write_bytes(body)
_cfg, dsl = _compile_project_dsl(root) cfg = yaml.safe_load((root / "a2a.yaml").read_text(encoding="utf-8")) or {}
if not isinstance(cfg, dict):
raise ValueError("a2a.yaml must be a mapping")
language = str(cfg.get("language") or "python").strip().lower()
if language != "python":
raise ValueError(f"agent-builder deploy only supports python Agent DSL, got {language!r}")
entrypoint = str(cfg.get("entrypoint") or "").strip()
if not entrypoint:
raise ValueError("a2a.yaml entrypoint is required")
cls = load_agent_class(entrypoint, project_dir=root)
apply_project_manifest(cls, cfg)
dsl = compile_agent_to_dsl(
cls,
language="python",
entrypoint=entrypoint,
metadata={
"source": "agent-builder",
"project_manifest": {
key: value
for key, value in cfg.items()
if key in {"name", "version", "entrypoint", "frontend"}
},
},
)
return dsl.model_dump_json() return dsl.model_dump_json()