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,37 @@
1
+ target: pydantic_ai
2
+ kind: code
3
+ language: python
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "1.107.0"
7
+ supports:
8
+ agents: native
9
+ tools: native
10
+ workflows: adapter
11
+ graph_edges: native
12
+ graph_conditions: native
13
+ cycles: lossy
14
+ parallel: lossy
15
+ human_approval: manual
16
+ mcp: native
17
+ a2a: adapter
18
+ ag_ui: adapter
19
+ structured_output: native
20
+ retry: lossy
21
+ reasoning: native
22
+ observability: native
23
+ artifacts:
24
+ - python_project
25
+ - diagnostics
26
+ - readme
27
+ notes: >
28
+ PydanticAI maps AgentsML agents to typed Agents with result_type Pydantic models.
29
+ Tools map to @agent.tool decorated async functions. Structured output is native via
30
+ result_type. MCP supported via MCPServerStdio/MCPServerHTTP. Human approval via
31
+ deferred tools. Long-term memory requires adapter. Observability via Logfire or
32
+ OpenTelemetry.
33
+ Multi-agent workflows compile to a pydantic_graph decision graph
34
+ (GraphBuilder + BaseNode) whose edges follow the workflow edges and whose edge
35
+ conditions are compiled into predicates evaluated at runtime; certified against
36
+ pydantic-ai==1.107.0. The decision graph hands control to one successor, so
37
+ parallel fan-out, joins and cycles are lossy and are reported at compile time.
@@ -0,0 +1,290 @@
1
+ """BOOT-003: Target Registry — canonical target names and adapter loading."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional, TypedDict
6
+
7
+ TargetMaturity = str
8
+ TargetCertification = str
9
+ _VALID_MATURITIES: frozenset[str] = frozenset({"runnable", "export", "scaffold"})
10
+ _VALID_CERTIFICATIONS: frozenset[str] = frozenset({"structural", "offline-behavioral", "external-runtime"})
11
+ _OFFLINE_BEHAVIORAL_TARGETS: frozenset[str] = frozenset(
12
+ {
13
+ "a2a",
14
+ "ucp",
15
+ "ap2",
16
+ "n8n",
17
+ "langflow",
18
+ "flowise",
19
+ "relevance-ai",
20
+ "zapier-agents",
21
+ "lyzr",
22
+ "mcp-server",
23
+ "ag-ui",
24
+ "vertex-agent-engine",
25
+ "bedrock-agentcore",
26
+ "databricks",
27
+ "spring-ai",
28
+ "snowflake-cortex",
29
+ }
30
+ )
31
+ _EXTERNAL_RUNTIME_TARGETS: frozenset[str] = frozenset(
32
+ {
33
+ "google-adk",
34
+ "langgraph",
35
+ "pydantic-ai",
36
+ "openai-agents",
37
+ "smolagents",
38
+ "claude-agent-sdk",
39
+ "crewai",
40
+ "llamaindex",
41
+ "ag2",
42
+ "agno",
43
+ "mastra",
44
+ "vercel-ai",
45
+ "langchain",
46
+ "strands-agents",
47
+ "microsoft-agent-framework",
48
+ }
49
+ )
50
+
51
+
52
+ class TargetInfo(TypedDict, total=False):
53
+ name: str
54
+ language: str
55
+ wave: int
56
+ level: int
57
+ maturity: TargetMaturity
58
+ certification: TargetCertification
59
+
60
+
61
+ def _target(
62
+ name: str,
63
+ language: str,
64
+ wave: int,
65
+ level: int,
66
+ maturity: TargetMaturity,
67
+ certification: TargetCertification = "structural",
68
+ ) -> TargetInfo:
69
+ return {
70
+ "name": name,
71
+ "language": language,
72
+ "wave": wave,
73
+ "level": level,
74
+ "maturity": maturity,
75
+ "certification": certification,
76
+ }
77
+
78
+
79
+ # Canonical target names (matches directory names with hyphens as display form)
80
+ ALL_TARGETS: list[TargetInfo] = [
81
+ # Wave 1 — Core Python frameworks (Level 1 codegen)
82
+ _target("langgraph", "python", 1, 1, "runnable", "external-runtime"),
83
+ _target("google-adk", "python", 1, 1, "runnable", "external-runtime"),
84
+ _target("pydantic-ai", "python", 1, 1, "runnable", "external-runtime"),
85
+ _target("openai-agents", "python", 1, 1, "runnable", "external-runtime"),
86
+ # Wave 2 — Extended code-first SDKs (Level 1 codegen)
87
+ _target("crewai", "python", 2, 1, "runnable", "external-runtime"),
88
+ _target("smolagents", "python", 2, 1, "runnable", "external-runtime"),
89
+ _target("claude-agent-sdk", "python", 2, 1, "runnable", "external-runtime"),
90
+ _target("ag2", "python", 2, 1, "runnable", "external-runtime"),
91
+ _target("agno", "python", 2, 1, "runnable", "external-runtime"),
92
+ _target("mastra", "typescript", 2, 1, "runnable", "external-runtime"),
93
+ _target("llamaindex", "python", 2, 1, "runnable", "external-runtime"),
94
+ _target("langchain", "python", 2, 1, "runnable", "external-runtime"),
95
+ _target("vercel-ai", "typescript", 2, 1, "runnable", "external-runtime"),
96
+ _target("strands-agents", "python", 2, 1, "runnable", "external-runtime"),
97
+ # Wave 3 — Cloud / Managed Platforms
98
+ _target("microsoft-agent-framework", "python", 3, 1, "runnable", "external-runtime"),
99
+ _target("vertex-agent-engine", "python", 3, 1, "runnable", "offline-behavioral"),
100
+ _target("bedrock-agentcore", "python", 3, 1, "runnable", "offline-behavioral"),
101
+ _target("databricks", "python", 3, 1, "runnable", "offline-behavioral"),
102
+ _target("snowflake-cortex", "yaml/sql", 3, 0, "runnable", "offline-behavioral"),
103
+ _target("spring-ai", "java", 3, 1, "runnable", "offline-behavioral"),
104
+ # Wave 4 — Low-code / Visual platforms
105
+ _target("n8n", "json", 4, 0, "export", "offline-behavioral"),
106
+ _target("langflow", "json", 4, 0, "export", "offline-behavioral"),
107
+ _target("flowise", "json", 4, 0, "export", "offline-behavioral"),
108
+ _target("relevance-ai", "json", 4, 0, "export", "offline-behavioral"),
109
+ _target("zapier-agents", "markdown", 4, 0, "export", "offline-behavioral"),
110
+ _target("lyzr", "json", 4, 0, "export", "offline-behavioral"),
111
+ # Wave 5 — Agentic protocols
112
+ _target("mcp-server", "python", 5, 1, "runnable", "offline-behavioral"),
113
+ _target("a2a", "json", 5, 1, "export", "offline-behavioral"),
114
+ _target("ag-ui", "python", 5, 1, "runnable", "offline-behavioral"),
115
+ _target("ucp", "json", 5, 1, "export", "offline-behavioral"),
116
+ _target("ap2", "json", 5, 1, "export", "offline-behavioral"),
117
+ ]
118
+
119
+ _TARGET_MAP: dict[str, TargetInfo] = {t["name"]: t for t in ALL_TARGETS}
120
+
121
+
122
+ def _validate_maturity(value: str) -> TargetMaturity:
123
+ if value not in _VALID_MATURITIES:
124
+ allowed = ", ".join(sorted(_VALID_MATURITIES))
125
+ raise ValueError(f"Unsupported target maturity {value!r}; expected one of {allowed}.")
126
+ return value
127
+
128
+
129
+ def _validate_certification(value: str) -> TargetCertification:
130
+ if value not in _VALID_CERTIFICATIONS:
131
+ allowed = ", ".join(sorted(_VALID_CERTIFICATIONS))
132
+ raise ValueError(f"Unsupported target certification {value!r}; expected one of {allowed}.")
133
+ return value
134
+
135
+
136
+ def _normalized_target(name: str) -> TargetInfo:
137
+ target = _TARGET_MAP.get(name)
138
+ if target is None:
139
+ return {
140
+ "name": name,
141
+ "language": "unknown",
142
+ "wave": 0,
143
+ "level": 0,
144
+ "maturity": "scaffold",
145
+ "certification": "structural",
146
+ }
147
+
148
+ maturity = _validate_maturity(target.get("maturity", "scaffold"))
149
+ certification = _validate_certification(target.get("certification", "structural"))
150
+ normalized: TargetInfo = dict(target)
151
+ normalized["maturity"] = maturity
152
+ normalized["certification"] = certification
153
+ return normalized
154
+
155
+
156
+ def validate_registry() -> None:
157
+ """Raise ValueError if the registry contains duplicate or malformed entries."""
158
+ seen: set[str] = set()
159
+ problems: list[str] = []
160
+
161
+ for target in ALL_TARGETS:
162
+ name = target.get("name")
163
+ if not name:
164
+ problems.append("target entry is missing a name")
165
+ continue
166
+ if name in seen:
167
+ problems.append(f"duplicate target name: {name}")
168
+ seen.add(name)
169
+
170
+ level = target.get("level")
171
+ if level not in (0, 1):
172
+ problems.append(f"target {name!r} has invalid level {level!r}; expected 0 or 1")
173
+
174
+ maturity = target.get("maturity")
175
+ if maturity is None:
176
+ problems.append(f"target {name!r} is missing maturity")
177
+ elif maturity not in _VALID_MATURITIES:
178
+ problems.append(
179
+ f"target {name!r} has invalid maturity {maturity!r}; expected one of "
180
+ f"{', '.join(sorted(_VALID_MATURITIES))}"
181
+ )
182
+
183
+ certification = target.get("certification")
184
+ if certification is None:
185
+ problems.append(f"target {name!r} is missing certification")
186
+ elif certification not in _VALID_CERTIFICATIONS:
187
+ problems.append(
188
+ f"target {name!r} has invalid certification {certification!r}; expected one of "
189
+ f"{', '.join(sorted(_VALID_CERTIFICATIONS))}"
190
+ )
191
+ elif certification == "offline-behavioral":
192
+ if maturity not in ("export", "runnable"):
193
+ problems.append(
194
+ f"target {name!r} is marked offline-behavioral but has invalid maturity {maturity!r}"
195
+ )
196
+ if name not in _OFFLINE_BEHAVIORAL_TARGETS:
197
+ problems.append(
198
+ f"target {name!r} is marked offline-behavioral but is not one of "
199
+ f"{', '.join(sorted(_OFFLINE_BEHAVIORAL_TARGETS))}"
200
+ )
201
+ elif certification == "external-runtime":
202
+ if maturity != "runnable":
203
+ problems.append(
204
+ f"target {name!r} is marked external-runtime but is not runnable"
205
+ )
206
+ if name not in _EXTERNAL_RUNTIME_TARGETS:
207
+ problems.append(
208
+ f"target {name!r} is marked external-runtime but is not one of "
209
+ f"{', '.join(sorted(_EXTERNAL_RUNTIME_TARGETS))}"
210
+ )
211
+ elif name in _OFFLINE_BEHAVIORAL_TARGETS and certification != "offline-behavioral":
212
+ problems.append(
213
+ f"target {name!r} should be marked offline-behavioral to reflect deterministic protocol exports"
214
+ )
215
+ elif name in _EXTERNAL_RUNTIME_TARGETS and certification != "external-runtime":
216
+ problems.append(
217
+ f"target {name!r} should be marked external-runtime to reflect verified live-runtime execution"
218
+ )
219
+
220
+ if len(_TARGET_MAP) != len(ALL_TARGETS):
221
+ problems.append("registry map size does not match target list size")
222
+
223
+ if problems:
224
+ raise ValueError("Invalid AgentsML target registry: " + "; ".join(problems))
225
+
226
+
227
+ def list_targets(
228
+ maturity: Optional[TargetMaturity] = None,
229
+ certification: Optional[TargetCertification] = None,
230
+ ) -> list[dict]:
231
+ """Return all registered targets, optionally filtered by maturity and certification."""
232
+ if maturity is not None:
233
+ maturity = _validate_maturity(maturity)
234
+ if certification is not None:
235
+ certification = _validate_certification(certification)
236
+
237
+ targets = ALL_TARGETS
238
+ if maturity is not None:
239
+ targets = [t for t in targets if t["maturity"] == maturity]
240
+ if certification is not None:
241
+ targets = [t for t in targets if t["certification"] == certification]
242
+ return [dict(t) for t in targets]
243
+
244
+
245
+ def get_target(name: str) -> Optional[dict]:
246
+ """Return target info dict or None if not found."""
247
+ target = _TARGET_MAP.get(name)
248
+ return dict(target) if target is not None else None
249
+
250
+
251
+ def get_target_maturity(name: str) -> TargetMaturity:
252
+ """Return the canonical maturity for a target, defaulting to scaffold for unknown targets."""
253
+ return _normalized_target(name)["maturity"]
254
+
255
+
256
+ def get_target_certification_status(name: str) -> TargetCertification:
257
+ """Return the canonical certification status for a target, defaulting to structural."""
258
+ return _normalized_target(name)["certification"]
259
+
260
+
261
+ def is_runnable_target(name: str) -> bool:
262
+ return get_target_maturity(name) == "runnable"
263
+
264
+
265
+ def is_export_target(name: str) -> bool:
266
+ return get_target_maturity(name) == "export"
267
+
268
+
269
+ def is_scaffold_target(name: str) -> bool:
270
+ return get_target_maturity(name) == "scaffold"
271
+
272
+
273
+ def is_structural_target(name: str) -> bool:
274
+ return get_target_certification_status(name) == "structural"
275
+
276
+
277
+ def is_offline_behavioral_target(name: str) -> bool:
278
+ return get_target_certification_status(name) == "offline-behavioral"
279
+
280
+
281
+ def is_external_runtime_target(name: str) -> bool:
282
+ return get_target_certification_status(name) == "external-runtime"
283
+
284
+
285
+ def target_dir_name(name: str) -> str:
286
+ """Convert a hyphen-separated target name to an underscore directory name."""
287
+ return name.replace("-", "_")
288
+
289
+
290
+ validate_registry()
File without changes
@@ -0,0 +1,66 @@
1
+ """Relevance AI 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 "relevance-ai"
18
+
19
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
20
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
21
+ analyze_capabilities(ir, "relevance_ai", diagnostics)
22
+
23
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
24
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
25
+ out_dir.mkdir(parents=True, exist_ok=True)
26
+
27
+ files: list[str] = []
28
+ files += _write_relevance_json(ir, plan, out_dir)
29
+ files += _write_readme(ir, plan, out_dir)
30
+
31
+ return GenerationResult(
32
+ target=self.name, out_dir=out_dir, files_written=files, success=True
33
+ )
34
+
35
+
36
+ def _write_relevance_json(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
37
+ agents = []
38
+ for ak, agent in ir.agents.items():
39
+ agents.append({
40
+ "name": ak,
41
+ "prompt": agent.instructions,
42
+ "model": agent.model or "gpt-4o"
43
+ })
44
+
45
+ export = {
46
+ "title": plan.project_name,
47
+ "agents": agents
48
+ }
49
+
50
+ c = json.dumps(export, indent=2)
51
+ rel = "relevance.json"
52
+ write_file(out_dir, rel, c)
53
+ return [rel]
54
+
55
+
56
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
57
+ c = f"""\
58
+ # {plan.project_name} — Relevance AI
59
+
60
+ Generated by `agentsml-impl`.
61
+
62
+ ## Quickstart
63
+ Import `relevance.json` into your Relevance AI workspace.
64
+ """
65
+ write_file(out_dir, "README.md", c)
66
+ return ["README.md"]
@@ -0,0 +1,26 @@
1
+ target: relevance_ai
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: native
11
+ graph_edges: lossy
12
+ graph_conditions: lossy
13
+ cycles: unsupported
14
+ parallel: native
15
+ human_approval: adapter
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 Relevance AI JSON workflow.
File without changes
@@ -0,0 +1,210 @@
1
+ """smolagents target adapter — Level 1 code generation."""
2
+
3
+ from __future__ import annotations
4
+ from pathlib import Path
5
+
6
+ from agentsml_impl.compiler.identifiers import python_identifier_ir
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 toml_string, write_file
11
+ from agentsml_impl.runtime.tools import generate_tools_module
12
+ from agentsml_impl.targets.base import TargetAdapter, GenerationResult
13
+
14
+
15
+ class Adapter(TargetAdapter):
16
+ @property
17
+ def name(self) -> str:
18
+ return "smolagents"
19
+
20
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
21
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
22
+ analyze_capabilities(ir, self.name, diagnostics)
23
+
24
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
25
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
26
+ ir = python_identifier_ir(ir)
27
+ out_dir.mkdir(parents=True, exist_ok=True)
28
+ pkg = plan.package_name
29
+ src = out_dir / "src" / pkg
30
+ src.mkdir(parents=True, exist_ok=True)
31
+
32
+ files: list[str] = []
33
+ files += _write_pyproject(ir, plan, out_dir)
34
+ files += _write_tools(ir, src, out_dir, diagnostics)
35
+ files += _write_agent(ir, plan, src, out_dir, diagnostics)
36
+ files += _write_run(plan, src, out_dir)
37
+ files += _write_init(src, out_dir)
38
+ files += _write_readme(ir, plan, out_dir)
39
+
40
+ return GenerationResult(
41
+ target=self.name, out_dir=out_dir, files_written=files, success=True
42
+ )
43
+
44
+
45
+ def _model_str(model: ModelIR) -> str:
46
+ p = model.provider.lower()
47
+ n = model.name
48
+ if p == "huggingface":
49
+ return f'HfApiModel("{n}")'
50
+ elif p == "openai":
51
+ return f'OpenAIModel("{n}")'
52
+ return f'LiteLLMModel("{p}/{n}")'
53
+
54
+
55
+ def _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
56
+ c = f'''\
57
+ [build-system]
58
+ requires = ["setuptools>=68"]
59
+ build-backend = "setuptools.build_meta"
60
+
61
+ [project]
62
+ name = "{plan.package_name}"
63
+ version = "{ir.metadata.version or '0.1.0'}"
64
+ description = {toml_string(ir.metadata.description or plan.project_name)}
65
+ requires-python = ">=3.11"
66
+ dependencies = [
67
+ "smolagents",
68
+ "litellm",
69
+ "python-dotenv",
70
+ "gradio"
71
+ ]
72
+
73
+ [tool.setuptools.packages.find]
74
+ where = ["src"]
75
+ '''
76
+ write_file(out_dir, "pyproject.toml", c)
77
+ return ["pyproject.toml"]
78
+
79
+
80
+ def _write_tools(ir: AgentSystemIR, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
81
+ if not ir.tools:
82
+ return []
83
+ c = generate_tools_module(ir.tools, ds, framework="smolagents", decorator="tool")
84
+ c = c.replace("from typing import Any", "from typing import Any\nfrom smolagents import tool")
85
+ rel = f"src/{src.name}/tools.py"
86
+ write_file(out_dir, rel, c)
87
+ return [rel]
88
+
89
+
90
+ def _write_agent(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
91
+ agent_blocks: list[str] = []
92
+
93
+ tools_import = f"from .tools import {', '.join(ir.tools.keys())}" if ir.tools else ""
94
+
95
+ for ak, agent in ir.agents.items():
96
+ m = ir.models.get(agent.model)
97
+ mstr = _model_str(m) if m else 'LiteLLMModel("openai/gpt-4o")'
98
+ inst = agent.instructions.replace('"""', "'''")
99
+ tools_list = ", ".join(agent.tools) if agent.tools else ""
100
+
101
+ # Check security sandbox
102
+ executor_str = ""
103
+ sec = getattr(agent, "security", None)
104
+ sandbox_type = getattr(sec, "sandbox", None) if sec else None
105
+ if sandbox_type == "e2b":
106
+ executor_str = ", code_executor=E2BExecutor()"
107
+ elif sandbox_type == "docker":
108
+ executor_str = ", code_executor=DockerExecutor()"
109
+ elif sandbox_type == "local":
110
+ executor_str = ", code_executor=LocalPythonExecutor()"
111
+
112
+ agent_blocks.append(f'''\
113
+ {ak}_agent = ToolCallingAgent(
114
+ tools=[{tools_list}],
115
+ model={mstr},
116
+ instructions="""{inst}"""{executor_str}
117
+ )''')
118
+
119
+ wf = ir.workflows.get(plan.main_workflow_key)
120
+ if wf and wf.edges:
121
+ ds.add_warning(
122
+ DiagCode.LOSSY_MAPPING,
123
+ "Workflow edges are mapped as manual code executions. Please implement in the runner.",
124
+ path=f"workflows.{plan.main_workflow_key}.edges"
125
+ )
126
+
127
+ c = f'''\
128
+ """smolagents definitions for {plan.project_name}."""
129
+ from __future__ import annotations
130
+ from smolagents import ToolCallingAgent, CodeAgent, LiteLLMModel, OpenAIModel
131
+ try:
132
+ from smolagents import HfApiModel
133
+ except ImportError:
134
+ try:
135
+ from smolagents import InferenceClientModel as HfApiModel
136
+ except ImportError:
137
+ pass
138
+ try:
139
+ from smolagents import LocalPythonExecutor
140
+ except ImportError:
141
+ pass
142
+ try:
143
+ from smolagents import E2BExecutor, DockerExecutor
144
+ except ImportError:
145
+ pass
146
+ {tools_import}
147
+
148
+ {chr(10).join(agent_blocks)}
149
+ '''
150
+ rel = f"src/{src.name}/agent.py"
151
+ write_file(out_dir, rel, c)
152
+ return [rel]
153
+
154
+
155
+ def _write_run(plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
156
+ c = f'''\
157
+ """Runner for {plan.project_name} (smolagents)."""
158
+ from __future__ import annotations
159
+ import sys
160
+ from .agent import *
161
+
162
+ def main():
163
+ # If Gradio UI mode is requested via CLI argument or profile
164
+ if "--ui" in sys.argv:
165
+ from smolagents import GradioUI
166
+ agents = [v for k, v in globals().items() if k.endswith("_agent")]
167
+ start_agent = agents[0] if agents else None
168
+ if start_agent:
169
+ print("Launching Gradio UI...")
170
+ GradioUI(start_agent).launch()
171
+ return
172
+
173
+ q = " ".join(sys.argv[1:]) or "Hello"
174
+ # Find the first agent defined to start
175
+ agents = [v for k, v in globals().items() if k.endswith("_agent")]
176
+ start_agent = agents[0] if agents else None
177
+ if not start_agent:
178
+ print("No agents found.")
179
+ return
180
+
181
+ response = start_agent.run(q)
182
+ print("Result:", response)
183
+
184
+ if __name__ == "__main__":
185
+ main()
186
+ '''
187
+ rel = f"src/{src.name}/run.py"
188
+ write_file(out_dir, rel, c)
189
+ return [rel]
190
+
191
+ def _write_init(src: Path, out_dir: Path) -> list[str]:
192
+ c = f'"""Package: {src.name}."""\n'
193
+ rel = f"src/{src.name}/__init__.py"
194
+ write_file(out_dir, rel, c)
195
+ return [rel]
196
+
197
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
198
+ c = f"""\
199
+ # {plan.project_name} — smolagents
200
+
201
+ Generated by `agentsml-impl`.
202
+
203
+ ## Quickstart
204
+ ```bash
205
+ pip install -e .
206
+ python -m {plan.package_name}.run
207
+ ```
208
+ """
209
+ write_file(out_dir, "README.md", c)
210
+ return ["README.md"]
@@ -0,0 +1,27 @@
1
+ target: smolagents
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: unsupported
19
+ structured_output: manual
20
+ observability: adapter
21
+ artifacts:
22
+ - python_project
23
+ - diagnostics
24
+ - readme
25
+ notes: >
26
+ Maps to Hugging Face smolagents (CodeAgent/ToolCallingAgent).
27
+ Workflows map to a MultiStepAgent. Edges and cycles emit lossy warnings.
File without changes