agentsml-impl 0.2.0__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.
Files changed (129) hide show
  1. agentsml_impl/__init__.py +3 -0
  2. agentsml_impl/cli.py +472 -0
  3. agentsml_impl/compiler/__init__.py +1 -0
  4. agentsml_impl/compiler/capabilities.py +330 -0
  5. agentsml_impl/compiler/conditions.py +177 -0
  6. agentsml_impl/compiler/diagnostics.py +112 -0
  7. agentsml_impl/compiler/durations.py +31 -0
  8. agentsml_impl/compiler/expressions.py +123 -0
  9. agentsml_impl/compiler/identifiers.py +60 -0
  10. agentsml_impl/compiler/ir.py +391 -0
  11. agentsml_impl/compiler/limits.py +28 -0
  12. agentsml_impl/compiler/loader.py +83 -0
  13. agentsml_impl/compiler/naming.py +87 -0
  14. agentsml_impl/compiler/planner.py +79 -0
  15. agentsml_impl/compiler/render.py +90 -0
  16. agentsml_impl/compiler/schema_validation.py +121 -0
  17. agentsml_impl/compiler/semantic_validation.py +424 -0
  18. agentsml_impl/protocols/__init__.py +1 -0
  19. agentsml_impl/runtime/__init__.py +1 -0
  20. agentsml_impl/runtime/events.py +59 -0
  21. agentsml_impl/runtime/json_schema.py +138 -0
  22. agentsml_impl/runtime/tools.py +145 -0
  23. agentsml_impl/schemas/agentsml.schema.json +406 -0
  24. agentsml_impl/schemas/v0.1/agentsml.schema.json +628 -0
  25. agentsml_impl/schemas/v0.2/agentsml.schema.json +363 -0
  26. agentsml_impl/schemas/v0.3/agentsml.schema.json +406 -0
  27. agentsml_impl/targets/__init__.py +1 -0
  28. agentsml_impl/targets/a2a/__init__.py +0 -0
  29. agentsml_impl/targets/a2a/adapter.py +94 -0
  30. agentsml_impl/targets/a2a/capabilities.yaml +25 -0
  31. agentsml_impl/targets/ag2/__init__.py +0 -0
  32. agentsml_impl/targets/ag2/adapter.py +655 -0
  33. agentsml_impl/targets/ag2/capabilities.yaml +37 -0
  34. agentsml_impl/targets/ag_ui/__init__.py +0 -0
  35. agentsml_impl/targets/ag_ui/adapter.py +123 -0
  36. agentsml_impl/targets/ag_ui/capabilities.yaml +25 -0
  37. agentsml_impl/targets/agno/__init__.py +0 -0
  38. agentsml_impl/targets/agno/adapter.py +191 -0
  39. agentsml_impl/targets/agno/capabilities.yaml +26 -0
  40. agentsml_impl/targets/ap2/__init__.py +0 -0
  41. agentsml_impl/targets/ap2/adapter.py +84 -0
  42. agentsml_impl/targets/ap2/capabilities.yaml +25 -0
  43. agentsml_impl/targets/base.py +157 -0
  44. agentsml_impl/targets/bedrock_agentcore/__init__.py +0 -0
  45. agentsml_impl/targets/bedrock_agentcore/adapter.py +592 -0
  46. agentsml_impl/targets/bedrock_agentcore/capabilities.yaml +26 -0
  47. agentsml_impl/targets/claude_agent_sdk/__init__.py +0 -0
  48. agentsml_impl/targets/claude_agent_sdk/adapter.py +178 -0
  49. agentsml_impl/targets/claude_agent_sdk/capabilities.yaml +26 -0
  50. agentsml_impl/targets/crewai/__init__.py +0 -0
  51. agentsml_impl/targets/crewai/adapter.py +441 -0
  52. agentsml_impl/targets/crewai/capabilities.yaml +30 -0
  53. agentsml_impl/targets/databricks/__init__.py +0 -0
  54. agentsml_impl/targets/databricks/adapter.py +427 -0
  55. agentsml_impl/targets/databricks/capabilities.yaml +26 -0
  56. agentsml_impl/targets/flowise/__init__.py +0 -0
  57. agentsml_impl/targets/flowise/adapter.py +71 -0
  58. agentsml_impl/targets/flowise/capabilities.yaml +26 -0
  59. agentsml_impl/targets/google_adk/__init__.py +0 -0
  60. agentsml_impl/targets/google_adk/adapter.py +589 -0
  61. agentsml_impl/targets/google_adk/capabilities.yaml +36 -0
  62. agentsml_impl/targets/langchain/__init__.py +1 -0
  63. agentsml_impl/targets/langchain/adapter.py +351 -0
  64. agentsml_impl/targets/langchain/capabilities.yaml +30 -0
  65. agentsml_impl/targets/langflow/__init__.py +0 -0
  66. agentsml_impl/targets/langflow/adapter.py +147 -0
  67. agentsml_impl/targets/langflow/capabilities.yaml +26 -0
  68. agentsml_impl/targets/langgraph/__init__.py +0 -0
  69. agentsml_impl/targets/langgraph/adapter.py +911 -0
  70. agentsml_impl/targets/langgraph/capabilities.yaml +33 -0
  71. agentsml_impl/targets/llamaindex/__init__.py +1 -0
  72. agentsml_impl/targets/llamaindex/adapter.py +406 -0
  73. agentsml_impl/targets/llamaindex/capabilities.yaml +31 -0
  74. agentsml_impl/targets/lyzr/__init__.py +0 -0
  75. agentsml_impl/targets/lyzr/adapter.py +146 -0
  76. agentsml_impl/targets/lyzr/capabilities.yaml +26 -0
  77. agentsml_impl/targets/mastra/__init__.py +0 -0
  78. agentsml_impl/targets/mastra/adapter.py +635 -0
  79. agentsml_impl/targets/mastra/capabilities.yaml +32 -0
  80. agentsml_impl/targets/mcp_server/__init__.py +0 -0
  81. agentsml_impl/targets/mcp_server/adapter.py +141 -0
  82. agentsml_impl/targets/mcp_server/capabilities.yaml +25 -0
  83. agentsml_impl/targets/microsoft_agent_framework/__init__.py +0 -0
  84. agentsml_impl/targets/microsoft_agent_framework/adapter.py +563 -0
  85. agentsml_impl/targets/microsoft_agent_framework/capabilities.yaml +26 -0
  86. agentsml_impl/targets/n8n/__init__.py +0 -0
  87. agentsml_impl/targets/n8n/adapter.py +139 -0
  88. agentsml_impl/targets/n8n/capabilities.yaml +26 -0
  89. agentsml_impl/targets/openai_agents/__init__.py +0 -0
  90. agentsml_impl/targets/openai_agents/adapter.py +175 -0
  91. agentsml_impl/targets/openai_agents/capabilities.yaml +27 -0
  92. agentsml_impl/targets/pydantic_ai/__init__.py +0 -0
  93. agentsml_impl/targets/pydantic_ai/adapter.py +922 -0
  94. agentsml_impl/targets/pydantic_ai/capabilities.yaml +37 -0
  95. agentsml_impl/targets/registry.py +290 -0
  96. agentsml_impl/targets/relevance_ai/__init__.py +0 -0
  97. agentsml_impl/targets/relevance_ai/adapter.py +66 -0
  98. agentsml_impl/targets/relevance_ai/capabilities.yaml +26 -0
  99. agentsml_impl/targets/smolagents/__init__.py +0 -0
  100. agentsml_impl/targets/smolagents/adapter.py +210 -0
  101. agentsml_impl/targets/smolagents/capabilities.yaml +27 -0
  102. agentsml_impl/targets/snowflake_cortex/__init__.py +0 -0
  103. agentsml_impl/targets/snowflake_cortex/adapter.py +167 -0
  104. agentsml_impl/targets/snowflake_cortex/capabilities.yaml +26 -0
  105. agentsml_impl/targets/spring_ai/__init__.py +1 -0
  106. agentsml_impl/targets/spring_ai/adapter.py +626 -0
  107. agentsml_impl/targets/spring_ai/capabilities.yaml +31 -0
  108. agentsml_impl/targets/strands_agents/__init__.py +1 -0
  109. agentsml_impl/targets/strands_agents/adapter.py +309 -0
  110. agentsml_impl/targets/strands_agents/capabilities.yaml +29 -0
  111. agentsml_impl/targets/support_matrix.py +91 -0
  112. agentsml_impl/targets/ucp/__init__.py +0 -0
  113. agentsml_impl/targets/ucp/adapter.py +86 -0
  114. agentsml_impl/targets/ucp/capabilities.yaml +25 -0
  115. agentsml_impl/targets/vercel_ai/__init__.py +1 -0
  116. agentsml_impl/targets/vercel_ai/adapter.py +349 -0
  117. agentsml_impl/targets/vercel_ai/capabilities.yaml +30 -0
  118. agentsml_impl/targets/vertex_agent_engine/__init__.py +0 -0
  119. agentsml_impl/targets/vertex_agent_engine/adapter.py +407 -0
  120. agentsml_impl/targets/vertex_agent_engine/capabilities.yaml +26 -0
  121. agentsml_impl/targets/zapier_agents/__init__.py +0 -0
  122. agentsml_impl/targets/zapier_agents/adapter.py +106 -0
  123. agentsml_impl/targets/zapier_agents/capabilities.yaml +26 -0
  124. agentsml_impl-0.2.0.dist-info/METADATA +109 -0
  125. agentsml_impl-0.2.0.dist-info/RECORD +129 -0
  126. agentsml_impl-0.2.0.dist-info/WHEEL +5 -0
  127. agentsml_impl-0.2.0.dist-info/entry_points.txt +3 -0
  128. agentsml_impl-0.2.0.dist-info/licenses/LICENSE +28 -0
  129. agentsml_impl-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,407 @@
