a4e 0.1.5__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.
- a4e/__init__.py +0 -0
- a4e/cli.py +47 -0
- a4e/cli_commands/__init__.py +5 -0
- a4e/cli_commands/add.py +376 -0
- a4e/cli_commands/deploy.py +149 -0
- a4e/cli_commands/dev.py +162 -0
- a4e/cli_commands/info.py +206 -0
- a4e/cli_commands/init.py +211 -0
- a4e/cli_commands/list.py +227 -0
- a4e/cli_commands/mcp.py +504 -0
- a4e/cli_commands/remove.py +197 -0
- a4e/cli_commands/update.py +285 -0
- a4e/cli_commands/validate.py +117 -0
- a4e/core.py +109 -0
- a4e/dev_runner.py +425 -0
- a4e/server.py +86 -0
- a4e/templates/agent.md.j2 +168 -0
- a4e/templates/agent.py.j2 +15 -0
- a4e/templates/agents.md.j2 +99 -0
- a4e/templates/metadata.json.j2 +20 -0
- a4e/templates/prompt.md.j2 +20 -0
- a4e/templates/prompts/agent.md.j2 +206 -0
- a4e/templates/skills/agents.md.j2 +110 -0
- a4e/templates/skills/skill.md.j2 +120 -0
- a4e/templates/support_module.py.j2 +84 -0
- a4e/templates/tool.py.j2 +60 -0
- a4e/templates/tools/agent.md.j2 +192 -0
- a4e/templates/view.tsx.j2 +21 -0
- a4e/templates/views/agent.md.j2 +219 -0
- a4e/tools/__init__.py +70 -0
- a4e/tools/agent_tools/__init__.py +12 -0
- a4e/tools/agent_tools/add_support_module.py +95 -0
- a4e/tools/agent_tools/add_tool.py +115 -0
- a4e/tools/agent_tools/list_tools.py +28 -0
- a4e/tools/agent_tools/remove_tool.py +69 -0
- a4e/tools/agent_tools/update_tool.py +123 -0
- a4e/tools/deploy/__init__.py +8 -0
- a4e/tools/deploy/deploy.py +59 -0
- a4e/tools/dev/__init__.py +10 -0
- a4e/tools/dev/check_environment.py +79 -0
- a4e/tools/dev/dev_start.py +30 -0
- a4e/tools/dev/dev_stop.py +26 -0
- a4e/tools/project/__init__.py +10 -0
- a4e/tools/project/get_agent_info.py +66 -0
- a4e/tools/project/get_instructions.py +216 -0
- a4e/tools/project/initialize_project.py +231 -0
- a4e/tools/schemas/__init__.py +8 -0
- a4e/tools/schemas/generate_schemas.py +278 -0
- a4e/tools/skills/__init__.py +12 -0
- a4e/tools/skills/add_skill.py +105 -0
- a4e/tools/skills/helpers.py +137 -0
- a4e/tools/skills/list_skills.py +54 -0
- a4e/tools/skills/remove_skill.py +74 -0
- a4e/tools/skills/update_skill.py +150 -0
- a4e/tools/validation/__init__.py +8 -0
- a4e/tools/validation/validate.py +389 -0
- a4e/tools/views/__init__.py +12 -0
- a4e/tools/views/add_view.py +40 -0
- a4e/tools/views/helpers.py +91 -0
- a4e/tools/views/list_views.py +27 -0
- a4e/tools/views/remove_view.py +73 -0
- a4e/tools/views/update_view.py +124 -0
- a4e/utils/dev_manager.py +253 -0
- a4e/utils/schema_generator.py +255 -0
- a4e-0.1.5.dist-info/METADATA +427 -0
- a4e-0.1.5.dist-info/RECORD +70 -0
- a4e-0.1.5.dist-info/WHEEL +5 -0
- a4e-0.1.5.dist-info/entry_points.txt +2 -0
- a4e-0.1.5.dist-info/licenses/LICENSE +21 -0
- a4e-0.1.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# AGENTS.md — {{ display_name }}
|
|
2
|
+
|
|
3
|
+
> **⚠️ IMPORTANT:** Keep this file updated as you modify the agent. This ensures AI coding agents can work effectively with your agent project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
**{{ display_name }}** is an A4E agent in the **{{ category }}** category.
|
|
8
|
+
|
|
9
|
+
{{ description }}
|
|
10
|
+
|
|
11
|
+
## Project Structure
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
{{ agent_id }}/
|
|
15
|
+
├── AGENTS.md # This file - context for AI coding agents
|
|
16
|
+
├── agent.py # Agent factory and initialization
|
|
17
|
+
├── metadata.json # Agent metadata for the marketplace
|
|
18
|
+
├── prompts/
|
|
19
|
+
│ ├── agent.md # Main agent personality and instructions
|
|
20
|
+
│ ├── reviewer.md # Review/validation prompts
|
|
21
|
+
│ └── view_renderer.md # View rendering instructions
|
|
22
|
+
├── tools/
|
|
23
|
+
│ ├── AGENTS.md # Tool-specific instructions
|
|
24
|
+
│ ├── schemas.json # Auto-generated tool schemas
|
|
25
|
+
│ └── *.py # Python tool files
|
|
26
|
+
└── views/
|
|
27
|
+
├── AGENTS.md # View-specific instructions
|
|
28
|
+
├── schemas.json # Auto-generated view schemas
|
|
29
|
+
└── */view.tsx # React view components
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Reference
|
|
33
|
+
|
|
34
|
+
| Action | Command / Location |
|
|
35
|
+
| ----------------------- | ----------------------------------------- |
|
|
36
|
+
| Add a tool | Create `tools/<tool_name>.py` with @tool |
|
|
37
|
+
| Add a view | Create `views/<view_id>/view.tsx` |
|
|
38
|
+
| Modify personality | Edit `prompts/agent.md` |
|
|
39
|
+
| Update metadata | Edit `metadata.json` |
|
|
40
|
+
| Regenerate schemas | Run `generate_schemas` MCP tool |
|
|
41
|
+
| Start dev server | Run `dev_start` MCP tool |
|
|
42
|
+
|
|
43
|
+
## Code Style
|
|
44
|
+
|
|
45
|
+
- Python 3.11+ for tools
|
|
46
|
+
- TypeScript/React for views
|
|
47
|
+
- Use type hints for all function parameters
|
|
48
|
+
- Snake_case for Python, camelCase for TypeScript
|
|
49
|
+
- All code and comments in English
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
Tools are Python functions that give the agent capabilities. Each tool:
|
|
54
|
+
- Lives in `tools/<tool_name>.py`
|
|
55
|
+
- Uses the `@tool` decorator from `a4e.sdk`
|
|
56
|
+
- Returns a dictionary with `status` and relevant data
|
|
57
|
+
- Has comprehensive docstrings for schema generation
|
|
58
|
+
|
|
59
|
+
See `tools/AGENTS.md` for detailed tool development guide.
|
|
60
|
+
|
|
61
|
+
## Views
|
|
62
|
+
|
|
63
|
+
Views are React components for rich UI responses. Each view:
|
|
64
|
+
- Lives in `views/<view_id>/view.tsx`
|
|
65
|
+
- Exports a default React component
|
|
66
|
+
- Receives props defined in the component interface
|
|
67
|
+
- Uses the A4E SDK for integrations
|
|
68
|
+
|
|
69
|
+
See `views/AGENTS.md` for detailed view development guide.
|
|
70
|
+
|
|
71
|
+
## Schema Generation
|
|
72
|
+
|
|
73
|
+
Schemas are auto-generated from code:
|
|
74
|
+
- `tools/schemas.json` - Generated from Python tool decorators and docstrings
|
|
75
|
+
- `views/schemas.json` - Generated from TypeScript prop interfaces
|
|
76
|
+
|
|
77
|
+
**Never edit schema files manually** — they are regenerated automatically.
|
|
78
|
+
|
|
79
|
+
## Development Workflow
|
|
80
|
+
|
|
81
|
+
1. **Edit code** — Modify tools, views, or prompts as needed
|
|
82
|
+
2. **Regenerate schemas** — Run `generate_schemas` after tool/view changes
|
|
83
|
+
3. **Test locally** — Use `dev_start` to run the agent locally
|
|
84
|
+
4. **Deploy** — Use `deploy` to publish to A4E Hub
|
|
85
|
+
|
|
86
|
+
## Security Notes
|
|
87
|
+
|
|
88
|
+
- Never hardcode API keys or secrets in code
|
|
89
|
+
- Use environment variables for sensitive configuration
|
|
90
|
+
- Validate all user inputs in tools
|
|
91
|
+
- Sanitize data before rendering in views
|
|
92
|
+
|
|
93
|
+
## Category: {{ category }}
|
|
94
|
+
|
|
95
|
+
This agent is designed for {{ category }} use cases. Keep this focus in mind when:
|
|
96
|
+
- Adding new tools (should relate to {{ category }})
|
|
97
|
+
- Designing views (should serve {{ category }} needs)
|
|
98
|
+
- Writing prompts (should maintain {{ category }} expertise)
|
|
99
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": {{ agent_id|tojson }},
|
|
3
|
+
"name": {{ display_name|tojson }},
|
|
4
|
+
"shortDescription": {{ description|tojson }},
|
|
5
|
+
"description": {{ description|tojson }},
|
|
6
|
+
"avatar": "",
|
|
7
|
+
"icon": "",
|
|
8
|
+
"category": {{ category|tojson }},
|
|
9
|
+
"rating": 0.0,
|
|
10
|
+
"reviewCount": 0,
|
|
11
|
+
"featured": false,
|
|
12
|
+
"tags": [],
|
|
13
|
+
"capabilities": [],
|
|
14
|
+
"pricing": "free",
|
|
15
|
+
"author": "Unknown",
|
|
16
|
+
"version": "1.0.0",
|
|
17
|
+
"status": "draft",
|
|
18
|
+
"longDescription": {{ description|tojson }},
|
|
19
|
+
"reviews": []
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# {{ display_name }}
|
|
2
|
+
|
|
3
|
+
You are {{ display_name }}, a specialized AI assistant for {{ category }}.
|
|
4
|
+
|
|
5
|
+
## Your Mission
|
|
6
|
+
|
|
7
|
+
{{ description }}
|
|
8
|
+
|
|
9
|
+
## Capabilities
|
|
10
|
+
|
|
11
|
+
- Helpful assistance
|
|
12
|
+
- Tool usage
|
|
13
|
+
- View display
|
|
14
|
+
|
|
15
|
+
## Conversation Guidelines
|
|
16
|
+
|
|
17
|
+
1. Be helpful and clear
|
|
18
|
+
2. Use views to display rich information
|
|
19
|
+
3. Use tools to perform actions
|
|
20
|
+
4. Hand over to other agents when appropriate
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# AGENTS.md — Prompts Directory
|
|
2
|
+
|
|
3
|
+
> This file provides context and instructions for AI coding agents working on prompts in this A4E agent project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This `prompts/` directory contains markdown files that define the agent's personality, behavior, and specialized instructions. These prompts are loaded and used by the A4E runtime.
|
|
8
|
+
|
|
9
|
+
## Directory Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
prompts/
|
|
13
|
+
├── AGENTS.md # This file
|
|
14
|
+
├── agent.md # Main agent personality and instructions
|
|
15
|
+
├── reviewer.md # Review/validation prompts (optional)
|
|
16
|
+
└── view_renderer.md # View rendering instructions (optional)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Prompt Files
|
|
20
|
+
|
|
21
|
+
### agent.md (Required)
|
|
22
|
+
|
|
23
|
+
The main prompt that defines the agent's:
|
|
24
|
+
- **Identity**: Who the agent is and its expertise
|
|
25
|
+
- **Mission**: Primary goals and purpose
|
|
26
|
+
- **Capabilities**: What the agent can do
|
|
27
|
+
- **Guidelines**: How to interact with users
|
|
28
|
+
- **Constraints**: What the agent should avoid
|
|
29
|
+
|
|
30
|
+
### reviewer.md (Optional)
|
|
31
|
+
|
|
32
|
+
Used for review and validation workflows:
|
|
33
|
+
- Quality checks on agent responses
|
|
34
|
+
- Fact verification instructions
|
|
35
|
+
- Style and tone guidelines
|
|
36
|
+
|
|
37
|
+
### view_renderer.md (Optional)
|
|
38
|
+
|
|
39
|
+
Instructions for rendering views:
|
|
40
|
+
- When to use specific views
|
|
41
|
+
- Data formatting for views
|
|
42
|
+
- Fallback behavior
|
|
43
|
+
|
|
44
|
+
## Writing Effective Prompts
|
|
45
|
+
|
|
46
|
+
### Structure
|
|
47
|
+
|
|
48
|
+
Use clear markdown structure:
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
# Agent Name
|
|
52
|
+
|
|
53
|
+
You are [Agent Name], a specialized AI assistant for [domain].
|
|
54
|
+
|
|
55
|
+
## Your Mission
|
|
56
|
+
|
|
57
|
+
[Clear statement of purpose]
|
|
58
|
+
|
|
59
|
+
## Capabilities
|
|
60
|
+
|
|
61
|
+
- Capability 1
|
|
62
|
+
- Capability 2
|
|
63
|
+
- Capability 3
|
|
64
|
+
|
|
65
|
+
## Guidelines
|
|
66
|
+
|
|
67
|
+
1. Be helpful and clear
|
|
68
|
+
2. Use tools appropriately
|
|
69
|
+
3. Display rich views when beneficial
|
|
70
|
+
|
|
71
|
+
## Constraints
|
|
72
|
+
|
|
73
|
+
- Never do X
|
|
74
|
+
- Always verify Y
|
|
75
|
+
- Avoid Z in responses
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Best Practices
|
|
79
|
+
|
|
80
|
+
1. **Be specific**: Define exact behaviors, not vague guidelines
|
|
81
|
+
2. **Use examples**: Show expected input/output patterns
|
|
82
|
+
3. **Set boundaries**: Clearly state what the agent should NOT do
|
|
83
|
+
4. **Maintain consistency**: Keep tone and style uniform
|
|
84
|
+
5. **Reference tools**: Mention available tools and when to use them
|
|
85
|
+
|
|
86
|
+
### Variables and Templates
|
|
87
|
+
|
|
88
|
+
Prompts can use template variables:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
# {{ display_name }}
|
|
92
|
+
|
|
93
|
+
You are {{ display_name }}, specialized in {{ category }}.
|
|
94
|
+
|
|
95
|
+
{{ description }}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Available variables:
|
|
99
|
+
- `{{ display_name }}` - Human-readable agent name
|
|
100
|
+
- `{{ category }}` - Agent category
|
|
101
|
+
- `{{ description }}` - Agent description
|
|
102
|
+
|
|
103
|
+
## Tool Integration
|
|
104
|
+
|
|
105
|
+
Reference tools in your prompts:
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
## Available Tools
|
|
109
|
+
|
|
110
|
+
- **calculate_bmi**: Use when user asks about BMI calculations
|
|
111
|
+
- **fetch_nutrition**: Use to get nutritional information
|
|
112
|
+
- **create_meal_plan**: Use for meal planning requests
|
|
113
|
+
|
|
114
|
+
When a user asks about nutrition, first use `fetch_nutrition` to get data,
|
|
115
|
+
then present it using the `NutritionView` component.
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## View Integration
|
|
119
|
+
|
|
120
|
+
Guide view usage in prompts:
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
## View Usage
|
|
124
|
+
|
|
125
|
+
When displaying results, use appropriate views:
|
|
126
|
+
|
|
127
|
+
- **Welcome**: Show on first interaction
|
|
128
|
+
- **MealPlan**: Display meal plans with full details
|
|
129
|
+
- **NutritionFacts**: Show nutritional breakdowns
|
|
130
|
+
|
|
131
|
+
Always prefer views over plain text for structured data.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Prompt Engineering Tips
|
|
135
|
+
|
|
136
|
+
### Context Setting
|
|
137
|
+
|
|
138
|
+
```markdown
|
|
139
|
+
You are an expert nutritionist with 20 years of experience.
|
|
140
|
+
You specialize in personalized meal planning and dietary advice.
|
|
141
|
+
Your approach is warm, encouraging, and evidence-based.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Behavioral Guidelines
|
|
145
|
+
|
|
146
|
+
```markdown
|
|
147
|
+
## Response Format
|
|
148
|
+
|
|
149
|
+
1. Acknowledge the user's question
|
|
150
|
+
2. Provide relevant information
|
|
151
|
+
3. Offer actionable next steps
|
|
152
|
+
4. Ask follow-up questions if needed
|
|
153
|
+
|
|
154
|
+
## Tone
|
|
155
|
+
|
|
156
|
+
- Professional but friendly
|
|
157
|
+
- Encouraging, not judgmental
|
|
158
|
+
- Clear and concise
|
|
159
|
+
- Use simple language
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Error Handling
|
|
163
|
+
|
|
164
|
+
```markdown
|
|
165
|
+
## When You Don't Know
|
|
166
|
+
|
|
167
|
+
If you cannot answer a question:
|
|
168
|
+
1. Acknowledge the limitation honestly
|
|
169
|
+
2. Suggest alternative resources
|
|
170
|
+
3. Offer to help with related topics
|
|
171
|
+
4. Never make up information
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Testing Prompts
|
|
175
|
+
|
|
176
|
+
Before deployment:
|
|
177
|
+
|
|
178
|
+
1. **Read through** the entire prompt for clarity
|
|
179
|
+
2. **Test edge cases** - unusual inputs and requests
|
|
180
|
+
3. **Check consistency** - does the agent maintain character?
|
|
181
|
+
4. **Verify tool usage** - are tools called appropriately?
|
|
182
|
+
5. **Review view rendering** - are views displayed correctly?
|
|
183
|
+
|
|
184
|
+
## Troubleshooting
|
|
185
|
+
|
|
186
|
+
### Agent not following instructions
|
|
187
|
+
|
|
188
|
+
- Make instructions more explicit
|
|
189
|
+
- Add examples of expected behavior
|
|
190
|
+
- Reduce ambiguity in guidelines
|
|
191
|
+
- Check for conflicting instructions
|
|
192
|
+
|
|
193
|
+
### Inconsistent personality
|
|
194
|
+
|
|
195
|
+
- Strengthen identity statements
|
|
196
|
+
- Add more context about the character
|
|
197
|
+
- Include sample responses
|
|
198
|
+
- Review and remove conflicting guidelines
|
|
199
|
+
|
|
200
|
+
### Tool misuse
|
|
201
|
+
|
|
202
|
+
- Clarify when each tool should be used
|
|
203
|
+
- Provide examples of correct tool invocation
|
|
204
|
+
- Add constraints about tool usage
|
|
205
|
+
- Define fallback behavior
|
|
206
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Skills
|
|
2
|
+
|
|
3
|
+
> Skills are the orchestration layer that connects user intents → tools → views.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
skills/
|
|
9
|
+
├── AGENTS.md # This file
|
|
10
|
+
├── schemas.json # All skills definitions
|
|
11
|
+
└── {skill_id}/
|
|
12
|
+
└── SKILL.md # Instructions for View Renderer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How Skills Work
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
User Message → Skill Selector → Matched Skill → View Renderer → Output
|
|
19
|
+
↓ ↓ ↓
|
|
20
|
+
schemas.json SKILL.md tools/ + views/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
1. **Skill Selector** reads `schemas.json` to find matching skill by `intent_triggers`
|
|
24
|
+
2. **View Renderer** reads `SKILL.md` for instructions on how to call tools and prepare view params
|
|
25
|
+
3. **Output** is rendered using the specified view from `views/`
|
|
26
|
+
|
|
27
|
+
## Creating Skills
|
|
28
|
+
|
|
29
|
+
Use the MCP tool `add_skill`:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
add_skill(
|
|
33
|
+
skill_id="show_products",
|
|
34
|
+
name="Show Products",
|
|
35
|
+
description="Display product catalog when user wants to browse",
|
|
36
|
+
intent_triggers=["show products", "ver productos", "browse catalog"],
|
|
37
|
+
output_view="products_list",
|
|
38
|
+
internal_tools=["get_products"],
|
|
39
|
+
agent_name="{{ agent_id }}"
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Parameters
|
|
44
|
+
|
|
45
|
+
| Parameter | Required | Description |
|
|
46
|
+
|-----------|----------|-------------|
|
|
47
|
+
| `skill_id` | ✅ | Unique ID (snake_case) |
|
|
48
|
+
| `name` | ✅ | Human-readable name |
|
|
49
|
+
| `description` | ✅ | What the skill does and when to use it |
|
|
50
|
+
| `intent_triggers` | ✅ | List of phrases that trigger this skill |
|
|
51
|
+
| `output_view` | ✅ | View ID to render (or "NONE") |
|
|
52
|
+
| `internal_tools` | ❌ | List of tools the skill uses |
|
|
53
|
+
| `requires_auth` | ❌ | Whether auth is required (default: false) |
|
|
54
|
+
|
|
55
|
+
## schemas.json Format
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"skill_id": {
|
|
60
|
+
"id": "skill_id",
|
|
61
|
+
"name": "Skill Name",
|
|
62
|
+
"description": "What this skill does",
|
|
63
|
+
"intent_triggers": ["phrase 1", "phrase 2"],
|
|
64
|
+
"requires_auth": false,
|
|
65
|
+
"internal_tools": ["tool_name"],
|
|
66
|
+
"output": {
|
|
67
|
+
"view": "view_id"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## SKILL.md Format
|
|
74
|
+
|
|
75
|
+
Each skill folder contains a `SKILL.md` that documents:
|
|
76
|
+
|
|
77
|
+
1. **Purpose** - What the skill does
|
|
78
|
+
2. **When to Use** - Intent triggers
|
|
79
|
+
3. **Instructions for View Renderer** - How to call tools and prepare params
|
|
80
|
+
4. **Expected Output** - Example code
|
|
81
|
+
5. **Parameter Extraction Rules** - How to map user intents to parameters
|
|
82
|
+
|
|
83
|
+
## Dependencies
|
|
84
|
+
|
|
85
|
+
Skills connect to:
|
|
86
|
+
|
|
87
|
+
- **Tools** (`tools/`) - Python functions that fetch/process data
|
|
88
|
+
- **Views** (`views/`) - React components that render the UI
|
|
89
|
+
|
|
90
|
+
### Validation
|
|
91
|
+
|
|
92
|
+
Before creating a skill:
|
|
93
|
+
1. The `output_view` must exist in `views/`
|
|
94
|
+
2. The `internal_tools` should exist in `tools/schemas.json`
|
|
95
|
+
|
|
96
|
+
## Listing Skills
|
|
97
|
+
|
|
98
|
+
Use the MCP tool `list_skills`:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
list_skills(agent_name="{{ agent_id }}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Best Practices
|
|
105
|
+
|
|
106
|
+
1. **Specific triggers** - Avoid generic phrases that could match multiple skills
|
|
107
|
+
2. **Clear descriptions** - Help the Skill Selector understand when to use this skill
|
|
108
|
+
3. **Document SKILL.md** - The View Renderer relies on this for execution
|
|
109
|
+
4. **Validate dependencies** - Ensure tools and views exist before creating skills
|
|
110
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# {{ skill_name }} Skill
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
{{ description }}
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
This skill is triggered by phrases like:
|
|
10
|
+
{% for trigger in intent_triggers %}
|
|
11
|
+
- "{{ trigger }}"
|
|
12
|
+
{% endfor %}
|
|
13
|
+
|
|
14
|
+
## Instructions for View Renderer
|
|
15
|
+
|
|
16
|
+
{% if internal_tools %}
|
|
17
|
+
### 1. Call Internal Tools
|
|
18
|
+
|
|
19
|
+
**IMPORTANT**: All tools use the `params: Dict[str, Any]` pattern. Pass parameters as a dictionary:
|
|
20
|
+
|
|
21
|
+
{% for tool in internal_tools %}
|
|
22
|
+
```python
|
|
23
|
+
# Call {{ tool }} with required parameters
|
|
24
|
+
{{ tool }}_result = {{ tool }}({
|
|
25
|
+
# Add required parameters here as key-value pairs
|
|
26
|
+
# Example: "param_name": value
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
{% endfor %}
|
|
30
|
+
|
|
31
|
+
### 2. Prepare View Parameters
|
|
32
|
+
|
|
33
|
+
Extract data from tool results and build the view params object:
|
|
34
|
+
|
|
35
|
+
{% else %}
|
|
36
|
+
### 1. Prepare View Parameters
|
|
37
|
+
|
|
38
|
+
This skill has no internal tools. Build the view params directly:
|
|
39
|
+
|
|
40
|
+
{% endif %}
|
|
41
|
+
{% if view_props %}
|
|
42
|
+
```python
|
|
43
|
+
view_params = {
|
|
44
|
+
{% for prop_name, prop_info in view_props.items() %}
|
|
45
|
+
{% set prop_type = prop_info.get('type', 'string') if prop_info is mapping else prop_info %}
|
|
46
|
+
{% if internal_tools %}
|
|
47
|
+
"{{ prop_name }}": {{ internal_tools[0] }}_result.get("{{ prop_name }}"), # {{ prop_type }}
|
|
48
|
+
{% else %}
|
|
49
|
+
"{{ prop_name }}": ..., # {{ prop_type }}{% if prop_info is mapping and prop_info.get('description') %} - {{ prop_info.get('description') }}{% endif %}
|
|
50
|
+
|
|
51
|
+
{% endif %}
|
|
52
|
+
{% endfor %}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### View Props Reference
|
|
57
|
+
|
|
58
|
+
| Property | Type | Description |
|
|
59
|
+
|----------|------|-------------|
|
|
60
|
+
{% for prop_name, prop_info in view_props.items() %}
|
|
61
|
+
| `{{ prop_name }}` | {{ prop_info.get('type', 'any') if prop_info is mapping else prop_info }} | {{ prop_info.get('description', '-') if prop_info is mapping else '-' }} |
|
|
62
|
+
{% endfor %}
|
|
63
|
+
{% else %}
|
|
64
|
+
```python
|
|
65
|
+
view_params = {
|
|
66
|
+
# Define view parameters based on tool results
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
{% endif %}
|
|
70
|
+
|
|
71
|
+
## Example Implementation
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
{% if internal_tools %}
|
|
75
|
+
# Step 1: Call the required tools with params dict pattern
|
|
76
|
+
{% for tool in internal_tools %}
|
|
77
|
+
{{ tool }}_data = {{ tool }}({
|
|
78
|
+
# Add your parameters here
|
|
79
|
+
})
|
|
80
|
+
{% endfor %}
|
|
81
|
+
|
|
82
|
+
# Step 2: Extract data and build view_params
|
|
83
|
+
{% endif %}
|
|
84
|
+
view_params = {
|
|
85
|
+
{% for prop_name, prop_info in view_props.items() %}
|
|
86
|
+
{% set prop_type = prop_info.get('type', 'string') if prop_info is mapping else prop_info %}
|
|
87
|
+
{% if prop_type == 'string' %}
|
|
88
|
+
"{{ prop_name }}": "Sample {{ prop_name }}",
|
|
89
|
+
{% elif prop_type == 'number' or prop_type == 'integer' %}
|
|
90
|
+
"{{ prop_name }}": 0,
|
|
91
|
+
{% elif prop_type == 'boolean' %}
|
|
92
|
+
"{{ prop_name }}": False,
|
|
93
|
+
{% elif prop_type == 'array' %}
|
|
94
|
+
"{{ prop_name }}": [],
|
|
95
|
+
{% elif prop_type == 'object' %}
|
|
96
|
+
"{{ prop_name }}": {},
|
|
97
|
+
{% else %}
|
|
98
|
+
"{{ prop_name }}": None,
|
|
99
|
+
{% endif %}
|
|
100
|
+
{% endfor %}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Parameter Extraction Rules
|
|
105
|
+
|
|
106
|
+
When extracting parameters from the user's message:
|
|
107
|
+
|
|
108
|
+
| User Intent | Parameters to Extract |
|
|
109
|
+
|-------------|----------------------|
|
|
110
|
+
{% for trigger in intent_triggers[:3] %}
|
|
111
|
+
| "{{ trigger }}" | Analyze message for relevant values |
|
|
112
|
+
{% endfor %}
|
|
113
|
+
|
|
114
|
+
## Important Notes
|
|
115
|
+
|
|
116
|
+
- **Output view:** `{{ output_view }}`
|
|
117
|
+
{% if requires_auth %}- **Authentication:** Required - ensure user is authenticated{% else %}- **Authentication:** Not required{% endif %}
|
|
118
|
+
{% if internal_tools %}- **Tool dependencies:** {{ internal_tools | join(', ') }}{% endif %}
|
|
119
|
+
- **Tool calling pattern:** Always use `tool_name({"param": value})` format
|
|
120
|
+
- **Error handling:** Check tool results for `status: "success"` before using data
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
{{ module_name | replace('_', ' ') | title }} - Support Module for {{ agent_name }}
|
|
3
|
+
|
|
4
|
+
{{ description }}
|
|
5
|
+
|
|
6
|
+
This module is designed to work in both:
|
|
7
|
+
1. Direct Python execution
|
|
8
|
+
2. exec() context (when loaded by A4E main application)
|
|
9
|
+
"""
|
|
10
|
+
# Ensure __name__ is defined for exec() context compatibility
|
|
11
|
+
if '__name__' not in dir():
|
|
12
|
+
__name__ = "{{ module_name }}"
|
|
13
|
+
|
|
14
|
+
import sys
|
|
15
|
+
import os
|
|
16
|
+
from typing import Dict, Any, Optional, List
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _ensure_path():
|
|
20
|
+
"""Add this directory to sys.path if not already there."""
|
|
21
|
+
if '__file__' in dir():
|
|
22
|
+
module_dir = os.path.dirname(globals()['__file__'])
|
|
23
|
+
if module_dir not in sys.path:
|
|
24
|
+
sys.path.insert(0, module_dir)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Ensure path is set up
|
|
28
|
+
_ensure_path()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# =============================================================================
|
|
32
|
+
# {{ module_name | upper }} IMPLEMENTATION
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
# TODO: Implement your {{ module_name }} logic here
|
|
36
|
+
# Example functions:
|
|
37
|
+
|
|
38
|
+
def get_data(key: str) -> Optional[Dict[str, Any]]:
|
|
39
|
+
"""
|
|
40
|
+
Get data by key.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
key: The data key to retrieve
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Data dictionary or None if not found
|
|
47
|
+
"""
|
|
48
|
+
# TODO: Implement data retrieval
|
|
49
|
+
return {"key": key, "value": "sample"}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def save_data(key: str, data: Dict[str, Any]) -> bool:
|
|
53
|
+
"""
|
|
54
|
+
Save data with key.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
key: The data key
|
|
58
|
+
data: The data to save
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
True if successful, False otherwise
|
|
62
|
+
"""
|
|
63
|
+
# TODO: Implement data storage
|
|
64
|
+
return True
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# =============================================================================
|
|
68
|
+
# MODULE SELF-TEST
|
|
69
|
+
# =============================================================================
|
|
70
|
+
|
|
71
|
+
# Only run when executed directly (not when exec'd by the main app)
|
|
72
|
+
if globals().get('__name__') == "__main__":
|
|
73
|
+
print(f"Testing {__name__} module...")
|
|
74
|
+
|
|
75
|
+
# Test get_data
|
|
76
|
+
result = get_data("test_key")
|
|
77
|
+
print(f"get_data result: {result}")
|
|
78
|
+
|
|
79
|
+
# Test save_data
|
|
80
|
+
success = save_data("test_key", {"test": "data"})
|
|
81
|
+
print(f"save_data success: {success}")
|
|
82
|
+
|
|
83
|
+
print("All tests passed!")
|
|
84
|
+
|