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.
- agentsml_impl/__init__.py +3 -0
- agentsml_impl/cli.py +472 -0
- agentsml_impl/compiler/__init__.py +1 -0
- agentsml_impl/compiler/capabilities.py +330 -0
- agentsml_impl/compiler/conditions.py +177 -0
- agentsml_impl/compiler/diagnostics.py +112 -0
- agentsml_impl/compiler/durations.py +31 -0
- agentsml_impl/compiler/expressions.py +123 -0
- agentsml_impl/compiler/identifiers.py +60 -0
- agentsml_impl/compiler/ir.py +391 -0
- agentsml_impl/compiler/limits.py +28 -0
- agentsml_impl/compiler/loader.py +83 -0
- agentsml_impl/compiler/naming.py +87 -0
- agentsml_impl/compiler/planner.py +79 -0
- agentsml_impl/compiler/render.py +90 -0
- agentsml_impl/compiler/schema_validation.py +121 -0
- agentsml_impl/compiler/semantic_validation.py +424 -0
- agentsml_impl/protocols/__init__.py +1 -0
- agentsml_impl/runtime/__init__.py +1 -0
- agentsml_impl/runtime/events.py +59 -0
- agentsml_impl/runtime/json_schema.py +138 -0
- agentsml_impl/runtime/tools.py +145 -0
- agentsml_impl/schemas/agentsml.schema.json +406 -0
- agentsml_impl/schemas/v0.1/agentsml.schema.json +628 -0
- agentsml_impl/schemas/v0.2/agentsml.schema.json +363 -0
- agentsml_impl/schemas/v0.3/agentsml.schema.json +406 -0
- agentsml_impl/targets/__init__.py +1 -0
- agentsml_impl/targets/a2a/__init__.py +0 -0
- agentsml_impl/targets/a2a/adapter.py +94 -0
- agentsml_impl/targets/a2a/capabilities.yaml +25 -0
- agentsml_impl/targets/ag2/__init__.py +0 -0
- agentsml_impl/targets/ag2/adapter.py +655 -0
- agentsml_impl/targets/ag2/capabilities.yaml +37 -0
- agentsml_impl/targets/ag_ui/__init__.py +0 -0
- agentsml_impl/targets/ag_ui/adapter.py +123 -0
- agentsml_impl/targets/ag_ui/capabilities.yaml +25 -0
- agentsml_impl/targets/agno/__init__.py +0 -0
- agentsml_impl/targets/agno/adapter.py +191 -0
- agentsml_impl/targets/agno/capabilities.yaml +26 -0
- agentsml_impl/targets/ap2/__init__.py +0 -0
- agentsml_impl/targets/ap2/adapter.py +84 -0
- agentsml_impl/targets/ap2/capabilities.yaml +25 -0
- agentsml_impl/targets/base.py +157 -0
- agentsml_impl/targets/bedrock_agentcore/__init__.py +0 -0
- agentsml_impl/targets/bedrock_agentcore/adapter.py +592 -0
- agentsml_impl/targets/bedrock_agentcore/capabilities.yaml +26 -0
- agentsml_impl/targets/claude_agent_sdk/__init__.py +0 -0
- agentsml_impl/targets/claude_agent_sdk/adapter.py +178 -0
- agentsml_impl/targets/claude_agent_sdk/capabilities.yaml +26 -0
- agentsml_impl/targets/crewai/__init__.py +0 -0
- agentsml_impl/targets/crewai/adapter.py +441 -0
- agentsml_impl/targets/crewai/capabilities.yaml +30 -0
- agentsml_impl/targets/databricks/__init__.py +0 -0
- agentsml_impl/targets/databricks/adapter.py +427 -0
- agentsml_impl/targets/databricks/capabilities.yaml +26 -0
- agentsml_impl/targets/flowise/__init__.py +0 -0
- agentsml_impl/targets/flowise/adapter.py +71 -0
- agentsml_impl/targets/flowise/capabilities.yaml +26 -0
- agentsml_impl/targets/google_adk/__init__.py +0 -0
- agentsml_impl/targets/google_adk/adapter.py +589 -0
- agentsml_impl/targets/google_adk/capabilities.yaml +36 -0
- agentsml_impl/targets/langchain/__init__.py +1 -0
- agentsml_impl/targets/langchain/adapter.py +351 -0
- agentsml_impl/targets/langchain/capabilities.yaml +30 -0
- agentsml_impl/targets/langflow/__init__.py +0 -0
- agentsml_impl/targets/langflow/adapter.py +147 -0
- agentsml_impl/targets/langflow/capabilities.yaml +26 -0
- agentsml_impl/targets/langgraph/__init__.py +0 -0
- agentsml_impl/targets/langgraph/adapter.py +911 -0
- agentsml_impl/targets/langgraph/capabilities.yaml +33 -0
- agentsml_impl/targets/llamaindex/__init__.py +1 -0
- agentsml_impl/targets/llamaindex/adapter.py +406 -0
- agentsml_impl/targets/llamaindex/capabilities.yaml +31 -0
- agentsml_impl/targets/lyzr/__init__.py +0 -0
- agentsml_impl/targets/lyzr/adapter.py +146 -0
- agentsml_impl/targets/lyzr/capabilities.yaml +26 -0
- agentsml_impl/targets/mastra/__init__.py +0 -0
- agentsml_impl/targets/mastra/adapter.py +635 -0
- agentsml_impl/targets/mastra/capabilities.yaml +32 -0
- agentsml_impl/targets/mcp_server/__init__.py +0 -0
- agentsml_impl/targets/mcp_server/adapter.py +141 -0
- agentsml_impl/targets/mcp_server/capabilities.yaml +25 -0
- agentsml_impl/targets/microsoft_agent_framework/__init__.py +0 -0
- agentsml_impl/targets/microsoft_agent_framework/adapter.py +563 -0
- agentsml_impl/targets/microsoft_agent_framework/capabilities.yaml +26 -0
- agentsml_impl/targets/n8n/__init__.py +0 -0
- agentsml_impl/targets/n8n/adapter.py +139 -0
- agentsml_impl/targets/n8n/capabilities.yaml +26 -0
- agentsml_impl/targets/openai_agents/__init__.py +0 -0
- agentsml_impl/targets/openai_agents/adapter.py +175 -0
- agentsml_impl/targets/openai_agents/capabilities.yaml +27 -0
- agentsml_impl/targets/pydantic_ai/__init__.py +0 -0
- agentsml_impl/targets/pydantic_ai/adapter.py +922 -0
- agentsml_impl/targets/pydantic_ai/capabilities.yaml +37 -0
- agentsml_impl/targets/registry.py +290 -0
- agentsml_impl/targets/relevance_ai/__init__.py +0 -0
- agentsml_impl/targets/relevance_ai/adapter.py +66 -0
- agentsml_impl/targets/relevance_ai/capabilities.yaml +26 -0
- agentsml_impl/targets/smolagents/__init__.py +0 -0
- agentsml_impl/targets/smolagents/adapter.py +210 -0
- agentsml_impl/targets/smolagents/capabilities.yaml +27 -0
- agentsml_impl/targets/snowflake_cortex/__init__.py +0 -0
- agentsml_impl/targets/snowflake_cortex/adapter.py +167 -0
- agentsml_impl/targets/snowflake_cortex/capabilities.yaml +26 -0
- agentsml_impl/targets/spring_ai/__init__.py +1 -0
- agentsml_impl/targets/spring_ai/adapter.py +626 -0
- agentsml_impl/targets/spring_ai/capabilities.yaml +31 -0
- agentsml_impl/targets/strands_agents/__init__.py +1 -0
- agentsml_impl/targets/strands_agents/adapter.py +309 -0
- agentsml_impl/targets/strands_agents/capabilities.yaml +29 -0
- agentsml_impl/targets/support_matrix.py +91 -0
- agentsml_impl/targets/ucp/__init__.py +0 -0
- agentsml_impl/targets/ucp/adapter.py +86 -0
- agentsml_impl/targets/ucp/capabilities.yaml +25 -0
- agentsml_impl/targets/vercel_ai/__init__.py +1 -0
- agentsml_impl/targets/vercel_ai/adapter.py +349 -0
- agentsml_impl/targets/vercel_ai/capabilities.yaml +30 -0
- agentsml_impl/targets/vertex_agent_engine/__init__.py +0 -0
- agentsml_impl/targets/vertex_agent_engine/adapter.py +407 -0
- agentsml_impl/targets/vertex_agent_engine/capabilities.yaml +26 -0
- agentsml_impl/targets/zapier_agents/__init__.py +0 -0
- agentsml_impl/targets/zapier_agents/adapter.py +106 -0
- agentsml_impl/targets/zapier_agents/capabilities.yaml +26 -0
- agentsml_impl-0.2.0.dist-info/METADATA +109 -0
- agentsml_impl-0.2.0.dist-info/RECORD +129 -0
- agentsml_impl-0.2.0.dist-info/WHEEL +5 -0
- agentsml_impl-0.2.0.dist-info/entry_points.txt +3 -0
- agentsml_impl-0.2.0.dist-info/licenses/LICENSE +28 -0
- agentsml_impl-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Snowflake Cortex 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 "snowflake-cortex"
|
|
19
|
+
|
|
20
|
+
def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
|
|
21
|
+
from agentsml_impl.compiler.capabilities import analyze_capabilities
|
|
22
|
+
analyze_capabilities(ir, "snowflake_cortex", 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 _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
|
|
46
|
+
c = f'''\
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["setuptools>=68"]
|
|
49
|
+
build-backend = "setuptools.build_meta"
|
|
50
|
+
|
|
51
|
+
[project]
|
|
52
|
+
name = "{plan.package_name}"
|
|
53
|
+
version = "{ir.metadata.version or '0.1.0'}"
|
|
54
|
+
description = {toml_string(ir.metadata.description or plan.project_name)}
|
|
55
|
+
requires-python = ">=3.11"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"snowflake-snowpark-python",
|
|
58
|
+
"snowflake-ml-python",
|
|
59
|
+
"python-dotenv"
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.packages.find]
|
|
63
|
+
where = ["src"]
|
|
64
|
+
'''
|
|
65
|
+
write_file(out_dir, "pyproject.toml", c)
|
|
66
|
+
return ["pyproject.toml"]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _write_tools(ir: AgentSystemIR, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
|
|
70
|
+
if not ir.tools:
|
|
71
|
+
return []
|
|
72
|
+
c = generate_tools_module(ir.tools, ds, framework="snowflake_cortex")
|
|
73
|
+
rel = f"src/{src.name}/tools.py"
|
|
74
|
+
write_file(out_dir, rel, c)
|
|
75
|
+
return [rel]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _write_agent(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
|
|
79
|
+
agent_blocks: list[str] = []
|
|
80
|
+
tools_import = f"from .tools import {', '.join(ir.tools.keys())}" if ir.tools else ""
|
|
81
|
+
|
|
82
|
+
for ak, agent in ir.agents.items():
|
|
83
|
+
m = ir.models.get(agent.model)
|
|
84
|
+
mstr = m.name if m else 'snowflake-arctic'
|
|
85
|
+
inst = agent.instructions.replace('"""', "'''")
|
|
86
|
+
|
|
87
|
+
agent_blocks.append(f'''\
|
|
88
|
+
class {ak.capitalize()}Agent:
|
|
89
|
+
def __init__(self, session):
|
|
90
|
+
self.session = session
|
|
91
|
+
self.model = "{mstr}"
|
|
92
|
+
self.system_prompt = """{inst}"""
|
|
93
|
+
|
|
94
|
+
def complete(self, prompt: str):
|
|
95
|
+
from snowflake.cortex import Complete
|
|
96
|
+
full_prompt = f"{{self.system_prompt}}\\n\\n{{prompt}}"
|
|
97
|
+
return Complete(self.model, full_prompt, session=self.session)
|
|
98
|
+
''')
|
|
99
|
+
|
|
100
|
+
c = f'''\
|
|
101
|
+
"""Snowflake Cortex Agent definitions for {plan.project_name}."""
|
|
102
|
+
from __future__ import annotations
|
|
103
|
+
{tools_import}
|
|
104
|
+
|
|
105
|
+
{chr(10).join(agent_blocks)}
|
|
106
|
+
'''
|
|
107
|
+
rel = f"src/{src.name}/agent.py"
|
|
108
|
+
write_file(out_dir, rel, c)
|
|
109
|
+
return [rel]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _write_run(plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
|
|
113
|
+
c = f'''\
|
|
114
|
+
"""Runner for {plan.project_name} (Snowflake Cortex)."""
|
|
115
|
+
from __future__ import annotations
|
|
116
|
+
import sys
|
|
117
|
+
from snowflake.snowpark import Session
|
|
118
|
+
from .agent import *
|
|
119
|
+
|
|
120
|
+
def main():
|
|
121
|
+
q = " ".join(sys.argv[1:]) or "Hello"
|
|
122
|
+
|
|
123
|
+
# Establish Snowflake session (requires credentials in env or config)
|
|
124
|
+
try:
|
|
125
|
+
session = Session.builder.getOrCreate()
|
|
126
|
+
except Exception as e:
|
|
127
|
+
print("Failed to create Snowflake session. Configure SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, etc.")
|
|
128
|
+
return
|
|
129
|
+
|
|
130
|
+
agent_classes = [v for k, v in globals().items() if k.endswith("Agent") and isinstance(v, type)]
|
|
131
|
+
start_agent_cls = agent_classes[0] if agent_classes else None
|
|
132
|
+
|
|
133
|
+
if not start_agent_cls:
|
|
134
|
+
print("No agents found.")
|
|
135
|
+
return
|
|
136
|
+
|
|
137
|
+
agent = start_agent_cls(session)
|
|
138
|
+
res = agent.complete(q)
|
|
139
|
+
print("Result:", res)
|
|
140
|
+
|
|
141
|
+
if __name__ == "__main__":
|
|
142
|
+
main()
|
|
143
|
+
'''
|
|
144
|
+
rel = f"src/{src.name}/run.py"
|
|
145
|
+
write_file(out_dir, rel, c)
|
|
146
|
+
return [rel]
|
|
147
|
+
|
|
148
|
+
def _write_init(src: Path, out_dir: Path) -> list[str]:
|
|
149
|
+
c = f'"""Package: {src.name}."""\n'
|
|
150
|
+
rel = f"src/{src.name}/__init__.py"
|
|
151
|
+
write_file(out_dir, rel, c)
|
|
152
|
+
return [rel]
|
|
153
|
+
|
|
154
|
+
def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
|
|
155
|
+
c = f"""\
|
|
156
|
+
# {plan.project_name} — Snowflake Cortex
|
|
157
|
+
|
|
158
|
+
Generated by `agentsml-impl`.
|
|
159
|
+
|
|
160
|
+
## Quickstart
|
|
161
|
+
```bash
|
|
162
|
+
pip install -e .
|
|
163
|
+
python -m {plan.package_name}.run
|
|
164
|
+
```
|
|
165
|
+
"""
|
|
166
|
+
write_file(out_dir, "README.md", c)
|
|
167
|
+
return ["README.md"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
target: snowflake_cortex
|
|
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: adapter
|
|
10
|
+
workflows: lossy
|
|
11
|
+
graph_edges: lossy
|
|
12
|
+
graph_conditions: lossy
|
|
13
|
+
cycles: lossy
|
|
14
|
+
parallel: unsupported
|
|
15
|
+
human_approval: adapter
|
|
16
|
+
mcp: unsupported
|
|
17
|
+
a2a: manual
|
|
18
|
+
ag_ui: unsupported
|
|
19
|
+
structured_output: unsupported
|
|
20
|
+
observability: native
|
|
21
|
+
artifacts:
|
|
22
|
+
- python_project
|
|
23
|
+
- diagnostics
|
|
24
|
+
- readme
|
|
25
|
+
notes: >
|
|
26
|
+
Maps to Snowflake Cortex AI (Python API).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Target: spring_ai."""
|