1
+ """Vertex Agent Engine target adapter — Level 1 runnable code generation."""
2
+
3
+ from __future__ import annotations
4
+ import json
5
+ from pathlib import Path
6
+
7
+ from agentsml_impl.compiler.identifiers import python_identifier_ir
8
+ from agentsml_impl.compiler.naming import pascal_identifier
9
+ from agentsml_impl.compiler.ir import AgentSystemIR, ModelIR
10
+ from agentsml_impl.compiler.diagnostics import DiagCode, DiagnosticSet
11
+ from agentsml_impl.compiler.planner import GenerationPlan
12
+ from agentsml_impl.compiler.render import toml_string, write_file
13
+ from agentsml_impl.runtime.tools import generate_tools_module
14
+ from agentsml_impl.targets.base import TargetAdapter, GenerationResult
15
+
16
+
17
+ class Adapter(TargetAdapter):
18
+ @property
19
+ def name(self) -> str:
20
+ return "vertex-agent-engine"
21
+
22
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
23
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
24
+ analyze_capabilities(ir, "vertex_agent_engine", diagnostics)
25
+
26
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
27
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
28
+ ir = python_identifier_ir(ir)
29
+ out_dir.mkdir(parents=True, exist_ok=True)
30
+ pkg = plan.package_name
31
+ src = out_dir / "src" / pkg
32
+ src.mkdir(parents=True, exist_ok=True)
33
+
34
+ files: list[str] = []
35
+ files += _write_pyproject(ir, plan, out_dir)
36
+ files += _write_tools(ir, src, out_dir, diagnostics)
37
+ files += _write_agent(ir, plan, src, out_dir, diagnostics)
38
+ files += _write_run(plan, src, out_dir)
39
+ files += _write_deploy(ir, plan, src, out_dir)
40
+ files += _write_init(src, out_dir)
41
+ files += _write_gcloud_deploy(plan, out_dir)
42
+ files += _write_env_example(out_dir)
43
+ files += _write_readme(ir, plan, out_dir)
44
+
45
+ return GenerationResult(
46
+ target=self.name, out_dir=out_dir, files_written=files, success=True
47
+ )
48
+
49
+
50
+ def _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
51
+ c = f'''\
52
+ [build-system]
53
+ requires = ["setuptools>=68"]
54
+ build-backend = "setuptools.build_meta"
55
+
56
+ [project]
57
+ name = "{plan.package_name}"
58
+ version = "{ir.metadata.version or '0.1.0'}"
59
+ description = {toml_string(ir.metadata.description or plan.project_name)}
60
+ requires-python = ">=3.11"
61
+ dependencies = [
62
+ "google-cloud-aiplatform>=1.49.0",
63
+ "python-dotenv"
64
+ ]
65
+
66
+ [tool.setuptools.packages.find]
67
+ where = ["src"]
68
+ '''
69
+ write_file(out_dir, "pyproject.toml", c)
70
+ return ["pyproject.toml"]
71
+
72
+
73
+ def _write_tools(ir: AgentSystemIR, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
74
+ if not ir.tools:
75
+ return []
76
+ c = generate_tools_module(ir.tools, ds, framework="vertex")
77
+ rel = f"src/{src.name}/tools.py"
78
+ write_file(out_dir, rel, c)
79
+ return [rel]
80
+
81
+
82
+ def _tool_specs(ir: AgentSystemIR, tool_keys: list[str]) -> list[dict]:
83
+ """FunctionDeclaration specs (name, description, parameters) for declared tools."""
84
+ specs = []
85
+ for tk in tool_keys:
86
+ tool = ir.tools.get(tk)
87
+ if tool is None:
88
+ continue
89
+ params = tool.input_schema if isinstance(tool.input_schema, dict) and tool.input_schema else {"type": "object", "properties": {}}
90
+ specs.append({"name": tk, "description": tool.description or f"Tool {tk}", "parameters": params})
91
+ return specs
92
+
93
+
94
+ _AGENT_TEMPLATE = '''\
95
+ class __CLASS__:
96
+ """Vertex AI Agent Engine reasoning engine for '__AK__'."""
97
+
98
+ def __init__(self, project_id: str | None = None, location: str | None = None):
99
+ self.project_id = project_id or os.environ.get("GOOGLE_CLOUD_PROJECT", "default-project")
100
+ self.location = location or os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
101
+ self.model_name = "__MODEL__"
102
+ self.instructions = """__INST__"""
103
+ self.tools = [__TOOLS__]
104
+ self.tool_specs = json.loads(__SPECS__)
105
+ self.model = None
106
+
107
+ def set_up(self) -> None:
108
+ """Initialize the Gemini model with FunctionDeclaration tools."""
109
+ if not os.environ.get("GOOGLE_CLOUD_PROJECT"):
110
+ return
111
+ try:
112
+ import vertexai
113
+ from vertexai.generative_models import FunctionDeclaration, GenerativeModel, Tool
114
+ except ImportError:
115
+ return
116
+ vertexai.init(project=self.project_id, location=self.location)
117
+ tools = None
118
+ if self.tool_specs:
119
+ declarations = [
120
+ FunctionDeclaration(
121
+ name=spec["name"],
122
+ description=spec["description"],
123
+ parameters=spec["parameters"],
124
+ )
125
+ for spec in self.tool_specs
126
+ ]
127
+ tools = [Tool.from_function_declarations(declarations)]
128
+ self.model = GenerativeModel(
129
+ model_name=self.model_name,
130
+ system_instruction=self.instructions,
131
+ tools=tools,
132
+ )
133
+
134
+ def _dispatch_tool_calls(self, tool_calls: list[dict[str, Any]]) -> list[dict[str, Any]]:
135
+ """Execute model-requested tool calls once (single round, no loop)."""
136
+ results: list[dict[str, Any]] = []
137
+ for call in tool_calls:
138
+ fn = getattr(_tools_module, call["name"], None) if _tools_module is not None else None
139
+ if fn is None:
140
+ results.append({"name": call["name"], "error": "unknown tool"})
141
+ continue
142
+ try:
143
+ results.append({"name": call["name"], "result": fn(**call["arguments"])})
144
+ except Exception as exc:
145
+ results.append({"name": call["name"], "error": f"{type(exc).__name__}: {exc}"})
146
+ return results
147
+
148
+ def query(self, input_text: str, **kwargs: Any) -> dict[str, Any]:
149
+ """Invoke the reasoning engine.
150
+
151
+ Falls back to a deterministic echo only when the Vertex SDK is not importable
152
+ or GOOGLE_CLOUD_PROJECT is unset. Any other failure is returned as
153
+ {"status": "error", "error": "<type>: <message>"} (never raised, never faked as success).
154
+ """
155
+ try:
156
+ if self.model is None:
157
+ self.set_up()
158
+ if self.model is not None:
159
+ response = self.model.generate_content(input_text)
160
+ text_parts: list[str] = []
161
+ tool_calls: list[dict[str, Any]] = []
162
+ for candidate in getattr(response, "candidates", None) or []:
163
+ for part in candidate.content.parts:
164
+ call = getattr(part, "function_call", None)
165
+ if call is not None and getattr(call, "name", ""):
166
+ tool_calls.append({"name": call.name, "arguments": dict(call.args)})
167
+ elif getattr(part, "text", ""):
168
+ text_parts.append(part.text)
169
+ result: dict[str, Any] = {
170
+ "output": "".join(text_parts),
171
+ "model": self.model_name,
172
+ "status": "success",
173
+ }
174
+ if tool_calls:
175
+ result["tool_calls"] = tool_calls
176
+ result["tool_results"] = self._dispatch_tool_calls(tool_calls)
177
+ return result
178
+ except Exception as exc:
179
+ return {
180
+ "output": "",
181
+ "model": self.model_name,
182
+ "status": "error",
183
+ "error": f"{type(exc).__name__}: {exc}",
184
+ }
185
+ return {
186
+ "output": f"Vertex Agent Engine ({self.model_name}) response to: {input_text}",
187
+ "model": self.model_name,
188
+ "status": "success",
189
+ }
190
+ '''
191
+
192
+
193
+ def _write_agent(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
194
+ agent_blocks: list[str] = []
195
+ class_names: list[str] = []
196
+ tools_import = f"from .tools import {', '.join(ir.tools.keys())}" if ir.tools else ""
197
+
198
+ for ak, agent in ir.agents.items():
199
+ m = ir.models.get(agent.model)
200
+ mstr = m.name if m else 'gemini-1.5-pro'
201
+ inst = agent.instructions.replace('"""', "'''")
202
+ tools_list = ", ".join(agent.tools) if agent.tools else ""
203
+
204
+ class_name = f"{pascal_identifier(ak, prefix='Agent')}Agent"
205
+ class_names.append(class_name)
206
+ specs = _tool_specs(ir, agent.tools)
207
+ block = _AGENT_TEMPLATE
208
+ for k, v in {
209
+ "__CLASS__": class_name, "__AK__": ak, "__MODEL__": mstr,
210
+ "__INST__": inst, "__TOOLS__": tools_list,
211
+ "__SPECS__": repr(json.dumps(specs)),
212
+ }.items():
213
+ block = block.replace(k, v)
214
+ agent_blocks.append(block)
215
+
216
+ tools_module_import = "from . import tools as _tools_module" if ir.tools else "_tools_module = None"
217
+ first_cls = class_names[0] if class_names else "DefaultAgent"
218
+ if not class_names:
219
+ agent_blocks.append('''\
220
+ class DefaultAgent:
221
+ def __init__(self, project_id: str | None = None, location: str | None = None):
222
+ self.project_id = project_id
223
+ self.location = location
224
+ def set_up(self) -> None:
225
+ pass
226
+ def query(self, input_text: str, **kwargs: Any) -> dict[str, Any]:
227
+ return {"output": input_text, "status": "success"}
228
+ ''')
229
+
230
+ c = f'''\
231
+ """Vertex AI Agent Engine definitions for {plan.project_name}."""
232
+ from __future__ import annotations
233
+ import json
234
+ import os
235
+ from typing import Any
236
+ {tools_import}
237
+ {tools_module_import}
238
+
239
+ {chr(10).join(agent_blocks)}
240
+
241
+ root_agent = {first_cls}()
242
+ __all__ = [{", ".join(repr(cn) for cn in class_names)}, "root_agent"]
243
+ '''
244
+ rel = f"src/{src.name}/agent.py"
245
+ write_file(out_dir, rel, c)
246
+ return [rel]
247
+
248
+
249
+ def _write_run(plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
250
+ c = f'''\
251
+ """Runner for {plan.project_name} (Vertex Agent Engine)."""
252
+ from __future__ import annotations
253
+ import os
254
+ import sys
255
+ from .agent import root_agent
256
+
257
+ def main() -> None:
258
+ q = " ".join(sys.argv[1:]) or "Hello"
259
+
260
+ project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-project-id")
261
+ location = os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
262
+ try:
263
+ import vertexai
264
+ vertexai.init(project=project_id, location=location)
265
+ root_agent.set_up()
266
+ except Exception:
267
+ pass
268
+
269
+ res = root_agent.query(q)
270
+ print("Result:", res.get("output", res))
271
+
272
+ if __name__ == "__main__":
273
+ main()
274
+ '''
275
+ rel = f"src/{src.name}/run.py"
276
+ write_file(out_dir, rel, c)
277
+ return [rel]
278
+
279
+
280
+ def _write_deploy(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
281
+ c = f'''\
282
+ """Deployment script for {plan.project_name} to Vertex AI Agent Engine."""
283
+ from __future__ import annotations
284
+ import os
285
+ from typing import Any
286
+ import vertexai
287
+ from vertexai.preview import reasoning_engines
288
+ from .agent import root_agent
289
+
290
+ def deploy() -> Any:
291
+ project = os.environ.get("GOOGLE_CLOUD_PROJECT")
292
+ location = os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
293
+ if not project:
294
+ raise ValueError("GOOGLE_CLOUD_PROJECT environment variable must be set to deploy.")
295
+ vertexai.init(project=project, location=location)
296
+ engine = reasoning_engines.ReasoningEngine.create(
297
+ root_agent,
298
+ requirements=["google-cloud-aiplatform[reasoningengine]"],
299
+ display_name="{plan.project_name}-agent",
300
+ description={toml_string(ir.metadata.description or plan.project_name)},
301
+ )
302
+ print(f"Successfully deployed Vertex Reasoning Engine: {{engine.resource_name}}")
303
+ return engine
304
+
305
+ if __name__ == "__main__":
306
+ deploy()
307
+ '''
308
+ rel = f"src/{src.name}/deploy.py"
309
+ write_file(out_dir, rel, c)
310
+ return [rel]
311
+
312
+
313
+ def _write_init(src: Path, out_dir: Path) -> list[str]:
314
+ c = f'"""Package: {src.name}."""\n'
315
+ rel = f"src/{src.name}/__init__.py"
316
+ write_file(out_dir, rel, c)
317
+ return [rel]
318
+
319
+
320
+ def _write_gcloud_deploy(plan: GenerationPlan, out_dir: Path) -> list[str]:
321
+ c = f"""\
322
+ # Deploying {plan.project_name} to Vertex AI Agent Engine
323
+
324
+ This project uses Google Cloud Vertex AI Reasoning Engines.
325
+
326
+ ## Prerequisites
327
+
328
+ 1. Install Google Cloud SDK (`gcloud`).
329
+ 2. Authenticate application default credentials:
330
+ ```bash
331
+ gcloud auth application-default login
332
+ ```
333
+ 3. Set your Google Cloud project and region:
334
+ ```bash
335
+ export GOOGLE_CLOUD_PROJECT="your-project-id"
336
+ export GOOGLE_CLOUD_LOCATION="us-central1"
337
+ ```
338
+
339
+ ## Deploying
340
+
341
+ Run the deployment module:
342
+ ```bash
343
+ python -m {plan.package_name}.deploy
344
+ ```
345
+
346
+ ## Invoking the Remote Reasoning Engine
347
+
348
+ ```python
349
+ import vertexai
350
+ from vertexai.preview import reasoning_engines
351
+
352
+ vertexai.init(project="your-project-id", location="us-central1")
353
+ engine = reasoning_engines.ReasoningEngine("projects/.../locations/us-central1/reasoningEngines/<id>")
354
+ response = engine.query(input_text="Hello Vertex AI!")
355
+ print(response)
356
+ ```
357
+ """
358
+ write_file(out_dir, "gcloud-deploy.md", c)
359
+ return ["gcloud-deploy.md"]
360
+
361
+
362
+ def _write_env_example(out_dir: Path) -> list[str]:
363
+ c = """\
364
+ GOOGLE_CLOUD_PROJECT=your-project-id
365
+ GOOGLE_CLOUD_LOCATION=us-central1
366
+ """
367
+ write_file(out_dir, ".env.example", c)
368
+ return [".env.example"]
369
+
370
+
371
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
372
+ c = f"""\
373
+ # {plan.project_name} — Vertex Agent Engine
374
+
375
+ Generated by `agentsml-impl`.
376
+
377
+ Vertex AI Agent Engine target generates Google Cloud Vertex AI Reasoning Engine
378
+ classes that can run locally or deploy directly to Google Cloud.
379
+
380
+ ## Architecture
381
+
382
+ - `src/{plan.package_name}/agent.py`: Vertex AI Reasoning Engine classes with `set_up()` and `query()`.
383
+ - `src/{plan.package_name}/deploy.py`: Deployment script using `vertexai.preview.reasoning_engines.ReasoningEngine.create`.
384
+ - `src/{plan.package_name}/run.py`: Local execution runner.
385
+ - `gcloud-deploy.md`: Step-by-step Google Cloud deployment guide.
386
+
387
+ ## Runtime behavior
388
+
389
+ `query()` calls Gemini through the Vertex AI SDK when `GOOGLE_CLOUD_PROJECT` is set and
390
+ `vertexai` is importable; otherwise it returns a deterministic local echo. Any other
391
+ failure is returned as `{{"status": "error", "error": "<type>: <message>"}}` (not raised).
392
+ When the model returns function calls they are executed once (single round) against
393
+ `tools.py` and reported under `tool_results` next to `tool_calls`.
394
+
395
+ ## Quickstart
396
+
397
+ ```bash
398
+ pip install -e .
399
+ python -m {plan.package_name}.run "What is your mission?"
400
+ ```
401
+
402
+ ## Cloud Deployment
403
+
404
+ See [gcloud-deploy.md](gcloud-deploy.md) for full deployment instructions.
405
+ """
406
+ write_file(out_dir, "README.md", c)
407
+ return ["README.md"]
@@ -0,0 +1,26 @@
1
+ target: vertex_agent_engine
2
+ kind: code
3
+ language: python
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "1.0.0"
7
+ supports:
8
+ agents: native
9
+ tools: native
10
+ workflows: lossy
11
+ graph_edges: lossy
12
+ graph_conditions: lossy
13
+ cycles: lossy
14
+ parallel: unsupported
15
+ human_approval: adapter
16
+ mcp: adapter
17
+ a2a: manual
18
+ ag_ui: adapter
19
+ structured_output: manual
20
+ observability: native
21
+ artifacts:
22
+ - python_project
23
+ - diagnostics
24
+ - readme
25
+ notes: >
26
+ Maps to Google Cloud Vertex AI Reasoning Engine.
File without changes
@@ -0,0 +1,106 @@
1
+ """Zapier Agents target adapter — Level 1 code generation."""
2
+
3
+ from __future__ import annotations
4
+ import json
5
+ from pathlib import Path
6
+
7
+ from agentsml_impl.compiler.ir import AgentSystemIR, ModelIR
8
+ from agentsml_impl.compiler.diagnostics import DiagCode, DiagnosticSet
9
+ from agentsml_impl.compiler.planner import GenerationPlan
10
+ from agentsml_impl.compiler.render import write_file
11
+ from agentsml_impl.targets.base import TargetAdapter, GenerationResult
12
+
13
+
14
+ class Adapter(TargetAdapter):
15
+ @property
16
+ def name(self) -> str:
17
+ return "zapier-agents"
18
+
19
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
20
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
21
+ analyze_capabilities(ir, "zapier_agents", diagnostics)
22
+ diagnostics.add_warning(
23
+ code=DiagCode.UNSUPPORTED_FEATURE,
24
+ message=(
25
+ "Zapier Agents has no documented definition import/export format. "
26
+ "Agents must be configured manually in the Zapier Agents UI using the generated instructions."
27
+ ),
28
+ target=self.name,
29
+ recommendation="Follow the steps in README.md to configure your agent in the Zapier Agents UI.",
30
+ )
31
+
32
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
33
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
34
+ out_dir.mkdir(parents=True, exist_ok=True)
35
+ diagnostics.add_warning(
36
+ code=DiagCode.UNSUPPORTED_FEATURE,
37
+ message=(
38
+ "Zapier Agents has no documented definition import/export format. "
39
+ "Agents must be configured manually in the Zapier Agents UI using the generated instructions."
40
+ ),
41
+ target=self.name,
42
+ recommendation="Follow the steps in README.md to configure your agent in the Zapier Agents UI.",
43
+ )
44
+
45
+ files: list[str] = []
46
+ files += _write_zapier_json(ir, plan, out_dir)
47
+ files += _write_readme(ir, plan, out_dir)
48
+
49
+ return GenerationResult(
50
+ target=self.name, out_dir=out_dir, files_written=files, success=True
51
+ )
52
+
53
+
54
+ def _write_zapier_json(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
55
+ bots = []
56
+ for ak, agent in ir.agents.items():
57
+ bots.append({
58
+ "name": ak,
59
+ "instructions": agent.instructions,
60
+ "tools": agent.tools or []
61
+ })
62
+
63
+ export = {
64
+ "project": plan.project_name,
65
+ "bots": bots
66
+ }
67
+
68
+ c = json.dumps(export, indent=2)
69
+ rel = "zapier.json"
70
+ write_file(out_dir, rel, c)
71
+ return [rel]
72
+
73
+
74
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
75
+ agent_sections = []
76
+ for ak, agent in ir.agents.items():
77
+ tools_str = ", ".join(f"`{t}`" for t in agent.tools) if agent.tools else "None"
78
+ inst = agent.instructions.strip()
79
+ agent_sections.append(
80
+ f"### Agent: `{ak}`\n\n"
81
+ f"- **Role / Name**: {ak}\n"
82
+ f"- **Tools**: {tools_str}\n"
83
+ f"- **Instructions**:\n```\n{inst}\n```\n"
84
+ )
85
+
86
+ agents_md = "\n".join(agent_sections)
87
+ c = f"""\
88
+ # {plan.project_name} — Zapier Agents Setup Guide
89
+
90
+ Generated by `agentsml-impl`.
91
+
92
+ > [!NOTE]
93
+ > Zapier Agents are configured interactively via the Zapier web UI. Zapier does not provide a public definition import format or CLI. The `zapier.json` file in this folder is an export reference, and this guide provides the configuration to enter into the Zapier UI.
94
+
95
+ ## Manual Configuration Steps
96
+
97
+ 1. Navigate to [Zapier Central / Zapier Agents](https://zapier.com/agents).
98
+ 2. Click **Create Agent** (or edit an existing one).
99
+ 3. Set the agent name, model instructions, and attach the required actions/tools as listed below.
100
+
101
+ ## Agent Specifications
102
+
103
+ {agents_md}
104
+ """
105
+ write_file(out_dir, "README.md", c)
106
+ return ["README.md"]
@@ -0,0 +1,26 @@
1
+ target: zapier_agents
2
+ kind: code
3
+ language: json
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "1.0.0"
7
+ supports:
8
+ agents: native
9
+ tools: adapter
10
+ workflows: lossy
11
+ graph_edges: lossy
12
+ graph_conditions: lossy
13
+ cycles: lossy
14
+ parallel: unsupported
15
+ human_approval: unsupported
16
+ mcp: unsupported
17
+ a2a: manual
18
+ ag_ui: unsupported
19
+ structured_output: unsupported
20
+ observability: native
21
+ artifacts:
22
+ - json_export
23
+ - diagnostics
24
+ - readme
25
+ notes: >
26
+ Maps to Zapier Central / Zapier Agents JSON config.
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentsml-impl
3
+ Version: 0.2.0
4
+ Summary: AgentsML IR-first compiler — converts AgentsML YAML documents into target-specific code, manifests, and deployment bundles.
5
+ Author: Sanjay Sharma
6
+ License-Expression: MIT
7
+ Keywords: agentsml,agents,compiler,codegen
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: jsonschema>=4.23
13
+ Requires-Dist: jinja2>=3.1
14
+ Requires-Dist: typer>=0.12
15
+ Requires-Dist: rich>=13.0
16
+ Requires-Dist: pydantic>=2.7
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=8.0; extra == "dev"
19
+ Requires-Dist: pytest-cov; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # agentsml-impl
23
+
24
+ `agentsml-impl` is the reference compiler and implementation surface for AgentsML.
25
+ It ingests AgentsML definitions (YAML or JSON) and compiles them into functioning code, export artifacts, and standard configurations for various target AI agent runtimes and protocols.
26
+
27
+ This repository is distinct from the core spec repository. While `agentsml/` contains the standard definitions and schemas, `agentsml-impl/` brings them to life via a Design 2 IR-first compilation approach.
28
+
29
+ ## Supported Targets
30
+
31
+ See [Target Support Matrix](docs/target-support.md) for the current registry coverage, grouped by target category and maturity. The registry lists 31 targets: 22 runnable generators, 9 export generators, and 0 scaffolds. Certification: 15 external-runtime, 16 offline-behavioral, 0 structural. Registry level is retained for compatibility but does not imply runtime maturity.
32
+
33
+ ## Quickstart
34
+
35
+ ### Installation
36
+
37
+ ```bash
38
+ # Clone the repository
39
+ git clone https://github.com/indoos/agentsml-impl.git
40
+ cd agentsml-impl
41
+
42
+ # Install locally
43
+ pip install -e .
44
+ ```
45
+
46
+ ### Usage
47
+
48
+ The CLI is available as both `agentsml` and `agentsml-impl`.
49
+
50
+ **1. Validate an AgentsML document:**
51
+ ```bash
52
+ agentsml validate path/to/agent.yaml
53
+ ```
54
+
55
+ **2. Compile to a Target Framework:**
56
+ ```bash
57
+ agentsml generate path/to/agent.yaml --target pydantic-ai --out my_project
58
+ ```
59
+
60
+ **3. Run Diagnostic Checks:**
61
+ ```bash
62
+ agentsml doctor path/to/agent.yaml --target crewai
63
+ ```
64
+
65
+ **4. Compile (alias of generate):**
66
+ ```bash
67
+ agentsml compile path/to/agent.yaml -t langgraph -o my_project
68
+ ```
69
+
70
+ **5. Render the execution graph:**
71
+ ```bash
72
+ agentsml graph path/to/agent.yaml --format mermaid
73
+ ```
74
+
75
+ **6. List registered targets with maturity and certification:**
76
+ ```bash
77
+ agentsml list-targets
78
+ ```
79
+
80
+ ### Development & Testing
81
+
82
+ Run the complete structural, golden, conformance, and behavioral suite:
83
+ ```bash
84
+ pip install -e ".[dev]"
85
+ pytest
86
+ ```
87
+
88
+ Run offline behavioral and external-runtime certification:
89
+ ```bash
90
+ python scripts/run_certification.py
91
+ uv run --python 3.12 --with pytest --with 'pydantic-ai==1.107.0' --with 'langchain>=1.0,<2' --with 'langgraph==1.2.20' --with 'langchain-openai==1.7.4' --with 'google-adk==2.14.0' --with 'a2a-sdk[http-server]>=1.3.0' --with 'git+https://github.com/openai/swarm.git' --with 'smolagents[openai]>=1.0.0' --with 'anthropic>=0.30.0' --with 'crewai>=0.80.0' --with 'llama-index-core>=0.11.0' --with 'llama-index-llms-openai>=0.1.0' --with 'agno>=1.0.0' --with 'ag2==1.3.1' --with 'uvicorn>=0.30' --with 'strands-agents==1.65.0' --with 'semantic-kernel==1.47.0' --with 'protobuf' python scripts/run_external_certification.py --suite a
92
+ ```
93
+
94
+ Structural tests prove artifact shape and syntax. Offline behavioral tests
95
+ execute generated helpers or validate generated protocol artifacts against
96
+ semantic contracts. External-runtime tests install and exercise the real target
97
+ SDK or runtime against deterministic fixtures. Fifteen targets are external-runtime certified and the remaining sixteen are offline-behavioral certified; see the support matrix for per-target evidence.
98
+
99
+ ## Changelog
100
+
101
+ See [CHANGELOG.md](CHANGELOG.md).
102
+
103
+ ## Adding a Target
104
+
105
+ Please refer to the [Adapter Authoring Guide](docs/adapter-authoring.md) for instructions on creating a new target generator.
106
+
107
+ ## License
108
+
109
+ MIT. See [LICENSE](LICENSE).