@qubiit/lmagent 2.5.0
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.
- package/.editorconfig +18 -0
- package/AGENTS.md +169 -0
- package/CLAUDE.md +122 -0
- package/CONTRIBUTING.md +90 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/config/commands.yaml +194 -0
- package/config/levels.yaml +135 -0
- package/config/models.yaml +192 -0
- package/config/settings.yaml +405 -0
- package/config/tools-extended.yaml +534 -0
- package/config/tools.yaml +437 -0
- package/docs/assets/logo.png +0 -0
- package/docs/commands.md +132 -0
- package/docs/customization-guide.md +445 -0
- package/docs/getting-started.md +154 -0
- package/docs/how-to-start.md +242 -0
- package/docs/navigation-index.md +227 -0
- package/docs/usage-guide.md +113 -0
- package/install.js +1044 -0
- package/package.json +35 -0
- package/pyproject.toml +182 -0
- package/rules/_bootstrap.md +138 -0
- package/rules/agents-ia.md +607 -0
- package/rules/api-design.md +337 -0
- package/rules/automations-n8n.md +646 -0
- package/rules/code-style.md +570 -0
- package/rules/documentation.md +98 -0
- package/rules/security.md +316 -0
- package/rules/stack.md +395 -0
- package/rules/testing.md +326 -0
- package/rules/workflow.md +353 -0
- package/scripts/create_skill.js +300 -0
- package/scripts/validate_skills.js +283 -0
- package/skills/ai-agent-engineer/SKILL.md +394 -0
- package/skills/ai-agent-engineer/references/agent-patterns.md +149 -0
- package/skills/api-designer/SKILL.md +429 -0
- package/skills/api-designer/references/api-standards.md +13 -0
- package/skills/architect/SKILL.md +285 -0
- package/skills/architect/references/c4-model.md +133 -0
- package/skills/automation-engineer/SKILL.md +352 -0
- package/skills/automation-engineer/references/n8n-patterns.md +127 -0
- package/skills/backend-engineer/SKILL.md +261 -0
- package/skills/backend-engineer/assets/fastapi-project-structure.yaml +74 -0
- package/skills/backend-engineer/references/debugging-guide.md +174 -0
- package/skills/backend-engineer/references/design-patterns.md +208 -0
- package/skills/backend-engineer/scripts/scaffold_backend.py +313 -0
- package/skills/bmad-methodology/SKILL.md +202 -0
- package/skills/bmad-methodology/references/scale-adaptive-levels.md +141 -0
- package/skills/browser-agent/SKILL.md +502 -0
- package/skills/browser-agent/scripts/playwright_setup.ts +16 -0
- package/skills/code-reviewer/SKILL.md +306 -0
- package/skills/code-reviewer/references/code-review-checklist.md +16 -0
- package/skills/data-engineer/SKILL.md +474 -0
- package/skills/data-engineer/assets/pg-monitoring-queries.sql +154 -0
- package/skills/data-engineer/references/index-strategy.md +128 -0
- package/skills/data-engineer/scripts/backup_postgres.py +221 -0
- package/skills/devops-engineer/SKILL.md +547 -0
- package/skills/devops-engineer/references/ci-cd-patterns.md +265 -0
- package/skills/devops-engineer/scripts/docker_healthcheck.py +125 -0
- package/skills/document-generator/SKILL.md +746 -0
- package/skills/document-generator/references/pdf-generation.md +22 -0
- package/skills/frontend-engineer/SKILL.md +532 -0
- package/skills/frontend-engineer/references/accessibility-guide.md +146 -0
- package/skills/frontend-engineer/scripts/audit_bundle.py +144 -0
- package/skills/git-workflow/SKILL.md +374 -0
- package/skills/git-workflow/references/git-flow.md +25 -0
- package/skills/mcp-builder/SKILL.md +471 -0
- package/skills/mcp-builder/references/mcp-server-guide.md +23 -0
- package/skills/mobile-engineer/SKILL.md +502 -0
- package/skills/mobile-engineer/references/platform-guidelines.md +160 -0
- package/skills/orchestrator/SKILL.md +246 -0
- package/skills/orchestrator/references/methodology-routing.md +117 -0
- package/skills/orchestrator/references/persona-mapping.md +85 -0
- package/skills/orchestrator/references/routing-logic.md +110 -0
- package/skills/performance-engineer/SKILL.md +549 -0
- package/skills/performance-engineer/references/caching-patterns.md +181 -0
- package/skills/performance-engineer/scripts/profile_endpoint.py +170 -0
- package/skills/product-manager/SKILL.md +488 -0
- package/skills/product-manager/references/prioritization-frameworks.md +126 -0
- package/skills/prompt-engineer/SKILL.md +433 -0
- package/skills/prompt-engineer/references/prompt-patterns.md +158 -0
- package/skills/qa-engineer/SKILL.md +441 -0
- package/skills/qa-engineer/references/testing-strategy.md +166 -0
- package/skills/qa-engineer/scripts/run_coverage.py +147 -0
- package/skills/scrum-master/SKILL.md +225 -0
- package/skills/scrum-master/references/sprint-ceremonies.md +159 -0
- package/skills/security-analyst/SKILL.md +390 -0
- package/skills/security-analyst/references/owasp-top10.md +188 -0
- package/skills/security-analyst/scripts/audit_security.py +242 -0
- package/skills/seo-auditor/SKILL.md +523 -0
- package/skills/seo-auditor/references/seo-checklist.md +17 -0
- package/skills/spec-driven-dev/SKILL.md +342 -0
- package/skills/spec-driven-dev/references/phase-gates.md +107 -0
- package/skills/supabase-expert/SKILL.md +602 -0
- package/skills/supabase-expert/references/supabase-patterns.md +19 -0
- package/skills/swe-agent/SKILL.md +311 -0
- package/skills/swe-agent/references/trajectory-format.md +134 -0
- package/skills/systematic-debugger/SKILL.md +512 -0
- package/skills/systematic-debugger/references/debugging-guide.md +12 -0
- package/skills/tech-lead/SKILL.md +409 -0
- package/skills/tech-lead/references/code-review-checklist.md +111 -0
- package/skills/technical-writer/SKILL.md +631 -0
- package/skills/technical-writer/references/doc-templates.md +218 -0
- package/skills/testing-strategist/SKILL.md +476 -0
- package/skills/testing-strategist/references/testing-pyramid.md +16 -0
- package/skills/ux-ui-designer/SKILL.md +419 -0
- package/skills/ux-ui-designer/references/design-system-foundation.md +168 -0
- package/skills_overview.txt +94 -0
- package/templates/PROJECT_KICKOFF.md +284 -0
- package/templates/SKILL_TEMPLATE.md +131 -0
- package/templates/USAGE.md +95 -0
- package/templates/agent-python/README.md +71 -0
- package/templates/agent-python/agent.py +272 -0
- package/templates/agent-python/config.yaml +76 -0
- package/templates/agent-python/prompts/system.md +109 -0
- package/templates/agent-python/requirements.txt +7 -0
- package/templates/automation-n8n/README.md +14 -0
- package/templates/automation-n8n/webhook-handler.json +57 -0
- package/templates/backend-node/Dockerfile +12 -0
- package/templates/backend-node/README.md +15 -0
- package/templates/backend-node/package.json +30 -0
- package/templates/backend-node/src/index.ts +19 -0
- package/templates/backend-node/src/routes.ts +7 -0
- package/templates/backend-node/tsconfig.json +22 -0
- package/templates/backend-python/Dockerfile +11 -0
- package/templates/backend-python/README.md +78 -0
- package/templates/backend-python/app/core/config.py +12 -0
- package/templates/backend-python/app/core/database.py +12 -0
- package/templates/backend-python/app/main.py +17 -0
- package/templates/backend-python/app/routers/__init__.py +1 -0
- package/templates/backend-python/app/routers/health.py +7 -0
- package/templates/backend-python/requirements-dev.txt +6 -0
- package/templates/backend-python/requirements.txt +4 -0
- package/templates/backend-python/tests/test_health.py +9 -0
- package/templates/checkpoint.yaml +117 -0
- package/templates/database/README.md +474 -0
- package/templates/frontend-react/README.md +446 -0
- package/templates/plan.yaml +320 -0
- package/templates/session.yaml +125 -0
- package/templates/spec.yaml +229 -0
- package/templates/tasks.yaml +330 -0
- package/workflows/bugfix-backend.md +380 -0
- package/workflows/documentation.md +232 -0
- package/workflows/generate-prd.md +320 -0
- package/workflows/ideation.md +396 -0
- package/workflows/new-agent-ia.md +497 -0
- package/workflows/new-automation.md +374 -0
- package/workflows/new-feature.md +290 -0
- package/workflows/optimize-performance.md +373 -0
- package/workflows/resolve-github-issue.md +524 -0
- package/workflows/security-review.md +291 -0
- package/workflows/spec-driven.md +476 -0
- package/workflows/testing-strategy.md +296 -0
- package/workflows/third-party-integration.md +277 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent implementation template.
|
|
3
|
+
|
|
4
|
+
This is the main agent class that you can customize for your specific use case.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
import yaml
|
|
14
|
+
import structlog
|
|
15
|
+
from pydantic import BaseModel
|
|
16
|
+
|
|
17
|
+
# Importar desde LMAgent (ajustar paths según estructura real)
|
|
18
|
+
# from lmagent.core.base_agent import BaseAgent
|
|
19
|
+
# from lmagent.core.tool_registry import ToolRegistry
|
|
20
|
+
# from lmagent.core.llm_provider import get_provider
|
|
21
|
+
# from lmagent.core.trajectory import TrajectoryLogger
|
|
22
|
+
# from lmagent.core.cost_tracker import CostTracker
|
|
23
|
+
|
|
24
|
+
logger = structlog.get_logger()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AgentConfig(BaseModel):
|
|
28
|
+
"""Configuration for the agent."""
|
|
29
|
+
name: str
|
|
30
|
+
display_name: str
|
|
31
|
+
description: str
|
|
32
|
+
version: str = "1.0.0"
|
|
33
|
+
|
|
34
|
+
# LLM config
|
|
35
|
+
llm_provider: str = "openai"
|
|
36
|
+
llm_model: str = "gpt-4o"
|
|
37
|
+
temperature: float = 0.7
|
|
38
|
+
max_tokens: int = 4096
|
|
39
|
+
|
|
40
|
+
# Limits
|
|
41
|
+
max_iterations: int = 10
|
|
42
|
+
max_cost: float = 2.00
|
|
43
|
+
timeout_seconds: int = 300
|
|
44
|
+
|
|
45
|
+
# Tools
|
|
46
|
+
tools: list[str] = []
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def from_yaml(cls, path: str | Path) -> "AgentConfig":
|
|
50
|
+
"""Load config from YAML file."""
|
|
51
|
+
with open(path) as f:
|
|
52
|
+
data = yaml.safe_load(f)
|
|
53
|
+
|
|
54
|
+
return cls(
|
|
55
|
+
name=data["name"],
|
|
56
|
+
display_name=data["display_name"],
|
|
57
|
+
description=data["description"],
|
|
58
|
+
version=data.get("version", "0.1.0"),
|
|
59
|
+
llm_provider=data.get("llm", {}).get("provider", "openai"),
|
|
60
|
+
llm_model=data.get("llm", {}).get("model", "gpt-4o"),
|
|
61
|
+
temperature=data.get("llm", {}).get("temperature", 0.7),
|
|
62
|
+
max_tokens=data.get("llm", {}).get("max_tokens", 4096),
|
|
63
|
+
max_iterations=data.get("limits", {}).get("max_iterations", 10),
|
|
64
|
+
max_cost=data.get("limits", {}).get("max_cost", 2.00),
|
|
65
|
+
timeout_seconds=data.get("limits", {}).get("timeout_seconds", 300),
|
|
66
|
+
tools=data.get("tools", {}).get("from_registry", []),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class MyAgent:
|
|
71
|
+
"""
|
|
72
|
+
Custom agent implementation.
|
|
73
|
+
|
|
74
|
+
This agent [describe what your agent does].
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
>>> agent = MyAgent.from_config("config.yaml")
|
|
78
|
+
>>> result = await agent.run("Your input here")
|
|
79
|
+
>>> print(result)
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
def __init__(self, config: AgentConfig):
|
|
83
|
+
"""Initialize the agent with configuration."""
|
|
84
|
+
self.config = config
|
|
85
|
+
self.history: list[dict[str, Any]] = []
|
|
86
|
+
self.iteration_count = 0
|
|
87
|
+
self.total_cost = 0.0
|
|
88
|
+
|
|
89
|
+
# Load system prompt
|
|
90
|
+
self.system_prompt = self._load_system_prompt()
|
|
91
|
+
|
|
92
|
+
# Initialize tools
|
|
93
|
+
self.tools = self._load_tools()
|
|
94
|
+
|
|
95
|
+
# Initialize LLM provider
|
|
96
|
+
# self.llm = get_provider(config.llm_provider, config.llm_model)
|
|
97
|
+
|
|
98
|
+
# Initialize tracking
|
|
99
|
+
# self.trajectory = TrajectoryLogger()
|
|
100
|
+
# self.cost_tracker = CostTracker(max_cost=config.max_cost)
|
|
101
|
+
|
|
102
|
+
logger.info(
|
|
103
|
+
"agent_initialized",
|
|
104
|
+
name=config.name,
|
|
105
|
+
model=config.llm_model,
|
|
106
|
+
tools=list(self.tools.keys())
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def from_config(cls, config_path: str | Path) -> "MyAgent":
|
|
111
|
+
"""Create agent from config file."""
|
|
112
|
+
config = AgentConfig.from_yaml(config_path)
|
|
113
|
+
return cls(config)
|
|
114
|
+
|
|
115
|
+
def _load_system_prompt(self) -> str:
|
|
116
|
+
"""Load system prompt from file."""
|
|
117
|
+
prompt_path = Path(__file__).parent / "prompts" / "system.md"
|
|
118
|
+
if prompt_path.exists():
|
|
119
|
+
return prompt_path.read_text()
|
|
120
|
+
return "You are a helpful AI assistant."
|
|
121
|
+
|
|
122
|
+
def _load_tools(self) -> dict[str, Any]:
|
|
123
|
+
"""Load and initialize tools."""
|
|
124
|
+
tools = {}
|
|
125
|
+
|
|
126
|
+
# Load tools from registry
|
|
127
|
+
# for tool_name in self.config.tools:
|
|
128
|
+
# tools[tool_name] = ToolRegistry.get(tool_name)
|
|
129
|
+
|
|
130
|
+
# Load custom tools
|
|
131
|
+
# from .tools import custom_tool
|
|
132
|
+
# tools["custom_tool"] = custom_tool.CustomTool()
|
|
133
|
+
|
|
134
|
+
return tools
|
|
135
|
+
|
|
136
|
+
async def run(
|
|
137
|
+
self,
|
|
138
|
+
user_input: str,
|
|
139
|
+
context: dict[str, Any] | None = None
|
|
140
|
+
) -> str:
|
|
141
|
+
"""
|
|
142
|
+
Run the agent with user input.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
user_input: The user's query or task.
|
|
146
|
+
context: Optional additional context.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
The agent's final response.
|
|
150
|
+
|
|
151
|
+
Raises:
|
|
152
|
+
CostLimitExceeded: If the cost limit is reached.
|
|
153
|
+
MaxIterationsExceeded: If max iterations is reached.
|
|
154
|
+
"""
|
|
155
|
+
logger.info(
|
|
156
|
+
"agent_run_start",
|
|
157
|
+
input_length=len(user_input),
|
|
158
|
+
context_keys=list(context.keys()) if context else []
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Add user message to history
|
|
162
|
+
self.history.append({
|
|
163
|
+
"role": "user",
|
|
164
|
+
"content": user_input
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
# Main agent loop
|
|
168
|
+
for iteration in range(self.config.max_iterations):
|
|
169
|
+
self.iteration_count = iteration + 1
|
|
170
|
+
|
|
171
|
+
logger.info(f"🤠 INFO ========================= STEP {iteration + 1} =========================")
|
|
172
|
+
|
|
173
|
+
# Get LLM response
|
|
174
|
+
# response = await self.llm.complete(
|
|
175
|
+
# system_prompt=self.system_prompt,
|
|
176
|
+
# messages=self.history,
|
|
177
|
+
# tools=self.tools,
|
|
178
|
+
# temperature=self.config.temperature,
|
|
179
|
+
# max_tokens=self.config.max_tokens
|
|
180
|
+
# )
|
|
181
|
+
|
|
182
|
+
# For template purposes, simulate a response
|
|
183
|
+
response = await self._simulate_response(user_input, iteration)
|
|
184
|
+
|
|
185
|
+
# Track cost
|
|
186
|
+
# self.cost_tracker.track(
|
|
187
|
+
# model=self.config.llm_model,
|
|
188
|
+
# input_tokens=response.usage.input_tokens,
|
|
189
|
+
# output_tokens=response.usage.output_tokens
|
|
190
|
+
# )
|
|
191
|
+
|
|
192
|
+
# Log thinking
|
|
193
|
+
if hasattr(response, 'thinking'):
|
|
194
|
+
logger.info(f"💭 THOUGHT: {response.thinking}")
|
|
195
|
+
|
|
196
|
+
# If there are tool calls, execute them
|
|
197
|
+
if hasattr(response, 'tool_calls') and response.tool_calls:
|
|
198
|
+
for tool_call in response.tool_calls:
|
|
199
|
+
logger.info(f"🎬 ACTION: {tool_call.name}({tool_call.args})")
|
|
200
|
+
|
|
201
|
+
# Execute tool
|
|
202
|
+
# result = await self.tools[tool_call.name].execute(**tool_call.args)
|
|
203
|
+
result = {"success": True, "data": "Simulated result"}
|
|
204
|
+
|
|
205
|
+
logger.info(f"📤 OBSERVATION: {str(result)[:200]}...")
|
|
206
|
+
|
|
207
|
+
# Add to history
|
|
208
|
+
self.history.append({
|
|
209
|
+
"role": "tool",
|
|
210
|
+
"name": tool_call.name,
|
|
211
|
+
"result": result
|
|
212
|
+
})
|
|
213
|
+
else:
|
|
214
|
+
# No tool calls, agent wants to respond
|
|
215
|
+
final_response = response.content if hasattr(response, 'content') else str(response)
|
|
216
|
+
|
|
217
|
+
self.history.append({
|
|
218
|
+
"role": "assistant",
|
|
219
|
+
"content": final_response
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
logger.info(
|
|
223
|
+
"agent_run_complete",
|
|
224
|
+
iterations=self.iteration_count,
|
|
225
|
+
cost=self.total_cost
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return final_response
|
|
229
|
+
|
|
230
|
+
# Max iterations reached
|
|
231
|
+
logger.warning("agent_max_iterations_reached")
|
|
232
|
+
return "I've reached my maximum number of steps. Here's what I've accomplished so far..."
|
|
233
|
+
|
|
234
|
+
async def _simulate_response(self, user_input: str, iteration: int) -> Any:
|
|
235
|
+
"""Simulate a response for template testing."""
|
|
236
|
+
# This is a placeholder. In real implementation,
|
|
237
|
+
# this would be replaced by actual LLM calls.
|
|
238
|
+
|
|
239
|
+
class SimulatedResponse:
|
|
240
|
+
thinking = f"Processing iteration {iteration + 1}..."
|
|
241
|
+
content = f"This is a simulated response to: {user_input}"
|
|
242
|
+
tool_calls = [] if iteration > 0 else [] # No tools in simulation
|
|
243
|
+
|
|
244
|
+
await asyncio.sleep(0.1) # Simulate API latency
|
|
245
|
+
return SimulatedResponse()
|
|
246
|
+
|
|
247
|
+
def get_trajectory(self) -> list[dict[str, Any]]:
|
|
248
|
+
"""Get the full trajectory of the agent run."""
|
|
249
|
+
return self.history.copy()
|
|
250
|
+
|
|
251
|
+
def get_cost(self) -> float:
|
|
252
|
+
"""Get the total cost of the agent run."""
|
|
253
|
+
return self.total_cost
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# Example usage
|
|
257
|
+
async def main():
|
|
258
|
+
"""Example of how to use the agent."""
|
|
259
|
+
# Load agent from config
|
|
260
|
+
agent = MyAgent.from_config("config.yaml")
|
|
261
|
+
|
|
262
|
+
# Run agent
|
|
263
|
+
result = await agent.run("What is the weather like today?")
|
|
264
|
+
print(f"Result: {result}")
|
|
265
|
+
|
|
266
|
+
# Get metrics
|
|
267
|
+
print(f"Iterations: {agent.iteration_count}")
|
|
268
|
+
print(f"Cost: ${agent.get_cost():.4f}")
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Agent Configuration
|
|
2
|
+
# Template de configuración para un agente LMAgent
|
|
3
|
+
|
|
4
|
+
# Información básica
|
|
5
|
+
name: "my_agent"
|
|
6
|
+
display_name: "My Agent"
|
|
7
|
+
description: "Descripción de lo que hace el agente"
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
|
|
10
|
+
# Configuración de LLM
|
|
11
|
+
llm:
|
|
12
|
+
provider: "openai" # openai, anthropic, google
|
|
13
|
+
model: "gpt-4o" # Modelo específico
|
|
14
|
+
temperature: 0.7 # 0-1, más bajo = más determinístico
|
|
15
|
+
max_tokens: 4096 # Máximo de tokens por respuesta
|
|
16
|
+
|
|
17
|
+
# Límites
|
|
18
|
+
limits:
|
|
19
|
+
max_iterations: 10 # Máximo de pasos del agente
|
|
20
|
+
max_cost: 2.00 # USD máximo por ejecución
|
|
21
|
+
timeout_seconds: 300 # Timeout total
|
|
22
|
+
|
|
23
|
+
# System prompt
|
|
24
|
+
system_prompt:
|
|
25
|
+
file: "prompts/system.md" # Archivo con el prompt
|
|
26
|
+
# O inline:
|
|
27
|
+
# content: |
|
|
28
|
+
# You are an AI assistant...
|
|
29
|
+
|
|
30
|
+
# Herramientas disponibles
|
|
31
|
+
tools:
|
|
32
|
+
# Herramientas del registry global
|
|
33
|
+
from_registry:
|
|
34
|
+
- http_request
|
|
35
|
+
- file_read
|
|
36
|
+
- file_write
|
|
37
|
+
- file_search
|
|
38
|
+
|
|
39
|
+
# Herramientas custom locales
|
|
40
|
+
custom:
|
|
41
|
+
- module: "tools.custom_tool"
|
|
42
|
+
class: "CustomTool"
|
|
43
|
+
|
|
44
|
+
# Guardrails
|
|
45
|
+
guardrails:
|
|
46
|
+
# Herramientas que requieren confirmación
|
|
47
|
+
require_confirmation:
|
|
48
|
+
- file_write
|
|
49
|
+
- http_request
|
|
50
|
+
|
|
51
|
+
# Acciones bloqueadas
|
|
52
|
+
blocked_actions: []
|
|
53
|
+
|
|
54
|
+
# Patrones de código peligrosos a bloquear
|
|
55
|
+
dangerous_patterns:
|
|
56
|
+
- "rm -rf"
|
|
57
|
+
- "DROP TABLE"
|
|
58
|
+
|
|
59
|
+
# Logging
|
|
60
|
+
logging:
|
|
61
|
+
level: "INFO" # DEBUG, INFO, WARNING, ERROR
|
|
62
|
+
trajectory: true # Guardar trajectory completo
|
|
63
|
+
cost_tracking: true # Trackear costos
|
|
64
|
+
|
|
65
|
+
# Variables de entorno requeridas
|
|
66
|
+
required_env:
|
|
67
|
+
- OPENAI_API_KEY # API key del proveedor LLM
|
|
68
|
+
# - CUSTOM_API_KEY # Agregar variables custom
|
|
69
|
+
|
|
70
|
+
# Metadata
|
|
71
|
+
metadata:
|
|
72
|
+
author: "Tu Nombre"
|
|
73
|
+
created_at: "2024-01-01"
|
|
74
|
+
tags:
|
|
75
|
+
- "automation"
|
|
76
|
+
- "ai-agent"
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
You are {agent_name}, an AI assistant specialized in {domain}.
|
|
2
|
+
|
|
3
|
+
## Your Role
|
|
4
|
+
|
|
5
|
+
{Describe the role and responsibilities of this agent}
|
|
6
|
+
|
|
7
|
+
## Available Tools
|
|
8
|
+
|
|
9
|
+
You have access to the following tools:
|
|
10
|
+
|
|
11
|
+
### http_request
|
|
12
|
+
Make HTTP requests to external APIs. Use when you need to fetch data from or send data to external services.
|
|
13
|
+
|
|
14
|
+
Parameters:
|
|
15
|
+
- url (required): Full URL to request
|
|
16
|
+
- method (optional): HTTP method (GET, POST, PUT, DELETE). Default: GET
|
|
17
|
+
- headers (optional): Request headers
|
|
18
|
+
- body (optional): Request body for POST/PUT
|
|
19
|
+
|
|
20
|
+
### file_read
|
|
21
|
+
Read contents of files in the project.
|
|
22
|
+
|
|
23
|
+
Parameters:
|
|
24
|
+
- path (required): Relative path to the file
|
|
25
|
+
- start_line (optional): Starting line number
|
|
26
|
+
- end_line (optional): Ending line number
|
|
27
|
+
|
|
28
|
+
### file_write
|
|
29
|
+
Write or modify files in the project.
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
- path (required): Relative path to the file
|
|
33
|
+
- content (required): Content to write
|
|
34
|
+
- mode (optional): overwrite, append, or insert. Default: overwrite
|
|
35
|
+
|
|
36
|
+
### file_search
|
|
37
|
+
Search for patterns in project files.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
- pattern (required): Search pattern (regex supported)
|
|
41
|
+
- path (optional): Directory to search in. Default: "."
|
|
42
|
+
- include (optional): File patterns to include
|
|
43
|
+
- exclude (optional): File patterns to exclude
|
|
44
|
+
|
|
45
|
+
## How to Use Tools
|
|
46
|
+
|
|
47
|
+
When you need to take an action:
|
|
48
|
+
|
|
49
|
+
1. **Think first**: Consider which tool is most appropriate for the task
|
|
50
|
+
2. **Call the tool**: Provide all required parameters
|
|
51
|
+
3. **Wait for observation**: The tool will return a result
|
|
52
|
+
4. **Iterate or respond**: Based on the result, decide next steps
|
|
53
|
+
|
|
54
|
+
## Response Guidelines
|
|
55
|
+
|
|
56
|
+
- Be concise and direct in your responses
|
|
57
|
+
- When using data from tools, mention the source
|
|
58
|
+
- If a tool fails, explain what happened and try an alternative approach
|
|
59
|
+
- If you cannot complete a task, explain why clearly
|
|
60
|
+
- Structure complex responses with headings and bullet points
|
|
61
|
+
|
|
62
|
+
## Constraints
|
|
63
|
+
|
|
64
|
+
- Maximum cost per session: $2.00
|
|
65
|
+
- Maximum iterations: 10
|
|
66
|
+
- Do not access files outside the project directory
|
|
67
|
+
- Do not make changes to production systems without explicit confirmation
|
|
68
|
+
- Always validate input data before processing
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### Example 1: Finding information in files
|
|
73
|
+
|
|
74
|
+
User: "Find all functions that handle user authentication"
|
|
75
|
+
|
|
76
|
+
Thinking: I need to search for authentication-related code in the project.
|
|
77
|
+
|
|
78
|
+
Action: file_search(pattern="def.*auth|login|authenticate", include=["*.py"])
|
|
79
|
+
|
|
80
|
+
Observation: Found 5 matches in 3 files...
|
|
81
|
+
|
|
82
|
+
Response: "I found authentication-related functions in the following files:
|
|
83
|
+
1. `app/auth/service.py` - `authenticate_user()`, `validate_token()`
|
|
84
|
+
2. `app/routers/auth.py` - `login()`, `logout()`
|
|
85
|
+
3. `app/core/security.py` - `verify_password()`"
|
|
86
|
+
|
|
87
|
+
### Example 2: Making an API request
|
|
88
|
+
|
|
89
|
+
User: "Check if the external API is responding"
|
|
90
|
+
|
|
91
|
+
Thinking: I need to make a health check request to the external API.
|
|
92
|
+
|
|
93
|
+
Action: http_request(url="https://api.example.com/health", method="GET")
|
|
94
|
+
|
|
95
|
+
Observation: {"status": "healthy", "version": "1.2.3"}
|
|
96
|
+
|
|
97
|
+
Response: "The external API is responding correctly. Status: healthy, Version: 1.2.3"
|
|
98
|
+
|
|
99
|
+
## Output Format
|
|
100
|
+
|
|
101
|
+
When presenting findings or results:
|
|
102
|
+
|
|
103
|
+
1. **Summary**: Brief overview of what was found/done
|
|
104
|
+
2. **Details**: Structured breakdown with specifics
|
|
105
|
+
3. **Next Steps**: If applicable, suggest follow-up actions
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
Remember: You are here to help the user accomplish their tasks efficiently and accurately. Always prioritize clarity and correctness over speed.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# LMAgent n8n Automation Template
|
|
2
|
+
|
|
3
|
+
Template básico para flujos de automatización con n8n.
|
|
4
|
+
|
|
5
|
+
## Contenido
|
|
6
|
+
|
|
7
|
+
- `webhook-handler.json`: Un flujo simple que recibe un webhook y devuelve una respuesta JSON formateada.
|
|
8
|
+
|
|
9
|
+
## Cómo usar
|
|
10
|
+
|
|
11
|
+
1. Abre tu instancia de n8n.
|
|
12
|
+
2. Crea un nuevo workflow.
|
|
13
|
+
3. Ve a "Import from File" o copia el contenido del JSON y pégalo directamente en el canvas (Ctrl+V).
|
|
14
|
+
4. Activa el workflow y prueba la URL del webhook de prueba.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "LMAgent Webhook Handler",
|
|
3
|
+
"nodes": [
|
|
4
|
+
{
|
|
5
|
+
"parameters": {
|
|
6
|
+
"path": "webhook",
|
|
7
|
+
"responseMode": "lastNode",
|
|
8
|
+
"options": {}
|
|
9
|
+
},
|
|
10
|
+
"name": "Webhook",
|
|
11
|
+
"type": "n8n-nodes-base.webhook",
|
|
12
|
+
"typeVersion": 1,
|
|
13
|
+
"position": [
|
|
14
|
+
460,
|
|
15
|
+
300
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"parameters": {
|
|
20
|
+
"keepOnlySet": true,
|
|
21
|
+
"values": {
|
|
22
|
+
"string": [
|
|
23
|
+
{
|
|
24
|
+
"name": "message",
|
|
25
|
+
"value": "Hello from LMAgent Automation!"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "timestamp",
|
|
29
|
+
"value": "={{ $now }}"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"options": {}
|
|
34
|
+
},
|
|
35
|
+
"name": "Format Response",
|
|
36
|
+
"type": "n8n-nodes-base.set",
|
|
37
|
+
"typeVersion": 2,
|
|
38
|
+
"position": [
|
|
39
|
+
680,
|
|
40
|
+
300
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"connections": {
|
|
45
|
+
"Webhook": {
|
|
46
|
+
"main": [
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
"node": "Format Response",
|
|
50
|
+
"type": "main",
|
|
51
|
+
"index": 0
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# LMAgent Backend Node Template
|
|
2
|
+
|
|
3
|
+
Template básico para backend con Node.js, Express y TypeScript.
|
|
4
|
+
|
|
5
|
+
## Estructura
|
|
6
|
+
|
|
7
|
+
- `src/`: Código fuente
|
|
8
|
+
- `dist/`: Código compilado
|
|
9
|
+
- `Dockerfile`: Configuración para despliegue
|
|
10
|
+
|
|
11
|
+
## Scripts
|
|
12
|
+
|
|
13
|
+
- `npm run dev`: Ejecuta en modo desarrollo
|
|
14
|
+
- `npm run build`: Compila el proyecto
|
|
15
|
+
- `npm start`: Ejecuta la versión compilada
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lmagent-backend-node",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "LMAgent Node.js Backend Template",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node dist/index.js",
|
|
8
|
+
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"lint": "eslint src/**/*.ts",
|
|
11
|
+
"format": "prettier --write src/**/*.ts"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"cors": "^2.8.5",
|
|
15
|
+
"dotenv": "^16.3.1",
|
|
16
|
+
"express": "^4.18.2",
|
|
17
|
+
"helmet": "^7.0.0",
|
|
18
|
+
"morgan": "^1.10.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/cors": "^2.8.13",
|
|
22
|
+
"@types/express": "^4.17.17",
|
|
23
|
+
"@types/morgan": "^1.9.4",
|
|
24
|
+
"@types/node": "^20.4.5",
|
|
25
|
+
"eslint": "^8.46.0",
|
|
26
|
+
"prettier": "^3.0.0",
|
|
27
|
+
"ts-node-dev": "^2.0.0",
|
|
28
|
+
"typescript": "^5.1.6"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import morgan from 'morgan';
|
|
3
|
+
import helmet from 'helmet';
|
|
4
|
+
import cors from 'cors';
|
|
5
|
+
import { router } from './routes';
|
|
6
|
+
|
|
7
|
+
const app = express();
|
|
8
|
+
const port = process.env.PORT || 3000;
|
|
9
|
+
|
|
10
|
+
app.use(morgan('dev'));
|
|
11
|
+
app.use(helmet());
|
|
12
|
+
app.use(cors());
|
|
13
|
+
app.use(express.json());
|
|
14
|
+
|
|
15
|
+
app.use('/api', router);
|
|
16
|
+
|
|
17
|
+
app.listen(port, () => {
|
|
18
|
+
console.log(`Server is running at http://localhost:${port}`);
|
|
19
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": [
|
|
6
|
+
"es2020"
|
|
7
|
+
],
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src/**/*"
|
|
17
|
+
],
|
|
18
|
+
"exclude": [
|
|
19
|
+
"node_modules",
|
|
20
|
+
"**/*.test.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
FROM python:3.11-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /code
|
|
4
|
+
|
|
5
|
+
COPY ./requirements.txt /code/requirements.txt
|
|
6
|
+
|
|
7
|
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
8
|
+
|
|
9
|
+
COPY ./app /code/app
|
|
10
|
+
|
|
11
|
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|