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,309 @@
1
+ """AWS Strands Agents target adapter — Level 1 code generation.
2
+
3
+ AWS open-source Python agent framework (2025):
4
+ - Agent class with @tool decorated functions.
5
+ - BedrockModel for model integration.
6
+ - MCPClient context manager for MCP tools.
7
+ - Inline tool definitions via @tool decorator.
8
+ """
9
+
10
+ from __future__ import annotations
11
+ from pathlib import Path
12
+
13
+ from agentsml_impl.compiler.identifiers import python_identifier_ir
14
+ from agentsml_impl.compiler.ir import AgentSystemIR, ModelIR
15
+ from agentsml_impl.compiler.diagnostics import DiagCode, DiagnosticSet
16
+ from agentsml_impl.compiler.planner import GenerationPlan
17
+ from agentsml_impl.compiler.render import toml_string, write_file
18
+ from agentsml_impl.runtime.json_schema import generate_models_source
19
+ from agentsml_impl.targets.base import TargetAdapter, GenerationResult
20
+
21
+
22
+ class Adapter(TargetAdapter):
23
+ @property
24
+ def name(self) -> str:
25
+ return "strands-agents"
26
+
27
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
28
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
29
+ analyze_capabilities(ir, self.name, diagnostics)
30
+ for mk, model in ir.models.items():
31
+ p = model.provider.lower()
32
+ if p not in ("anthropic", "bedrock", "amazon", "meta", "mistral", "ai21"):
33
+ diagnostics.add_warning(
34
+ DiagCode.LOSSY_MAPPING,
35
+ f"Model '{mk}' provider '{model.provider}' may not be natively supported in Strands. "
36
+ "Strands works best with AWS Bedrock models (Claude, Titan, Llama, etc.).",
37
+ path=f"models.{mk}.provider",
38
+ recommendation="Use provider: bedrock or anthropic for Strands Agents.",
39
+ )
40
+
41
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
42
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
43
+ ir = python_identifier_ir(ir)
44
+ out_dir.mkdir(parents=True, exist_ok=True)
45
+ files: list[str] = []
46
+ files += _write_pyproject(ir, plan, out_dir)
47
+ files += _write_schemas(ir, out_dir, diagnostics)
48
+ files += _write_tools(ir, out_dir, diagnostics)
49
+ files += _write_agent(ir, plan, out_dir, diagnostics)
50
+ files += _write_run(ir, plan, out_dir)
51
+ files += _write_readme(ir, plan, out_dir)
52
+ return GenerationResult(target=self.name, out_dir=out_dir,
53
+ files_written=files, success=True)
54
+
55
+
56
+ # ---------------------------------------------------------------------------
57
+ # Model helpers
58
+ # ---------------------------------------------------------------------------
59
+
60
+ # Bedrock model ID mapping table for common providers
61
+ _BEDROCK_MODEL_IDS = {
62
+ ("anthropic", "claude-3-5-sonnet"): "anthropic.claude-3-5-sonnet-20241022-v2:0",
63
+ ("anthropic", "claude-3-5-haiku"): "anthropic.claude-3-5-haiku-20241022-v1:0",
64
+ ("anthropic", "claude-3-opus"): "anthropic.claude-3-opus-20240229-v1:0",
65
+ ("anthropic", "claude-3-sonnet"): "anthropic.claude-3-sonnet-20240229-v1:0",
66
+ ("meta", "llama3"): "meta.llama3-8b-instruct-v1:0",
67
+ ("amazon", "titan"): "amazon.titan-text-premier-v1:0",
68
+ ("mistral", "mistral-7b"): "mistral.mistral-7b-instruct-v0:2",
69
+ }
70
+
71
+
72
+ def _bedrock_model_id(model: ModelIR) -> str:
73
+ p = model.provider.lower()
74
+ n = model.name.lower()
75
+ # Try exact lookup
76
+ exact = _BEDROCK_MODEL_IDS.get((p, n))
77
+ if exact:
78
+ return exact
79
+ # For Anthropic, try prefix match
80
+ if p == "anthropic":
81
+ return f"anthropic.{n}" if "." not in n else n
82
+ if p == "bedrock":
83
+ return n # already a Bedrock model ID
84
+ return n # pass-through
85
+
86
+
87
+ # ---------------------------------------------------------------------------
88
+ # File generators
89
+ # ---------------------------------------------------------------------------
90
+
91
+ def _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
92
+ has_mcp = any(t.is_mcp() for t in ir.tools.values())
93
+ mcp_dep = '\n "strands-agents-tools>=0.1.0",' if has_mcp else ""
94
+ c = f'''\
95
+ [build-system]
96
+ requires = ["setuptools>=68"]
97
+ build-backend = "setuptools.build_meta"
98
+
99
+ [project]
100
+ name = "{plan.package_name}"
101
+ version = "{ir.metadata.version or '0.1.0'}"
102
+ description = {toml_string(ir.metadata.description or plan.project_name)}
103
+ requires-python = ">=3.11"
104
+ dependencies = [
105
+ "strands-agents>=0.1.0",
106
+ "strands-agents-tools>=0.1.0",
107
+ "boto3>=1.34.0",
108
+ "pydantic>=2.7",
109
+ "python-dotenv",{mcp_dep}
110
+ ]
111
+
112
+ [tool.setuptools.packages.find]
113
+ where = ["."]
114
+ '''
115
+ write_file(out_dir, "pyproject.toml", c)
116
+ return ["pyproject.toml"]
117
+
118
+
119
+ def _write_schemas(ir: AgentSystemIR, out_dir: Path, ds: DiagnosticSet) -> list[str]:
120
+ schemas = {f"{k}_output": v.output_schema for k, v in ir.agents.items() if v.output_schema}
121
+ if not schemas:
122
+ return []
123
+ c = generate_models_source(schemas, ds)
124
+ write_file(out_dir, "models.py", c)
125
+ return ["models.py"]
126
+
127
+
128
+ def _write_tools(ir: AgentSystemIR, out_dir: Path, ds: DiagnosticSet) -> list[str]:
129
+ local_tools = {k: v for k, v in ir.tools.items() if not v.is_mcp()}
130
+ if not local_tools:
131
+ return []
132
+
133
+ lines = [
134
+ '"""Strands Agents tool stubs — auto-generated by agentsml-impl."""',
135
+ "from __future__ import annotations",
136
+ "from typing import Any",
137
+ "from strands import tool",
138
+ "",
139
+ ]
140
+ for k, tool_ir in local_tools.items():
141
+ desc = tool_ir.description.replace('"""', "'''")
142
+ lines.append(f'''\
143
+ @tool
144
+ def {k}(**kwargs: Any) -> Any:
145
+ """{desc}"""
146
+ # TODO: implement
147
+ raise NotImplementedError("{k}")
148
+ ''')
149
+
150
+ write_file(out_dir, "tools.py", "\n".join(lines))
151
+ return ["tools.py"]
152
+
153
+
154
+ def _write_agent(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path, ds: DiagnosticSet) -> list[str]:
155
+ wf = ir.workflows.get(plan.main_workflow_key)
156
+ steps = wf.steps if wf else []
157
+
158
+ has_mcp = any(t.is_mcp() for t in ir.tools.values())
159
+ local_tool_keys = [k for k, v in ir.tools.items() if not v.is_mcp()]
160
+ mcp_tool_keys = [k for k, v in ir.tools.items() if v.is_mcp()]
161
+
162
+ tools_import = f"from .tools import {', '.join(local_tool_keys)}" if local_tool_keys else ""
163
+ schemas_import = ("from .models import " +
164
+ ", ".join(f"{k.capitalize()}Output" for k, v in ir.agents.items() if v.output_schema)
165
+ if any(v.output_schema for v in ir.agents.values()) else "")
166
+
167
+ # MCP servers
168
+ mcp_servers: dict[str, dict] = {}
169
+ for k, tool_ir in ir.tools.items():
170
+ if tool_ir.is_mcp() and tool_ir.mcp_server:
171
+ mcp_servers[tool_ir.mcp_server] = ir.extras.get("mcp_servers", {}).get(tool_ir.mcp_server, {})
172
+
173
+ mcp_init = ""
174
+ if mcp_servers:
175
+ ds.add_info(DiagCode.REQUIRES_ADAPTER,
176
+ f"MCP tools detected. Generated MCPClient context manager stubs for: "
177
+ f"{list(mcp_servers.keys())}. Configure transport in agent.py.",
178
+ path="tools")
179
+ srv_blocks = []
180
+ for srv_key, srv_cfg in mcp_servers.items():
181
+ transport = srv_cfg.get("transport", "stdio")
182
+ if transport == "stdio":
183
+ cmd = srv_cfg.get("command", "npx")
184
+ args = srv_cfg.get("args", [])
185
+ srv_blocks.append(
186
+ f' async with MCPClient({{"command": "{cmd}", "args": {args!r}}}) as {srv_key}_mcp:'
187
+ )
188
+ else:
189
+ url = srv_cfg.get("url", "http://localhost:8080/sse")
190
+ srv_blocks.append(
191
+ f' async with MCPClient({{"url": "{url}"}}) as {srv_key}_mcp:'
192
+ )
193
+ mcp_init = "\n".join(srv_blocks)
194
+
195
+ agent_blocks: list[str] = []
196
+ for ak, agent in ir.agents.items():
197
+ model = ir.models.get(agent.model)
198
+ if model:
199
+ bedrock_id = _bedrock_model_id(model)
200
+ model_expr = f'BedrockModel(model_id="{bedrock_id}")'
201
+ else:
202
+ model_expr = 'BedrockModel(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0")'
203
+
204
+ sys_prompt = agent.instructions.replace('"""', "'''")
205
+ tools_list_parts = [t for t in agent.tools if t in local_tool_keys]
206
+ tools_list = f"[{', '.join(tools_list_parts)}]" if tools_list_parts else "[]"
207
+
208
+ agent_blocks.append(f'''\
209
+ {ak}_agent = Agent(
210
+ model={model_expr},
211
+ system_prompt="""{sys_prompt}""",
212
+ tools={tools_list},
213
+ )''')
214
+
215
+ c = f'''\
216
+ """Strands Agents definitions for {plan.project_name}.
217
+
218
+ Auto-generated by agentsml-impl. Re-run to regenerate.
219
+ """
220
+ from __future__ import annotations
221
+ from strands import Agent
222
+ from strands.models import BedrockModel
223
+ {"from strands.tools.mcp import MCPClient" if has_mcp else ""}
224
+ {tools_import}
225
+ {schemas_import}
226
+
227
+ # ── Agent definitions ─────────────────────────────────────────────────────────
228
+ {chr(10).join(agent_blocks)}
229
+ '''
230
+ write_file(out_dir, "agent.py", c)
231
+ return ["agent.py"]
232
+
233
+
234
+ def _write_run(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
235
+ primary = next(iter(ir.agents.keys()), None)
236
+ agent_ref = f"{primary}_agent" if primary else "agent"
237
+
238
+ c = f'''\
239
+ """Runner for {plan.project_name} (Strands Agents). Auto-generated."""
240
+ from __future__ import annotations
241
+ import sys
242
+ from .agent import {agent_ref}
243
+
244
+
245
+ def main() -> None:
246
+ q = " ".join(sys.argv[1:]) or "Hello!"
247
+ # Strands Agent is synchronous by default
248
+ result = {agent_ref}(q)
249
+ print(result)
250
+
251
+
252
+ if __name__ == "__main__":
253
+ main()
254
+ '''
255
+ write_file(out_dir, "run.py", c)
256
+ return ["run.py"]
257
+
258
+
259
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
260
+ agents_md = "\n".join(f"- `{k}`: {v.description or ''}" for k, v in ir.agents.items())
261
+ has_mcp = any(t.is_mcp() for t in ir.tools.values())
262
+ mcp_note = ""
263
+ if has_mcp:
264
+ mcp_note = """
265
+ ## MCP Tools
266
+
267
+ MCP tools use `MCPClient` as a context manager:
268
+ ```python
269
+ from strands.tools.mcp import MCPClient
270
+ async with MCPClient({"command": "npx", "args": ["-y", "@my/mcp-server"]}) as mcp:
271
+ agent = Agent(tools=mcp.list_tools_sync(), ...)
272
+ ```
273
+ """
274
+
275
+ c = f"""\
276
+ # {plan.project_name} — AWS Strands Agents
277
+
278
+ > Auto-generated by `agentsml-impl`.
279
+
280
+ ## Agents
281
+ {agents_md or "None"}
282
+
283
+ ## Architecture
284
+
285
+ Uses AWS Strands Agents open-source SDK:
286
+ - `Agent` class with `BedrockModel` for AWS model integration.
287
+ - `@tool` decorator for inline tool definitions.
288
+ - `MCPClient` context manager for MCP server integration.
289
+ {mcp_note}
290
+ ## Quickstart
291
+ ```bash
292
+ pip install -e .
293
+ # Configure AWS credentials (aws configure or env vars)
294
+ export AWS_DEFAULT_REGION=us-east-1
295
+ python run.py "Your question here"
296
+ ```
297
+
298
+ ## Multi-agent
299
+ For multi-agent, use a tool-calling agent that calls sub-agents via `@tool`:
300
+ ```python
301
+ @tool
302
+ def delegate_to_{next(iter(ir.agents.keys()), "sub")}(query: str) -> str:
303
+ return str(sub_agent(query))
304
+ ```
305
+
306
+ > See `diagnostics.yaml` for portability warnings.
307
+ """
308
+ write_file(out_dir, "README.md", c)
309
+ return ["README.md"]
@@ -0,0 +1,29 @@
1
+ target: strands_agents
2
+ kind: code
3
+ language: python
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "0.1.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: unsupported
16
+ mcp: manual
17
+ a2a: unsupported
18
+ ag_ui: unsupported
19
+ structured_output: unsupported
20
+ observability: unsupported
21
+ artifacts:
22
+ - python_project
23
+ - diagnostics
24
+ - readme
25
+ notes: >
26
+ Strands Agents maps directly to Python Agent definitions with @tool functions
27
+ and BedrockModel selection. The adapter documents MCPClient configuration but
28
+ does not wire MCP tools into generated agents. Multi-agent delegation stays
29
+ programmatic, so workflow and graph semantics are lossy.
@@ -0,0 +1,91 @@
1
+ """Render docs/target-support.md from the target registry and capability manifests."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ from agentsml_impl.compiler.capabilities import _capabilities_path, load_capabilities
8
+ from agentsml_impl.targets.registry import ALL_TARGETS
9
+
10
+ DOC_PATH = Path(__file__).resolve().parents[3] / "docs" / "target-support.md"
11
+
12
+ WAVE_HEADINGS: dict[int, str] = {
13
+ 1: "Core Python frameworks",
14
+ 2: "Extended code-first SDKs",
15
+ 3: "Cloud / managed platforms",
16
+ 4: "Low-code / visual platforms",
17
+ 5: "Agentic protocols",
18
+ }
19
+
20
+ _INTRO_PARAGRAPH = (
21
+ "`Maturity` is the primary implementation-status claim: `runnable`, `export`, or `scaffold`. "
22
+ "`Certification` is a separate claim about how far the target has been verified: `structural`, "
23
+ "`offline-behavioral`, or `external-runtime`. `Registry level` is retained for compatibility and "
24
+ "does not imply maturity. `Capability manifest` shows whether a target-specific "
25
+ "`capabilities.yaml` exists."
26
+ )
27
+
28
+ # The offline-behavioral and external-runtime notes are curated prose (grouping and per-target
29
+ # verification detail) and are kept as literal text; the registry validates membership elsewhere.
30
+ _NOTES = """\
31
+ > Notes:
32
+ > - `runnable` means the generator emits an executable project path, but does not yet imply certified semantic conformance.
33
+ > - `export` means the target emits an importable manifest or configuration artifact.
34
+ > - `scaffold` means generated output contains placeholders and is not claimed as runnable.
35
+ > - `structural` means the claim is based on registry shape, static analysis, or generated-file presence, not on end-to-end execution evidence.
36
+ > - `offline-behavioral` means the target can be checked deterministically against fixtures without a live vendor runtime; applies to protocol exports and bridges (`a2a`, `ucp`, `ap2`, `mcp-server`, `ag-ui`) and low-code/visual platform exports (`n8n`, `langflow`, `flowise`, `relevance-ai`, `zapier-agents`, `lyzr`), and cloud deployment-artifact targets (`bedrock-agentcore`, `vertex-agent-engine`, `databricks`) whose generated code, CloudFormation/bundle YAML, and gateway JSON are checked by deterministic deployment-artifact contract tests without cloud access.
37
+ > - `external-runtime` means the target is verified against the real SDK or managed runtime; today that applies to `pydantic-ai` via deterministic `TestModel` certification, `langgraph` via a deterministic fake chat model run through the real LangGraph `StateGraph`, `google-adk` via a deterministic scripted `BaseLlm` run through the real ADK `Runner`, `openai-agents` via real Swarm execution and mock OpenAI client, `smolagents` via real `ToolCallingAgent` and deterministic `Model`, `claude-agent-sdk` via real Anthropic Message structures and mock client, `crewai` via real Crew and Task execution, `llamaindex` via real AgentWorkflow execution, `ag2` via real AG2 A2A client/server execution, `agno` via real Agno Agent execution, and `mastra` & `vercel-ai` via deterministic Node.js TypeScript execution.
38
+ > - `present` means a target-specific `capabilities.yaml` exists in `src/agentsml_impl/targets/`.
39
+ > - `Graph edges` and `Graph conditions` are read from each target's `capabilities.yaml`. `native` means the generated code implements it, `manual` means the user must wire it up, `lossy` means the workflow is flattened to step order, and `unsupported` means the target cannot express it.
40
+ > - Registry levels are the support tiers used by the public docs; they are intentionally separate from the manifest `level` field.
41
+ """
42
+
43
+ _TABLE_HEADER = (
44
+ "| Target | Language | Maturity | Certification | Registry level | Graph edges | Graph conditions | Capability manifest |\n"
45
+ "|--------|----------|----------|---------------|----------------|--------------|------------------|---------------------|"
46
+ )
47
+
48
+
49
+ def _count(key: str, value: str) -> int:
50
+ return sum(1 for t in ALL_TARGETS if t[key] == value)
51
+
52
+
53
+ def render_matrix() -> str:
54
+ total = len(ALL_TARGETS)
55
+ with_manifest = sum(1 for t in ALL_TARGETS if _capabilities_path(t["name"]).exists())
56
+ manifest_line = (
57
+ f"- All {total} registered targets have a `capabilities.yaml` manifest."
58
+ if with_manifest == total
59
+ else f"- {with_manifest} of {total} registered targets have a `capabilities.yaml` manifest."
60
+ )
61
+ lines = [
62
+ "# Target Support Matrix",
63
+ "",
64
+ "This matrix follows the canonical target registry in `src/agentsml_impl/targets/registry.py`.",
65
+ "",
66
+ f"- {total} targets are registered in total.",
67
+ f"- {_count('maturity', 'runnable')} targets generate runnable projects.",
68
+ f"- {_count('maturity', 'export')} targets generate importable/configuration exports.",
69
+ f"- {_count('maturity', 'scaffold')} targets generate scaffolds that still require implementation work.",
70
+ f"- {_count('level', 1)} targets are at registry level `1`.",
71
+ f"- {_count('level', 0)} targets are at registry level `0`.",
72
+ manifest_line,
73
+ f"- {_count('certification', 'structural')} targets are certified as `structural`.",
74
+ f"- {_count('certification', 'offline-behavioral')} targets are certified as `offline-behavioral`.",
75
+ f"- {_count('certification', 'external-runtime')} targets are certified as `external-runtime`.",
76
+ "",
77
+ _INTRO_PARAGRAPH,
78
+ ]
79
+ for wave, heading in WAVE_HEADINGS.items():
80
+ lines += ["", f"## {heading}", "", _TABLE_HEADER]
81
+ for t in (t for t in ALL_TARGETS if t["wave"] == wave):
82
+ caps = load_capabilities(t["name"])
83
+ supports = caps.get("supports", {})
84
+ edges = supports.get("graph_edges", "unsupported")
85
+ conds = supports.get("graph_conditions", "unsupported")
86
+ present = "present" if caps else "missing"
87
+ lines.append(
88
+ f"| `{t['name']}` | {t['language']} | {t['maturity']} | {t['certification']} "
89
+ f"| {t['level']} | {edges} | {conds} | {present} |"
90
+ )
91
+ return "\n".join(lines) + "\n\n" + _NOTES
File without changes
@@ -0,0 +1,86 @@
1
+ """UCP target adapter — Level 1 code generation."""
2
+
3
+ from __future__ import annotations
4
+ from pathlib import Path
5
+ import json
6
+
7
+ from agentsml_impl.compiler.ir import AgentSystemIR
8
+ from agentsml_impl.compiler.diagnostics import 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 "ucp"
18
+
19
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
20
+ pass
21
+
22
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
23
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
24
+ out_dir.mkdir(parents=True, exist_ok=True)
25
+
26
+ files: list[str] = []
27
+ files += _write_ucp(ir, plan, out_dir)
28
+ files += _write_readme(ir, plan, out_dir)
29
+
30
+ return GenerationResult(
31
+ target=self.name, out_dir=out_dir, files_written=files, success=True
32
+ )
33
+
34
+
35
+ def _payment_currencies(ir: AgentSystemIR) -> list[str]:
36
+ currencies: set[str] = set()
37
+ for tool in ir.tools.values():
38
+ if tool.side_effect != "payment" or not tool.input_schema:
39
+ continue
40
+ properties = tool.input_schema.get("properties", {})
41
+ currency = properties.get("currency")
42
+ if not isinstance(currency, dict):
43
+ continue
44
+ if isinstance(currency.get("const"), str):
45
+ currencies.add(currency["const"])
46
+ enum = currency.get("enum")
47
+ if isinstance(enum, list):
48
+ currencies.update(value for value in enum if isinstance(value, str))
49
+ if isinstance(currency.get("default"), str):
50
+ currencies.add(currency["default"])
51
+ return sorted(currencies)
52
+
53
+
54
+ def _write_ucp(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
55
+ # Determine commerce capabilities based on tools
56
+ payment_tools = [tool.key for tool in ir.tools.values() if tool.side_effect == "payment"]
57
+ currencies = _payment_currencies(ir)
58
+
59
+ ucp_card = {
60
+ "profile": "Universal Commerce Profile",
61
+ "version": "1.0",
62
+ "entity": plan.project_name,
63
+ "capabilities": {
64
+ "payments_enabled": bool(payment_tools),
65
+ "payment_tools": payment_tools,
66
+ "supported_currencies": currencies,
67
+ }
68
+ }
69
+
70
+ rel = "ucp.json"
71
+ write_file(out_dir, rel, json.dumps(ucp_card, indent=2))
72
+ return [rel]
73
+
74
+
75
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
76
+ c = f"""\
77
+ # {plan.project_name} — UCP Export
78
+
79
+ Generated by `agentsml-impl`.
80
+
81
+ ## Universal Commerce Profile
82
+ The `ucp.json` file is a UCP capability descriptor.
83
+ Host this at `/.well-known/ucp.json`.
84
+ """
85
+ write_file(out_dir, "README.md", c)
86
+ return ["README.md"]
@@ -0,0 +1,25 @@
1
+ target: ucp
2
+ kind: protocol
3
+ language: json
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "1.0.0"
7
+ supports:
8
+ agents: unsupported
9
+ tools: unsupported
10
+ workflows: unsupported
11
+ graph_edges: unsupported
12
+ graph_conditions: unsupported
13
+ cycles: unsupported
14
+ parallel: unsupported
15
+ human_approval: unsupported
16
+ mcp: unsupported
17
+ a2a: unsupported
18
+ ag_ui: unsupported
19
+ structured_output: unsupported
20
+ observability: unsupported
21
+ artifacts:
22
+ - json_export
23
+ - readme
24
+ notes: >
25
+ Generates a Universal Commerce Profile descriptor.
@@ -0,0 +1 @@
1
+ """Target: vercel_ai."""