From a49bebd8d96064b7babdc589a4906bc8abbe0fd0 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 4 Jun 2026 17:16:46 -0300 Subject: [PATCH] Use public SDK DSL compiler --- agent_builder/tools.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/agent_builder/tools.py b/agent_builder/tools.py index 068f12c..003511b 100644 --- a/agent_builder/tools.py +++ b/agent_builder/tools.py @@ -1153,7 +1153,9 @@ def _files_from_tarball(bundle: bytes) -> dict[str, bytes]: 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) 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.parent.mkdir(parents=True, exist_ok=True) 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()