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,139 @@
1
+ """n8n target adapter — Level 1 code generation (JSON export)."""
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 "n8n"
18
+
19
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
20
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
21
+ analyze_capabilities(ir, "n8n", 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_n8n_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_n8n_json(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
37
+ nodes = []
38
+ connections = {}
39
+
40
+ trigger_node = {
41
+ "parameters": {},
42
+ "id": "trigger_manual",
43
+ "name": "When clicking ‘Test workflow’",
44
+ "type": "n8n-nodes-base.manualTrigger",
45
+ "typeVersion": 1,
46
+ "position": [100, 300],
47
+ }
48
+ nodes.append(trigger_node)
49
+
50
+ prev_node_name = trigger_node["name"]
51
+ x = 340
52
+
53
+ wf = ir.workflows.get(plan.main_workflow_key)
54
+ if wf and wf.steps:
55
+ for step in wf.steps:
56
+ agent = ir.agents.get(step.agent) if step.agent else None
57
+ instructions = agent.instructions if agent else f"Execute step {step.id}"
58
+ node_name = f"Agent - {step.id}"
59
+ nodes.append({
60
+ "parameters": {
61
+ "name": step.id,
62
+ "instructions": instructions,
63
+ },
64
+ "id": f"node_{step.id}",
65
+ "name": node_name,
66
+ "type": "n8n-nodes-base.agent",
67
+ "typeVersion": 1,
68
+ "position": [x, 300],
69
+ })
70
+ connections[prev_node_name] = {
71
+ "main": [
72
+ [{"node": node_name, "type": "main", "index": 0}]
73
+ ]
74
+ }
75
+ prev_node_name = node_name
76
+ x += 240
77
+ else:
78
+ for ak, agent in ir.agents.items():
79
+ node_name = f"Agent - {ak}"
80
+ nodes.append({
81
+ "parameters": {
82
+ "name": ak,
83
+ "instructions": agent.instructions,
84
+ },
85
+ "id": f"agent_{ak}",
86
+ "name": node_name,
87
+ "type": "n8n-nodes-base.agent",
88
+ "typeVersion": 1,
89
+ "position": [x, 300],
90
+ })
91
+ connections[prev_node_name] = {
92
+ "main": [
93
+ [{"node": node_name, "type": "main", "index": 0}]
94
+ ]
95
+ }
96
+ prev_node_name = node_name
97
+ x += 240
98
+
99
+ export = {
100
+ "name": plan.project_name,
101
+ "nodes": nodes,
102
+ "connections": connections,
103
+ "settings": {},
104
+ }
105
+ if ir.metadata.description:
106
+ export["description"] = ir.metadata.description
107
+
108
+ c = json.dumps(export, indent=2)
109
+ rel = "workflow.json"
110
+ write_file(out_dir, rel, c)
111
+ return [rel]
112
+
113
+
114
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
115
+ c = f"""\
116
+ # {plan.project_name} — n8n Workflow
117
+
118
+ Generated by `agentsml-impl`.
119
+
120
+ ## Overview
121
+ This export produces an n8n workflow definition conforming to the official n8n OpenAPI schema (`POST /api/v1/workflows`).
122
+
123
+ ## Import Options
124
+
125
+ ### 1. n8n Web UI
126
+ 1. Open your n8n workspace.
127
+ 2. Open the **Workflow** canvas menu.
128
+ 3. Select **Import from File** and upload `workflow.json`.
129
+
130
+ ### 2. n8n Public API
131
+ ```bash
132
+ curl -X POST "http://localhost:5678/api/v1/workflows" \\
133
+ -H "Content-Type: application/json" \\
134
+ -H "X-N8N-API-KEY: $N8N_API_KEY" \\
135
+ -d @workflow.json
136
+ ```
137
+ """
138
+ write_file(out_dir, "README.md", c)
139
+ return ["README.md"]
@@ -0,0 +1,26 @@
1
+ target: n8n
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: lossy
15
+ human_approval: adapter
16
+ mcp: adapter
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 n8n AI workflow JSON export.
File without changes
@@ -0,0 +1,175 @@
1
+ """OpenAI Agents (Swarm) 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 "openai-agents"
19
+
20
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
21
+ from agentsml_impl.compiler.capabilities import analyze_capabilities
22
+ analyze_capabilities(ir, "openai_agents", diagnostics)
23
+ for mk, model in ir.models.items():
24
+ if model.provider.lower() not in ("openai", "azure", "azure-openai"):
25
+ diagnostics.add_warning(
26
+ DiagCode.LOSSY_MAPPING,
27
+ f"Model '{mk}' uses non-OpenAI provider. Swarm only supports OpenAI models natively.",
28
+ path=f"models.{mk}.provider"
29
+ )
30
+
31
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
32
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
33
+ ir = python_identifier_ir(ir)
34
+ out_dir.mkdir(parents=True, exist_ok=True)
35
+ pkg = plan.package_name
36
+ src = out_dir / "src" / pkg
37
+ src.mkdir(parents=True, exist_ok=True)
38
+
39
+ files: list[str] = []
40
+ files += _write_pyproject(ir, plan, out_dir)
41
+ files += _write_tools(ir, src, out_dir, diagnostics)
42
+ files += _write_agent(ir, plan, src, out_dir, diagnostics)
43
+ files += _write_run(plan, src, out_dir)
44
+ files += _write_init(src, out_dir)
45
+ files += _write_readme(ir, plan, out_dir)
46
+
47
+ return GenerationResult(
48
+ target=self.name, out_dir=out_dir, files_written=files, success=True
49
+ )
50
+
51
+
52
+ def _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
53
+ c = f'''\
54
+ [build-system]
55
+ requires = ["setuptools>=68"]
56
+ build-backend = "setuptools.build_meta"
57
+
58
+ [project]
59
+ name = "{plan.package_name}"
60
+ version = "{ir.metadata.version or '0.1.0'}"
61
+ description = {toml_string(ir.metadata.description or plan.project_name)}
62
+ requires-python = ">=3.11"
63
+ dependencies = [
64
+ "swarm>=0.1.0",
65
+ "openai",
66
+ "python-dotenv"
67
+ ]
68
+
69
+ [tool.setuptools.packages.find]
70
+ where = ["src"]
71
+ '''
72
+ write_file(out_dir, "pyproject.toml", c)
73
+ return ["pyproject.toml"]
74
+
75
+
76
+ def _write_tools(ir: AgentSystemIR, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
77
+ if not ir.tools:
78
+ return []
79
+ c = generate_tools_module(ir.tools, ds, framework="openai-agents")
80
+ rel = f"src/{src.name}/tools.py"
81
+ write_file(out_dir, rel, c)
82
+ return [rel]
83
+
84
+
85
+ def _write_agent(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
86
+ agent_blocks: list[str] = []
87
+
88
+ tools_import = f"from .tools import {', '.join(ir.tools.keys())}" if ir.tools else ""
89
+
90
+ for ak, agent in ir.agents.items():
91
+ mstr = ir.models.get(agent.model).name if agent.model and ir.models.get(agent.model) else "gpt-4o"
92
+ inst = agent.instructions.replace('"""', "'''")
93
+ tools_list = ", ".join(agent.tools) if agent.tools else ""
94
+
95
+ agent_blocks.append(f'''\
96
+ {ak}_agent = Agent(
97
+ name="{ak}",
98
+ model="{mstr}",
99
+ instructions="""{inst}""",
100
+ functions=[{tools_list}]
101
+ )''')
102
+
103
+ wf = ir.workflows.get(plan.main_workflow_key)
104
+ if wf and wf.edges:
105
+ ds.add_warning(
106
+ DiagCode.LOSSY_MAPPING,
107
+ "Workflow edges are mapped as manual handoff functions. Please implement them in your tools.",
108
+ path=f"workflows.{plan.main_workflow_key}.edges"
109
+ )
110
+
111
+ c = f'''\
112
+ """OpenAI Swarm agents for {plan.project_name}."""
113
+ from __future__ import annotations
114
+ from swarm import Agent
115
+ {tools_import}
116
+
117
+ {chr(10).join(agent_blocks)}
118
+ '''
119
+ rel = f"src/{src.name}/agent.py"
120
+ write_file(out_dir, rel, c)
121
+ return [rel]
122
+
123
+
124
+ def _write_run(plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
125
+ c = f'''\
126
+ """Runner for {plan.project_name} (Swarm)."""
127
+ from __future__ import annotations
128
+ import sys
129
+ from swarm import Swarm
130
+ from .agent import *
131
+
132
+ def main():
133
+ client = Swarm()
134
+ q = " ".join(sys.argv[1:]) or "Hello"
135
+ # Find the first agent defined to start
136
+ agents = [v for k, v in globals().items() if k.endswith("_agent") and hasattr(v, "name")]
137
+ start_agent = agents[0] if agents else None
138
+ if not start_agent:
139
+ print("No agents found.")
140
+ return
141
+
142
+ response = client.run(
143
+ agent=start_agent,
144
+ messages=[{{"role": "user", "content": q}}]
145
+ )
146
+ print(response.messages[-1]["content"])
147
+
148
+ if __name__ == "__main__":
149
+ main()
150
+ '''
151
+ rel = f"src/{src.name}/run.py"
152
+ write_file(out_dir, rel, c)
153
+ return [rel]
154
+
155
+ def _write_init(src: Path, out_dir: Path) -> list[str]:
156
+ c = f'"""Package: {src.name}."""\n'
157
+ rel = f"src/{src.name}/__init__.py"
158
+ write_file(out_dir, rel, c)
159
+ return [rel]
160
+
161
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
162
+ c = f"""\
163
+ # {plan.project_name} — OpenAI Swarm
164
+
165
+ Generated by `agentsml-impl`.
166
+
167
+ ## Quickstart
168
+ ```bash
169
+ pip install -e .
170
+ export OPENAI_API_KEY="your-key"
171
+ python -m {plan.package_name}.run
172
+ ```
173
+ """
174
+ write_file(out_dir, "README.md", c)
175
+ return ["README.md"]
@@ -0,0 +1,27 @@
1
+ target: openai_agents
2
+ kind: code
3
+ language: python
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "0.1.0" # swarm
7
+ supports:
8
+ agents: native
9
+ tools: native
10
+ workflows: lossy
11
+ graph_edges: lossy
12
+ graph_conditions: manual
13
+ cycles: lossy
14
+ parallel: unsupported
15
+ human_approval: adapter
16
+ mcp: unsupported
17
+ a2a: manual
18
+ ag_ui: unsupported
19
+ structured_output: manual
20
+ observability: unsupported
21
+ artifacts:
22
+ - python_project
23
+ - diagnostics
24
+ - readme
25
+ notes: >
26
+ Maps to OpenAI Swarm. Workflows and edges map to Swarm handoffs (function calls).
27
+ MCP requires building raw wrapper functions.
File without changes