Teach agent builder packed frontends
All checks were successful
build / build (push) Successful in 25s

This commit is contained in:
robert
2026-05-23 15:01:14 -04:00
parent f88fdf80ee
commit 0b9e594bec
10 changed files with 265 additions and 22 deletions

View File

@@ -41,12 +41,58 @@ class TemplateInitTests(unittest.TestCase):
self.assertIn("create_deep_agent", files["agent.py"])
self.assertIn("name: research-agent", files["a2a.yaml"])
self.assertIn("entrypoint: agent:ResearchAgent", files["a2a.yaml"])
self.assertNotIn("{{ frontend_block }}", files["a2a.yaml"])
self.assertNotIn("frontend:", files["a2a.yaml"])
self.assertIn("deepagents>=0.5.0", files["requirements.txt"])
def test_render_a2a_init_template_can_include_react_frontend(self) -> None:
files = _render_a2a_init_template(
"chart-agent",
description="Chart helper",
frontend="react",
)
self.assertTrue(
{
"agent.py",
"a2a.yaml",
"requirements.txt",
"frontend/package.json",
"frontend/index.html",
"frontend/vite.config.js",
"frontend/src/main.jsx",
"frontend/src/App.jsx",
"frontend/src/a2a.js",
"frontend/src/style.css",
}.issubset(files)
)
self.assertIn("frontend:", files["a2a.yaml"])
self.assertIn("build: npm run build", files["a2a.yaml"])
self.assertIn("mount: /app", files["a2a.yaml"])
self.assertIn("auth: inherit", files["a2a.yaml"])
self.assertIn("Skill runner", files["frontend/src/App.jsx"])
self.assertIn("callSkill", files["frontend/src/App.jsx"])
self.assertIn("CONFIG_URL", files["frontend/src/a2a.js"])
self.assertIn('"/invoke": agent', files["frontend/vite.config.js"])
def test_render_a2a_init_template_can_include_static_frontend(self) -> None:
files = _render_a2a_init_template("status-agent", frontend="static")
self.assertIn("frontend/dist/index.html", files)
self.assertIn("frontend:", files["a2a.yaml"])
self.assertIn("dist: dist", files["a2a.yaml"])
self.assertIn("mount: /app", files["a2a.yaml"])
self.assertNotIn("build: npm run build", files["a2a.yaml"])
self.assertIn("./a2a-client.js", files["frontend/dist/index.html"])
def test_render_a2a_init_template_rejects_invalid_names(self) -> None:
with self.assertRaises(ValueError):
_render_a2a_init_template("Bad Name")
def test_render_a2a_init_template_rejects_invalid_frontend(self) -> None:
with self.assertRaises(ValueError):
_render_a2a_init_template("demo-agent", frontend="vue")
def test_agent_projects_can_diverge_from_template(self) -> None:
files = _render_a2a_init_template("regex-explainer")
files["agent.py"] = "from a2a_pack import A2AAgent\n"