Send Agent DSL from agent-builder deploys
All checks were successful
build / build (push) Successful in 3s

This commit is contained in:
robert
2026-06-04 17:10:18 -03:00
parent be37a2f248
commit 6ab34c7200
2 changed files with 116 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import io
import json
import re
import tarfile
import tempfile
import time
from dataclasses import dataclass
from importlib import resources
@@ -530,6 +531,10 @@ def build_tools(ctx: ToolContext) -> list[Any]:
return json.dumps({"error": f"no files at agents/{name}/"})
# Read the entrypoint from a2a.yaml so we can pass it verbatim.
entrypoint = _read_entrypoint(bundle_bytes) or f"agent:{_class_name(name)}"
try:
agent_dsl_json = _compile_agent_dsl_json(bundle_bytes)
except Exception as exc: # noqa: BLE001
return json.dumps({"error": f"agent_dsl compile failed: {exc}"})
# NOTE: the CP from-tarball endpoint names the file field
# ``source`` (see apps/control-plane/control_plane/routes/agents.py).
@@ -538,6 +543,7 @@ def build_tools(ctx: ToolContext) -> list[Any]:
"name": name, "version": version,
"entrypoint": entrypoint, "public": "true" if public else "false",
"description": "Built by agent-builder.",
"agent_dsl": agent_dsl_json,
}
if isinstance(base_head, str) and base_head:
data["base_head_sha"] = base_head
@@ -1146,6 +1152,20 @@ def _files_from_tarball(bundle: bytes) -> dict[str, bytes]:
return out
def _compile_agent_dsl_json(bundle: bytes) -> str:
from a2a_pack.cli.main import _compile_project_dsl
files = _files_from_tarball(bundle)
with tempfile.TemporaryDirectory(prefix="agent-builder-dsl-") as tmp:
root = Path(tmp)
for rel, body in files.items():
path = root / rel
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(body)
_cfg, dsl = _compile_project_dsl(root)
return dsl.model_dump_json()
def _replace_workspace_files(
store_or_s3: Any,
bucket_or_prefix: str,