ema-mcp-toolkit 0.2.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/README.md +338 -0
- package/config.example.yaml +32 -0
- package/dist/cli/index.js +333 -0
- package/dist/config.js +136 -0
- package/dist/emaClient.js +398 -0
- package/dist/index.js +109 -0
- package/dist/mcp/handlers-consolidated.js +851 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/prompts.js +1753 -0
- package/dist/mcp/resources.js +624 -0
- package/dist/mcp/server.js +4585 -0
- package/dist/mcp/tools-consolidated.js +590 -0
- package/dist/mcp/tools-legacy.js +736 -0
- package/dist/models.js +8 -0
- package/dist/scheduler.js +21 -0
- package/dist/sdk/client.js +788 -0
- package/dist/sdk/config.js +136 -0
- package/dist/sdk/contracts.js +429 -0
- package/dist/sdk/generation-schema.js +189 -0
- package/dist/sdk/index.js +39 -0
- package/dist/sdk/knowledge.js +2780 -0
- package/dist/sdk/models.js +8 -0
- package/dist/sdk/state.js +88 -0
- package/dist/sdk/sync-options.js +216 -0
- package/dist/sdk/sync.js +220 -0
- package/dist/sdk/validation-rules.js +355 -0
- package/dist/sdk/workflow-generator.js +291 -0
- package/dist/sdk/workflow-intent.js +1585 -0
- package/dist/state.js +88 -0
- package/dist/sync.js +416 -0
- package/dist/syncOptions.js +216 -0
- package/dist/ui.js +334 -0
- package/docs/advisor-comms-assistant-fixes.md +175 -0
- package/docs/api-contracts.md +216 -0
- package/docs/auto-builder-analysis.md +271 -0
- package/docs/data-architecture.md +166 -0
- package/docs/ema-auto-builder-guide.html +394 -0
- package/docs/ema-user-guide.md +1121 -0
- package/docs/mcp-tools-guide.md +149 -0
- package/docs/naming-conventions.md +218 -0
- package/docs/tool-consolidation-proposal.md +427 -0
- package/package.json +95 -0
- package/resources/templates/chat-ai/README.md +119 -0
- package/resources/templates/chat-ai/persona-config.json +111 -0
- package/resources/templates/dashboard-ai/README.md +156 -0
- package/resources/templates/dashboard-ai/persona-config.json +180 -0
- package/resources/templates/voice-ai/README.md +123 -0
- package/resources/templates/voice-ai/persona-config.json +74 -0
- package/resources/templates/voice-ai/workflow-prompt.md +120 -0
|
@@ -0,0 +1,1753 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompts Registry
|
|
3
|
+
*
|
|
4
|
+
* Provides structured prompts for common Ema workflows.
|
|
5
|
+
*
|
|
6
|
+
* Prompts are designed to:
|
|
7
|
+
* - Have clear input schemas with validation
|
|
8
|
+
* - Reference MCP tools for data fetching
|
|
9
|
+
* - Produce deterministic, structured outputs
|
|
10
|
+
* - Not rely on hidden knowledge
|
|
11
|
+
*/
|
|
12
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
// Prompt Definitions
|
|
14
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
15
|
+
const PROMPTS = {
|
|
16
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
17
|
+
// Clarification & Requirements Gathering
|
|
18
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
19
|
+
requirements_clarify: {
|
|
20
|
+
definition: {
|
|
21
|
+
name: "requirements_clarify",
|
|
22
|
+
description: "Analyze workflow requirements for ambiguity and generate targeted clarification questions. Use before generation/extension when requirements are unclear.",
|
|
23
|
+
arguments: [
|
|
24
|
+
{
|
|
25
|
+
name: "input",
|
|
26
|
+
description: "The natural language requirements or modification request",
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "context",
|
|
31
|
+
description: "Context type: 'greenfield' (new workflow), 'brownfield' (extend existing), 'optimize' (improve existing)",
|
|
32
|
+
required: false,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "persona_id",
|
|
36
|
+
description: "Existing persona ID if brownfield/optimize context",
|
|
37
|
+
required: false,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
render: (args) => [
|
|
42
|
+
{
|
|
43
|
+
role: "user",
|
|
44
|
+
content: {
|
|
45
|
+
type: "text",
|
|
46
|
+
text: `Analyze the following requirements and determine if clarification is needed before proceeding.
|
|
47
|
+
|
|
48
|
+
**Input**: ${args.input}
|
|
49
|
+
**Context**: ${args.context || "unknown"}
|
|
50
|
+
${args.persona_id ? `**Existing Persona**: ${args.persona_id}` : ""}
|
|
51
|
+
|
|
52
|
+
## Clarification Analysis Framework
|
|
53
|
+
|
|
54
|
+
### Step 1: Parse the Request
|
|
55
|
+
Identify what the user is asking for:
|
|
56
|
+
- **Action Type**: Create new / Extend existing / Optimize / Analyze
|
|
57
|
+
- **Scope**: Single intent / Multi-intent / Full workflow
|
|
58
|
+
- **Specificity**: Vague / Partially specified / Detailed
|
|
59
|
+
|
|
60
|
+
### Step 2: Check for Required Information
|
|
61
|
+
|
|
62
|
+
#### For ALL requests, verify:
|
|
63
|
+
| Dimension | Status | Missing Info |
|
|
64
|
+
|-----------|--------|--------------|
|
|
65
|
+
| **Goal/Purpose** | ✓/✗ | What should this accomplish? |
|
|
66
|
+
| **Target Users** | ✓/✗ | Who will interact with this? |
|
|
67
|
+
| **Success Criteria** | ✓/✗ | How do we know it's working? |
|
|
68
|
+
|
|
69
|
+
#### For GREENFIELD (new workflow):
|
|
70
|
+
| Dimension | Status | Missing Info |
|
|
71
|
+
|-----------|--------|--------------|
|
|
72
|
+
| **Persona Type** | ✓/✗ | Voice, Chat, or Dashboard? |
|
|
73
|
+
| **Primary Intents** | ✓/✗ | What queries should it handle? |
|
|
74
|
+
| **Data Sources** | ✓/✗ | Knowledge base, web search, APIs? |
|
|
75
|
+
| **External Tools** | ✓/✗ | ServiceNow, Salesforce, email? |
|
|
76
|
+
| **Routing Logic** | ✓/✗ | How to handle different intents? |
|
|
77
|
+
| **HITL Requirements** | ✓/✗ | When is human approval needed? |
|
|
78
|
+
| **Fallback Handling** | ✓/✗ | What if no match? |
|
|
79
|
+
|
|
80
|
+
#### For BROWNFIELD (extend existing):
|
|
81
|
+
| Dimension | Status | Missing Info |
|
|
82
|
+
|-----------|--------|--------------|
|
|
83
|
+
| **Preserve vs Replace** | ✓/✗ | Keep existing intents or modify? |
|
|
84
|
+
| **Integration Points** | ✓/✗ | Where do new features connect? |
|
|
85
|
+
| **Data Dependencies** | ✓/✗ | What existing data to use? |
|
|
86
|
+
| **Impact Assessment** | ✓/✗ | What might break? |
|
|
87
|
+
|
|
88
|
+
#### For OPTIMIZE:
|
|
89
|
+
| Dimension | Status | Missing Info |
|
|
90
|
+
|-----------|--------|--------------|
|
|
91
|
+
| **Problem Areas** | ✓/✗ | What's not working? |
|
|
92
|
+
| **Performance Goals** | ✓/✗ | Speed, accuracy, cost? |
|
|
93
|
+
| **Constraints** | ✓/✗ | What can't change? |
|
|
94
|
+
|
|
95
|
+
### Step 3: Identify Ambiguities
|
|
96
|
+
|
|
97
|
+
Look for:
|
|
98
|
+
1. **Vague terms**: "better", "smarter", "improved" - what specifically?
|
|
99
|
+
2. **Implicit assumptions**: What does the user assume you know?
|
|
100
|
+
3. **Missing actors**: Who does what in the workflow?
|
|
101
|
+
4. **Undefined triggers**: When does this happen?
|
|
102
|
+
5. **Unclear outputs**: What should the result look like?
|
|
103
|
+
6. **Scope creep**: Multiple unrelated features bundled together
|
|
104
|
+
|
|
105
|
+
### Step 4: Generate Clarification Questions
|
|
106
|
+
|
|
107
|
+
Based on gaps identified, generate **targeted questions**:
|
|
108
|
+
|
|
109
|
+
#### Question Format:
|
|
110
|
+
\`\`\`
|
|
111
|
+
Q: [Specific question]
|
|
112
|
+
Context: [Why this matters]
|
|
113
|
+
Options: [If applicable, provide choices]
|
|
114
|
+
Default: [Reasonable default if user doesn't answer]
|
|
115
|
+
\`\`\`
|
|
116
|
+
|
|
117
|
+
#### Question Categories:
|
|
118
|
+
|
|
119
|
+
**Intent & Purpose**:
|
|
120
|
+
- What is the primary goal of this workflow/feature?
|
|
121
|
+
- What problem does this solve for users?
|
|
122
|
+
- How will success be measured?
|
|
123
|
+
|
|
124
|
+
**User & Interaction**:
|
|
125
|
+
- Who are the users? (internal, external, both)
|
|
126
|
+
- What triggers this workflow? (voice call, chat, scheduled)
|
|
127
|
+
- What should the user experience be like?
|
|
128
|
+
|
|
129
|
+
**Data & Integration**:
|
|
130
|
+
- What data sources should be searched?
|
|
131
|
+
- What external systems need to be called?
|
|
132
|
+
- What information should be extracted/captured?
|
|
133
|
+
|
|
134
|
+
**Logic & Flow**:
|
|
135
|
+
- How should different scenarios be handled?
|
|
136
|
+
- When should humans be involved?
|
|
137
|
+
- What happens if [edge case]?
|
|
138
|
+
|
|
139
|
+
**Constraints**:
|
|
140
|
+
- Are there intents/paths that must NOT change?
|
|
141
|
+
- Are there security/compliance requirements?
|
|
142
|
+
- What's the timeline/urgency?
|
|
143
|
+
|
|
144
|
+
### Step 5: Decision Output
|
|
145
|
+
|
|
146
|
+
Based on analysis, output ONE of:
|
|
147
|
+
|
|
148
|
+
#### A) PROCEED - Requirements are clear
|
|
149
|
+
\`\`\`json
|
|
150
|
+
{
|
|
151
|
+
"status": "clear",
|
|
152
|
+
"confidence": "high|medium",
|
|
153
|
+
"summary": "Brief summary of understood requirements",
|
|
154
|
+
"inferred_defaults": ["List any assumptions made"],
|
|
155
|
+
"next_action": "workflow(mode='generate'|'extend'|'optimize', ...)"
|
|
156
|
+
}
|
|
157
|
+
\`\`\`
|
|
158
|
+
|
|
159
|
+
#### B) CLARIFY - Need more information
|
|
160
|
+
\`\`\`json
|
|
161
|
+
{
|
|
162
|
+
"status": "needs_clarification",
|
|
163
|
+
"confidence": "low",
|
|
164
|
+
"understood": ["What IS clear"],
|
|
165
|
+
"questions": [
|
|
166
|
+
{
|
|
167
|
+
"id": "q1",
|
|
168
|
+
"question": "...",
|
|
169
|
+
"context": "...",
|
|
170
|
+
"options": ["opt1", "opt2"],
|
|
171
|
+
"default": "opt1",
|
|
172
|
+
"priority": "required|recommended|nice-to-have"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"can_proceed_with_defaults": true|false,
|
|
176
|
+
"partial_next_action": "If can proceed, what would be called"
|
|
177
|
+
}
|
|
178
|
+
\`\`\`
|
|
179
|
+
|
|
180
|
+
#### C) DECOMPOSE - Request too complex
|
|
181
|
+
\`\`\`json
|
|
182
|
+
{
|
|
183
|
+
"status": "needs_decomposition",
|
|
184
|
+
"reason": "Why this is too complex for one request",
|
|
185
|
+
"suggested_phases": [
|
|
186
|
+
{"phase": 1, "scope": "...", "description": "..."},
|
|
187
|
+
{"phase": 2, "scope": "...", "description": "..."}
|
|
188
|
+
],
|
|
189
|
+
"start_with": "Recommended first phase"
|
|
190
|
+
}
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
## Output Requirements
|
|
194
|
+
|
|
195
|
+
1. **Always show your analysis** - Don't just ask questions, show what you understood
|
|
196
|
+
2. **Prioritize questions** - Required > Recommended > Nice-to-have
|
|
197
|
+
3. **Provide defaults** - User can accept defaults to proceed faster
|
|
198
|
+
4. **Be specific** - "What email should be sent?" not "Tell me more"
|
|
199
|
+
5. **Limit questions** - Max 5 required questions, don't overwhelm`,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
205
|
+
// AI Employee Generation
|
|
206
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
207
|
+
ai_employee_generate: {
|
|
208
|
+
definition: {
|
|
209
|
+
name: "ai_employee_generate",
|
|
210
|
+
description: "Generate a complete AI Employee workflow prompt from requirements. Guides through qualifying questions, agent selection, and prompt generation.",
|
|
211
|
+
arguments: [
|
|
212
|
+
{
|
|
213
|
+
name: "use_case",
|
|
214
|
+
description: "Description of what the AI Employee should do (e.g., 'IT helpdesk that creates ServiceNow tickets')",
|
|
215
|
+
required: true,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "persona_type",
|
|
219
|
+
description: "Type of AI Employee: 'voice', 'chat', or 'dashboard'",
|
|
220
|
+
required: true,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "intents",
|
|
224
|
+
description: "Comma-separated list of intent categories the AI should recognize (optional, will be inferred if not provided)",
|
|
225
|
+
required: false,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
render: (args) => [
|
|
230
|
+
{
|
|
231
|
+
role: "user",
|
|
232
|
+
content: {
|
|
233
|
+
type: "text",
|
|
234
|
+
text: `Generate a complete AI Employee for the following use case:
|
|
235
|
+
|
|
236
|
+
**Use Case**: ${args.use_case}
|
|
237
|
+
**Persona Type**: ${args.persona_type}
|
|
238
|
+
${args.intents ? `**Intent Categories**: ${args.intents}` : ""}
|
|
239
|
+
|
|
240
|
+
## Instructions
|
|
241
|
+
|
|
242
|
+
Follow this MCP-enhanced generation workflow using the **consolidated tools**:
|
|
243
|
+
\`template\`, \`action\`, \`workflow\`, \`persona\`, \`knowledge\`, \`reference\`, \`sync\`.
|
|
244
|
+
|
|
245
|
+
### Step 1: Gather Requirements
|
|
246
|
+
First, call \`template(questions=true)\` to get structured qualifying questions.
|
|
247
|
+
If persona_type is "voice", also call \`template(questions=true, category="Voice")\`.
|
|
248
|
+
|
|
249
|
+
Verify you have answers for:
|
|
250
|
+
- AI Type: ${args.persona_type}
|
|
251
|
+
- Intents: ${args.intents || "(to be determined)"}
|
|
252
|
+
- Data Sources: (ask if not clear from use case)
|
|
253
|
+
- Actions: (ask if not clear from use case)
|
|
254
|
+
- Approvals/HITL: (ask if external actions involved)
|
|
255
|
+
|
|
256
|
+
### Step 2: Select Pattern + Agents
|
|
257
|
+
Call \`action(suggest="${args.use_case}")\` to get recommended agents and a suggested workflow pattern.
|
|
258
|
+
Then call \`template(pattern=<suggested_pattern>)\` to fetch the pattern template.
|
|
259
|
+
|
|
260
|
+
### Step 3: Get Agent Details
|
|
261
|
+
For each agent in the workflow, call \`action(id=<agent_name>, include_docs=true)\` to get:
|
|
262
|
+
- Inputs and outputs
|
|
263
|
+
- Critical rules
|
|
264
|
+
- Type compatibility requirements
|
|
265
|
+
|
|
266
|
+
### Step 4: Generate Prompt
|
|
267
|
+
Using the template from Step 2 and agent details from Step 3, generate:
|
|
268
|
+
|
|
269
|
+
1. **workflow-prompt.md** - Auto Builder prompt with:
|
|
270
|
+
- Explicit node definitions
|
|
271
|
+
- Explicit connections
|
|
272
|
+
- Results mapping to WORKFLOW_OUTPUT
|
|
273
|
+
- Validation assertions
|
|
274
|
+
|
|
275
|
+
2. **persona-config.json** - ${args.persona_type === "voice" ? "Voice settings (welcomeMessage, identityAndPurpose, takeActionInstructions, hangupInstructions)" : args.persona_type === "chat" ? "Chat settings (chatbotSdkConfig, feedbackMessage)" : "Dashboard settings (inputSchema, batchSettings)"}
|
|
276
|
+
|
|
277
|
+
### Step 5: Validate
|
|
278
|
+
Call \`reference(validate_prompt=<generated_prompt>)\` to check for:
|
|
279
|
+
- Missing Fallback category
|
|
280
|
+
- Type mismatches
|
|
281
|
+
- Incomplete categorizer routing
|
|
282
|
+
- Missing WORKFLOW_OUTPUT mapping
|
|
283
|
+
|
|
284
|
+
Call \`reference(mistakes=true)\` for final verification.
|
|
285
|
+
|
|
286
|
+
## Output Format
|
|
287
|
+
|
|
288
|
+
Produce a folder structure:
|
|
289
|
+
\`\`\`
|
|
290
|
+
{persona-name}/
|
|
291
|
+
├── README.md # Deployment guide
|
|
292
|
+
├── workflow-prompt.md # Auto Builder prompt
|
|
293
|
+
├── persona-config.json # ${args.persona_type} settings
|
|
294
|
+
└── docs/ # Knowledge base (if needed)
|
|
295
|
+
\`\`\`
|
|
296
|
+
|
|
297
|
+
Now begin by calling the MCP tools to gather the necessary information.`,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
303
|
+
// Workflow Review
|
|
304
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
305
|
+
workflow_review: {
|
|
306
|
+
definition: {
|
|
307
|
+
name: "workflow_review",
|
|
308
|
+
description: "Review an existing AI Employee workflow for issues, detect problems (loops, deadlocks, type mismatches), and propose fixes.",
|
|
309
|
+
arguments: [
|
|
310
|
+
{
|
|
311
|
+
name: "persona_id",
|
|
312
|
+
description: "ID of the AI Employee to review",
|
|
313
|
+
required: true,
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: "env",
|
|
317
|
+
description: "Environment to fetch from (default: demo). Options: demo, dev, staging",
|
|
318
|
+
required: false,
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
render: (args) => [
|
|
323
|
+
{
|
|
324
|
+
role: "user",
|
|
325
|
+
content: {
|
|
326
|
+
type: "text",
|
|
327
|
+
text: `Review the workflow for AI Employee: ${args.persona_id}
|
|
328
|
+
Environment: ${args.env || "demo"}
|
|
329
|
+
|
|
330
|
+
## Instructions
|
|
331
|
+
|
|
332
|
+
Follow this review workflow using the consolidated tools:
|
|
333
|
+
|
|
334
|
+
### Step 1: Fetch Persona + Workflow
|
|
335
|
+
Call \`persona(id="${args.persona_id}", include_workflow=true, env="${args.env || "demo"}")\` to fetch the full workflow_def.
|
|
336
|
+
|
|
337
|
+
### Step 2: Analyze (Issues + Connections + Fixes + Metrics)
|
|
338
|
+
Call \`workflow(mode="analyze", persona_id="${args.persona_id}", env="${args.env || "demo"}")\`.
|
|
339
|
+
|
|
340
|
+
### Step 3: (Optional) Preview Auto-Fixes
|
|
341
|
+
If issues are found and you want a one-click preview of fixes:
|
|
342
|
+
Call \`workflow(mode="optimize", persona_id="${args.persona_id}", preview=true, env="${args.env || "demo"}")\`.
|
|
343
|
+
|
|
344
|
+
## Output Format
|
|
345
|
+
|
|
346
|
+
\`\`\`markdown
|
|
347
|
+
## Workflow Review: {Persona Name}
|
|
348
|
+
|
|
349
|
+
**Environment**: ${args.env || "demo"}
|
|
350
|
+
**Persona ID**: ${args.persona_id}
|
|
351
|
+
**Review Date**: {date}
|
|
352
|
+
|
|
353
|
+
### Summary
|
|
354
|
+
|
|
355
|
+
| Category | Status | Issues |
|
|
356
|
+
|----------|--------|--------|
|
|
357
|
+
| Graph Structure | ✅/⚠️/❌ | {count} |
|
|
358
|
+
| Routing | ✅/⚠️/❌ | {count} |
|
|
359
|
+
| Type Compatibility | ✅/⚠️/❌ | {count} |
|
|
360
|
+
| HITL Patterns | ✅/⚠️/❌ | {count} |
|
|
361
|
+
|
|
362
|
+
### Critical Issues (Must Fix)
|
|
363
|
+
{list with location, impact, fix}
|
|
364
|
+
|
|
365
|
+
### Warnings (Should Fix)
|
|
366
|
+
{list with location, impact, fix}
|
|
367
|
+
|
|
368
|
+
### Proposed Fixes
|
|
369
|
+
{Before/After YAML for each fix}
|
|
370
|
+
|
|
371
|
+
### Next Steps
|
|
372
|
+
1. [ ] Apply critical fixes
|
|
373
|
+
2. [ ] Test in simulator
|
|
374
|
+
3. [ ] Validate all paths work
|
|
375
|
+
\`\`\`
|
|
376
|
+
|
|
377
|
+
Now begin by fetching the workflow.`,
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
383
|
+
// Debug Workflow
|
|
384
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
385
|
+
workflow_debug: {
|
|
386
|
+
definition: {
|
|
387
|
+
name: "workflow_debug",
|
|
388
|
+
description: "Debug workflow issues with step-by-step guidance based on symptoms.",
|
|
389
|
+
arguments: [
|
|
390
|
+
{
|
|
391
|
+
name: "persona_id",
|
|
392
|
+
description: "ID of the AI Employee with issues",
|
|
393
|
+
required: true,
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "symptoms",
|
|
397
|
+
description: "Description of the problem (e.g., 'responses are empty', 'categorizer not routing correctly', 'HITL approval breaks')",
|
|
398
|
+
required: true,
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "env",
|
|
402
|
+
description: "Environment (default: demo)",
|
|
403
|
+
required: false,
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
},
|
|
407
|
+
render: (args) => [
|
|
408
|
+
{
|
|
409
|
+
role: "user",
|
|
410
|
+
content: {
|
|
411
|
+
type: "text",
|
|
412
|
+
text: `Debug workflow issues for AI Employee: ${args.persona_id}
|
|
413
|
+
|
|
414
|
+
**Symptoms**: ${args.symptoms}
|
|
415
|
+
**Environment**: ${args.env || "demo"}
|
|
416
|
+
|
|
417
|
+
## Instructions
|
|
418
|
+
|
|
419
|
+
### Step 1: Get Debug Checklist
|
|
420
|
+
Call \`reference(checklist=true)\` to get the systematic debugging guide.
|
|
421
|
+
|
|
422
|
+
### Step 2: Fetch Workflow
|
|
423
|
+
Call \`persona(id="${args.persona_id}", include_workflow=true, env="${args.env || "demo"}")\`.
|
|
424
|
+
|
|
425
|
+
### Step 3: Analyze Based on Symptoms
|
|
426
|
+
|
|
427
|
+
Based on the symptoms "${args.symptoms}", focus on:
|
|
428
|
+
|
|
429
|
+
${args.symptoms.toLowerCase().includes("empty") || args.symptoms.toLowerCase().includes("no response") ? `
|
|
430
|
+
**Empty/No Response Issues:**
|
|
431
|
+
- Check if all paths reach WORKFLOW_OUTPUT
|
|
432
|
+
- Verify results mapping is correct
|
|
433
|
+
- Look for dead-end nodes
|
|
434
|
+
- Check if categorizer has edges for all categories
|
|
435
|
+
` : ""}
|
|
436
|
+
${args.symptoms.toLowerCase().includes("categoriz") || args.symptoms.toLowerCase().includes("routing") || args.symptoms.toLowerCase().includes("intent") ? `
|
|
437
|
+
**Categorizer/Routing Issues:**
|
|
438
|
+
- Check categorizer input source (must be chat_conversation, NOT user_query)
|
|
439
|
+
- Verify all categories have outgoing edges
|
|
440
|
+
- Check for missing Fallback category
|
|
441
|
+
- Verify category names match exactly in edges
|
|
442
|
+
` : ""}
|
|
443
|
+
${args.symptoms.toLowerCase().includes("hitl") || args.symptoms.toLowerCase().includes("approval") ? `
|
|
444
|
+
**HITL/Approval Issues:**
|
|
445
|
+
- Check both success AND failure paths exist
|
|
446
|
+
- Verify 'hitl_status_HITL Success' and 'hitl_status_HITL Failure' edges (note: space, not underscore)
|
|
447
|
+
- Check if HITL node receives correct inputs
|
|
448
|
+
- Unlike regular categorizers, HITL has NO Fallback category
|
|
449
|
+
` : ""}
|
|
450
|
+
${args.symptoms.toLowerCase().includes("type") || args.symptoms.toLowerCase().includes("mismatch") ? `
|
|
451
|
+
**Type Compatibility Issues:**
|
|
452
|
+
- Call \`workflow(mode="analyze", persona_id="${args.persona_id}", env="${args.env || "demo"}", include=["connections"])\` for an edge-by-edge type check
|
|
453
|
+
- Common issues: chat_conversation → search (should be user_query)
|
|
454
|
+
- Check wellKnownType compatibility
|
|
455
|
+
` : ""}
|
|
456
|
+
${args.symptoms.toLowerCase().includes("loop") || args.symptoms.toLowerCase().includes("infinite") || args.symptoms.toLowerCase().includes("hang") ? `
|
|
457
|
+
**Loop/Hang Issues:**
|
|
458
|
+
- Check for circular dependencies in edges
|
|
459
|
+
- Look for nodes that reference themselves
|
|
460
|
+
- Verify workflow has proper termination paths
|
|
461
|
+
` : ""}
|
|
462
|
+
|
|
463
|
+
### Step 4: Run Issue Detection
|
|
464
|
+
Call \`workflow(mode="analyze", persona_id="${args.persona_id}", env="${args.env || "demo"}")\` to find issues, connections, suggested fixes, and metrics.
|
|
465
|
+
|
|
466
|
+
### Step 5: Propose Fix
|
|
467
|
+
Based on findings, provide specific fix with before/after configuration.
|
|
468
|
+
|
|
469
|
+
## Output Format
|
|
470
|
+
|
|
471
|
+
\`\`\`markdown
|
|
472
|
+
## Debug Report: {Persona Name}
|
|
473
|
+
|
|
474
|
+
### Symptoms
|
|
475
|
+
${args.symptoms}
|
|
476
|
+
|
|
477
|
+
### Root Cause
|
|
478
|
+
{explanation of what's causing the issue}
|
|
479
|
+
|
|
480
|
+
### Diagnosis
|
|
481
|
+
{step-by-step what was found}
|
|
482
|
+
|
|
483
|
+
### Fix
|
|
484
|
+
|
|
485
|
+
**Before:**
|
|
486
|
+
\`\`\`yaml
|
|
487
|
+
{problematic configuration}
|
|
488
|
+
\`\`\`
|
|
489
|
+
|
|
490
|
+
**After:**
|
|
491
|
+
\`\`\`yaml
|
|
492
|
+
{fixed configuration}
|
|
493
|
+
\`\`\`
|
|
494
|
+
|
|
495
|
+
### Verification Steps
|
|
496
|
+
1. Apply the fix
|
|
497
|
+
2. {specific test to verify}
|
|
498
|
+
3. {additional validation}
|
|
499
|
+
\`\`\`
|
|
500
|
+
|
|
501
|
+
Now begin debugging.`,
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
},
|
|
506
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
507
|
+
// Sync Persona
|
|
508
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
509
|
+
persona_sync: {
|
|
510
|
+
definition: {
|
|
511
|
+
name: "persona_sync",
|
|
512
|
+
description: "Sync an AI Employee from source to target environment with change detection.",
|
|
513
|
+
arguments: [
|
|
514
|
+
{
|
|
515
|
+
name: "persona_name",
|
|
516
|
+
description: "Name of the AI Employee to sync",
|
|
517
|
+
required: true,
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "target_env",
|
|
521
|
+
description: "Target environment (e.g., 'dev', 'staging')",
|
|
522
|
+
required: true,
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: "source_env",
|
|
526
|
+
description: "Source environment (default: demo)",
|
|
527
|
+
required: false,
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "dry_run",
|
|
531
|
+
description: "If 'true', simulate without making changes (default: false)",
|
|
532
|
+
required: false,
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
},
|
|
536
|
+
render: (args) => [
|
|
537
|
+
{
|
|
538
|
+
role: "user",
|
|
539
|
+
content: {
|
|
540
|
+
type: "text",
|
|
541
|
+
text: `Sync AI Employee "${args.persona_name}" to ${args.target_env}
|
|
542
|
+
|
|
543
|
+
**Source**: ${args.source_env || "demo"}
|
|
544
|
+
**Target**: ${args.target_env}
|
|
545
|
+
**Dry Run**: ${args.dry_run === "true" ? "Yes" : "No"}
|
|
546
|
+
|
|
547
|
+
## Instructions
|
|
548
|
+
|
|
549
|
+
### Step 1: Verify Source Exists
|
|
550
|
+
Call \`persona(id="${args.persona_name}", env="${args.source_env || "demo"}")\` to verify the AI Employee exists and to retrieve its ID.
|
|
551
|
+
|
|
552
|
+
### Step 2: Check Sync Status
|
|
553
|
+
Call \`sync(mode="status", id="${args.persona_name}", env="${args.target_env}")\` to see whether the target environment already has a synced copy and what it’s synced from.
|
|
554
|
+
|
|
555
|
+
### Step 3: Preview Changes (if not dry run)
|
|
556
|
+
Run a dry-run sync to preview:
|
|
557
|
+
\`sync(id="${args.persona_name}", source="${args.source_env || "demo"}", target="${args.target_env}", dry_run=true)\`
|
|
558
|
+
|
|
559
|
+
### Step 4: Execute Sync
|
|
560
|
+
Call \`sync(id="${args.persona_name}", source="${args.source_env || "demo"}", target="${args.target_env}", dry_run=${args.dry_run === "true"})\`.
|
|
561
|
+
|
|
562
|
+
### Step 5: Verify (if not dry run)
|
|
563
|
+
After sync, call \`sync(mode="status", id="${args.persona_name}", env="${args.target_env}")\` to verify the sync metadata/tag was applied.
|
|
564
|
+
|
|
565
|
+
## Output Format
|
|
566
|
+
|
|
567
|
+
\`\`\`markdown
|
|
568
|
+
## Sync Report: ${args.persona_name}
|
|
569
|
+
|
|
570
|
+
| Field | Value |
|
|
571
|
+
|-------|-------|
|
|
572
|
+
| Source | ${args.source_env || "demo"} |
|
|
573
|
+
| Target | ${args.target_env} |
|
|
574
|
+
| Status | {Created/Updated/No Changes} |
|
|
575
|
+
| Dry Run | ${args.dry_run === "true" ? "Yes" : "No"} |
|
|
576
|
+
|
|
577
|
+
### Changes
|
|
578
|
+
{list of changes made or would be made}
|
|
579
|
+
|
|
580
|
+
### Sync Tag
|
|
581
|
+
\`\`\`
|
|
582
|
+
<!-- synced_from:${args.source_env || "demo"}/{source_id} -->
|
|
583
|
+
\`\`\`
|
|
584
|
+
\`\`\`
|
|
585
|
+
|
|
586
|
+
Now begin the sync process.`,
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
],
|
|
590
|
+
},
|
|
591
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
592
|
+
// Compare Personas
|
|
593
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
594
|
+
persona_compare: {
|
|
595
|
+
definition: {
|
|
596
|
+
name: "persona_compare",
|
|
597
|
+
description: "Compare two AI Employees to see differences in configuration and workflow.",
|
|
598
|
+
arguments: [
|
|
599
|
+
{
|
|
600
|
+
name: "persona_id_1",
|
|
601
|
+
description: "ID of the first AI Employee",
|
|
602
|
+
required: true,
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "persona_id_2",
|
|
606
|
+
description: "ID of the second AI Employee",
|
|
607
|
+
required: true,
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "env_1",
|
|
611
|
+
description: "Environment for first persona (default: demo)",
|
|
612
|
+
required: false,
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "env_2",
|
|
616
|
+
description: "Environment for second persona (default: same as env_1)",
|
|
617
|
+
required: false,
|
|
618
|
+
},
|
|
619
|
+
],
|
|
620
|
+
},
|
|
621
|
+
render: (args) => [
|
|
622
|
+
{
|
|
623
|
+
role: "user",
|
|
624
|
+
content: {
|
|
625
|
+
type: "text",
|
|
626
|
+
text: `Compare two AI Employees:
|
|
627
|
+
|
|
628
|
+
**Persona 1**: ${args.persona_id_1} (${args.env_1 || "demo"})
|
|
629
|
+
**Persona 2**: ${args.persona_id_2} (${args.env_2 || args.env_1 || "demo"})
|
|
630
|
+
|
|
631
|
+
## Instructions
|
|
632
|
+
|
|
633
|
+
### Step 1: Fetch Both Personas
|
|
634
|
+
Call in parallel:
|
|
635
|
+
- \`persona(id="${args.persona_id_1}", include_workflow=true, env="${args.env_1 || "demo"}")\`
|
|
636
|
+
- \`persona(id="${args.persona_id_2}", include_workflow=true, env="${args.env_2 || args.env_1 || "demo"}")\`
|
|
637
|
+
|
|
638
|
+
### Step 2: Compare
|
|
639
|
+
Call \`persona(id="${args.persona_id_1}", mode="compare", compare_to="${args.persona_id_2}", env="${args.env_1 || "demo"}", compare_env="${args.env_2 || args.env_1 || "demo"}")\`.
|
|
640
|
+
|
|
641
|
+
### Step 3: Compare Workflows (if both have workflows)
|
|
642
|
+
If both personas are in the same environment, call:
|
|
643
|
+
\`workflow(mode="compare", persona_id="${args.persona_id_1}", compare_to="${args.persona_id_2}", env="${args.env_1 || "demo"}")\`
|
|
644
|
+
to see structural differences.
|
|
645
|
+
|
|
646
|
+
## Output Format
|
|
647
|
+
|
|
648
|
+
\`\`\`markdown
|
|
649
|
+
## Comparison Report
|
|
650
|
+
|
|
651
|
+
### Personas
|
|
652
|
+
|
|
653
|
+
| Field | Persona 1 | Persona 2 |
|
|
654
|
+
|-------|-----------|-----------|
|
|
655
|
+
| Name | {name1} | {name2} |
|
|
656
|
+
| Environment | ${args.env_1 || "demo"} | ${args.env_2 || args.env_1 || "demo"} |
|
|
657
|
+
| Status | {status1} | {status2} |
|
|
658
|
+
| Trigger Type | {trigger1} | {trigger2} |
|
|
659
|
+
|
|
660
|
+
### Configuration Differences
|
|
661
|
+
{list of field differences}
|
|
662
|
+
|
|
663
|
+
### Workflow Differences
|
|
664
|
+
{structural changes: nodes added/removed/modified, edges changed}
|
|
665
|
+
|
|
666
|
+
### Recommendations
|
|
667
|
+
{which version is preferred and why}
|
|
668
|
+
\`\`\`
|
|
669
|
+
|
|
670
|
+
Now begin the comparison.`,
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
},
|
|
675
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
676
|
+
// Validate Prompt
|
|
677
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
678
|
+
prompt_validate: {
|
|
679
|
+
definition: {
|
|
680
|
+
name: "prompt_validate",
|
|
681
|
+
description: "Validate an Auto Builder workflow prompt for common errors before submission.",
|
|
682
|
+
arguments: [
|
|
683
|
+
{
|
|
684
|
+
name: "prompt",
|
|
685
|
+
description: "The Auto Builder prompt text to validate",
|
|
686
|
+
required: true,
|
|
687
|
+
},
|
|
688
|
+
],
|
|
689
|
+
},
|
|
690
|
+
render: (args) => [
|
|
691
|
+
{
|
|
692
|
+
role: "user",
|
|
693
|
+
content: {
|
|
694
|
+
type: "text",
|
|
695
|
+
text: `Validate this Auto Builder prompt:
|
|
696
|
+
|
|
697
|
+
\`\`\`
|
|
698
|
+
${args.prompt}
|
|
699
|
+
\`\`\`
|
|
700
|
+
|
|
701
|
+
## Instructions
|
|
702
|
+
|
|
703
|
+
### Step 1: Run Validation
|
|
704
|
+
Call \`reference(validate_prompt=<the_prompt>)\` to check for:
|
|
705
|
+
- Missing Fallback category
|
|
706
|
+
- Type mismatches in connections
|
|
707
|
+
- Incomplete categorizer routing
|
|
708
|
+
- Missing WORKFLOW_OUTPUT mapping
|
|
709
|
+
- HITL without both success/failure paths
|
|
710
|
+
|
|
711
|
+
### Step 2: Check Common Mistakes
|
|
712
|
+
Call \`reference(mistakes=true)\` and verify the prompt doesn't have:
|
|
713
|
+
1. Missing Fallback category
|
|
714
|
+
2. Missing HITL on sensitive actions
|
|
715
|
+
3. Wrong input sources (user_query vs chat_conversation)
|
|
716
|
+
4. Duplicate record creation on follow-ups
|
|
717
|
+
|
|
718
|
+
### Step 3: Verify Type Compatibility
|
|
719
|
+
For each connection in the prompt, verify types are compatible:
|
|
720
|
+
- chat_trigger.chat_conversation → chat_categorizer.conversation ✓
|
|
721
|
+
- chat_trigger.user_query → search.query ✓
|
|
722
|
+
- search.search_results → respond_with_sources.search_results ✓
|
|
723
|
+
|
|
724
|
+
## Output Format
|
|
725
|
+
|
|
726
|
+
\`\`\`markdown
|
|
727
|
+
## Validation Report
|
|
728
|
+
|
|
729
|
+
### Overall Status: ✅ PASS / ⚠️ WARNINGS / ❌ FAIL
|
|
730
|
+
|
|
731
|
+
### Issues Found
|
|
732
|
+
|
|
733
|
+
#### Critical (Must Fix)
|
|
734
|
+
{list or "None"}
|
|
735
|
+
|
|
736
|
+
#### Warnings (Should Fix)
|
|
737
|
+
{list or "None"}
|
|
738
|
+
|
|
739
|
+
#### Suggestions (Optional)
|
|
740
|
+
{list or "None"}
|
|
741
|
+
|
|
742
|
+
### Type Compatibility Check
|
|
743
|
+
| Connection | Status |
|
|
744
|
+
|------------|--------|
|
|
745
|
+
{table of connections and their status}
|
|
746
|
+
|
|
747
|
+
### Recommendations
|
|
748
|
+
{specific fixes if issues found}
|
|
749
|
+
\`\`\`
|
|
750
|
+
|
|
751
|
+
Now run the validation.`,
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
],
|
|
755
|
+
},
|
|
756
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
757
|
+
// Onboard to Toolkit
|
|
758
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
759
|
+
toolkit_onboard: {
|
|
760
|
+
definition: {
|
|
761
|
+
name: "toolkit_onboard",
|
|
762
|
+
description: "Get started with the Ema MCP Toolkit. Provides setup instructions, available tools, and common workflows.",
|
|
763
|
+
arguments: [],
|
|
764
|
+
},
|
|
765
|
+
render: () => [
|
|
766
|
+
{
|
|
767
|
+
role: "user",
|
|
768
|
+
content: {
|
|
769
|
+
type: "text",
|
|
770
|
+
text: `Help me get started with the Ema MCP Toolkit.
|
|
771
|
+
|
|
772
|
+
## Instructions
|
|
773
|
+
|
|
774
|
+
### Step 1: Read the README
|
|
775
|
+
Fetch the resource \`ema://docs/readme\` to understand the toolkit overview.
|
|
776
|
+
|
|
777
|
+
### Step 2: List Available Environments
|
|
778
|
+
Call \`env()\` to see configured environments.
|
|
779
|
+
|
|
780
|
+
### Step 3: Explore Platform Concepts
|
|
781
|
+
Call \`reference(concepts=true)\` to understand key terminology:
|
|
782
|
+
- AI Employee (Persona)
|
|
783
|
+
- Action (Agent)
|
|
784
|
+
- Workflow
|
|
785
|
+
- HITL
|
|
786
|
+
- Sync Tags
|
|
787
|
+
|
|
788
|
+
### Step 4: Show Key Workflows
|
|
789
|
+
|
|
790
|
+
Provide examples of common tasks:
|
|
791
|
+
|
|
792
|
+
1. **List AI Employees**: \`persona(all=true, env="demo")\`
|
|
793
|
+
2. **Search for specific persona**: \`persona(query="support", status="active", env="demo")\`
|
|
794
|
+
3. **Get full persona details**: \`persona(id="xxx", include_workflow=true, env="demo")\`
|
|
795
|
+
4. **Sync a persona**: \`sync(id="my-bot", source="demo", target="dev")\`
|
|
796
|
+
5. **Analyze workflow**: \`workflow(mode="analyze", persona_id="xxx", env="demo")\`
|
|
797
|
+
|
|
798
|
+
## Output Format
|
|
799
|
+
|
|
800
|
+
\`\`\`markdown
|
|
801
|
+
# Ema MCP Toolkit Quickstart
|
|
802
|
+
|
|
803
|
+
## Setup Complete ✓
|
|
804
|
+
|
|
805
|
+
| Environment | Status |
|
|
806
|
+
|-------------|--------|
|
|
807
|
+
{table of environments}
|
|
808
|
+
|
|
809
|
+
## Key Concepts
|
|
810
|
+
|
|
811
|
+
{brief explanation of each concept}
|
|
812
|
+
|
|
813
|
+
## Common Commands
|
|
814
|
+
|
|
815
|
+
### Browse AI Employees
|
|
816
|
+
\`\`\`
|
|
817
|
+
persona(all=true, env="demo")
|
|
818
|
+
persona(query="support", env="demo")
|
|
819
|
+
\`\`\`
|
|
820
|
+
|
|
821
|
+
### Generate New AI Employee
|
|
822
|
+
Use the \`generate_ai_employee\` prompt with:
|
|
823
|
+
- use_case: what it should do
|
|
824
|
+
- persona_type: voice/chat/dashboard
|
|
825
|
+
|
|
826
|
+
### Review Existing Workflow
|
|
827
|
+
Use the \`review_workflow\` prompt with:
|
|
828
|
+
- persona_id: the ID to review
|
|
829
|
+
- env: environment
|
|
830
|
+
|
|
831
|
+
### Sync Across Environments
|
|
832
|
+
Use the \`sync_persona\` prompt with:
|
|
833
|
+
- persona_name: name to sync
|
|
834
|
+
- target_env: destination
|
|
835
|
+
|
|
836
|
+
## Next Steps
|
|
837
|
+
|
|
838
|
+
1. Try listing AI Employees in demo
|
|
839
|
+
2. Pick one and review its workflow
|
|
840
|
+
3. Generate a new AI Employee for your use case
|
|
841
|
+
\`\`\`
|
|
842
|
+
|
|
843
|
+
Now provide the onboarding guide.`,
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
],
|
|
847
|
+
},
|
|
848
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
849
|
+
// Create Voice AI
|
|
850
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
851
|
+
persona_create_voice: {
|
|
852
|
+
definition: {
|
|
853
|
+
name: "persona_create_voice",
|
|
854
|
+
description: "Create a Voice AI Employee with conversation settings, tool calling, and voice configuration.",
|
|
855
|
+
arguments: [
|
|
856
|
+
{
|
|
857
|
+
name: "name",
|
|
858
|
+
description: "Name for the Voice AI (e.g., 'IT Support Assistant')",
|
|
859
|
+
required: true,
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
name: "purpose",
|
|
863
|
+
description: "What the Voice AI should do (e.g., 'Help employees reset passwords and create IT tickets')",
|
|
864
|
+
required: true,
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
name: "intents",
|
|
868
|
+
description: "Comma-separated intent categories (e.g., 'Password Reset, Create Ticket, Check Status')",
|
|
869
|
+
required: false,
|
|
870
|
+
},
|
|
871
|
+
],
|
|
872
|
+
},
|
|
873
|
+
render: (args) => [
|
|
874
|
+
{
|
|
875
|
+
role: "user",
|
|
876
|
+
content: {
|
|
877
|
+
type: "text",
|
|
878
|
+
text: `Create a Voice AI Employee:
|
|
879
|
+
|
|
880
|
+
**Name**: ${args.name}
|
|
881
|
+
**Purpose**: ${args.purpose}
|
|
882
|
+
${args.intents ? `**Intents**: ${args.intents}` : ""}
|
|
883
|
+
|
|
884
|
+
## Instructions
|
|
885
|
+
|
|
886
|
+
### Step 1: Read Templates (Resources)
|
|
887
|
+
Read these resources to get templates and reference data:
|
|
888
|
+
- \`ema://templates/voice-ai/config\` - Voice AI persona configuration template
|
|
889
|
+
- \`ema://templates/voice-ai/workflow-prompt\` - Auto Builder prompt template with safeguards
|
|
890
|
+
- \`ema://templates/voice-ai/readme\` - Deployment guide template
|
|
891
|
+
- \`ema://catalog/agents-summary\` - Available agents for workflow composition
|
|
892
|
+
|
|
893
|
+
### Step 2: Read Validation Rules (Resources)
|
|
894
|
+
Read these resources to ensure correct workflow design:
|
|
895
|
+
- \`ema://rules/input-sources\` - Which agent inputs accept which data types
|
|
896
|
+
- \`ema://rules/anti-patterns\` - Common mistakes to avoid
|
|
897
|
+
|
|
898
|
+
### Step 3: Get Agent Recommendations (Tool)
|
|
899
|
+
Call \`action(suggest="${args.purpose}")\` for recommended agents and pattern.
|
|
900
|
+
|
|
901
|
+
### Step 4: Get Voice-Specific Guidance (Tool)
|
|
902
|
+
Call \`template(questions=true, category="Voice")\` for Voice AI specific requirements.
|
|
903
|
+
Call \`reference(guidance="voice-tool-calling")\` for tool calling rules:
|
|
904
|
+
1. Collect all parameters before calling tool
|
|
905
|
+
2. Wait for response before next tool
|
|
906
|
+
3. Never mention tool names to caller
|
|
907
|
+
4. Handle delays with "Just a moment..."
|
|
908
|
+
|
|
909
|
+
### Step 5: Generate Output
|
|
910
|
+
Using the templates from Step 1 and guidance from Steps 3-4, generate:
|
|
911
|
+
|
|
912
|
+
**Folder structure:**
|
|
913
|
+
\`\`\`
|
|
914
|
+
${args.name.toLowerCase().replace(/\s+/g, "-")}/
|
|
915
|
+
├── README.md # Deployment guide (based on ema://templates/voice-ai/readme)
|
|
916
|
+
├── workflow-prompt.md # Auto Builder prompt (based on ema://templates/voice-ai/workflow-prompt)
|
|
917
|
+
├── persona-config.json # Voice settings (based on ema://templates/voice-ai/config)
|
|
918
|
+
└── proto-config.json # Full API config
|
|
919
|
+
\`\`\`
|
|
920
|
+
|
|
921
|
+
### Step 6: Validate
|
|
922
|
+
Call \`reference(validate_prompt=<generated_prompt>)\` to verify the prompt.
|
|
923
|
+
|
|
924
|
+
Now begin by reading the resources, then proceed with generation.`,
|
|
925
|
+
},
|
|
926
|
+
},
|
|
927
|
+
],
|
|
928
|
+
},
|
|
929
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
930
|
+
// Create Chat AI
|
|
931
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
932
|
+
persona_create_chat: {
|
|
933
|
+
definition: {
|
|
934
|
+
name: "persona_create_chat",
|
|
935
|
+
description: "Create a Chat AI Employee with knowledge base search and web widget.",
|
|
936
|
+
arguments: [
|
|
937
|
+
{
|
|
938
|
+
name: "name",
|
|
939
|
+
description: "Name for the Chat AI (e.g., 'Product FAQ Bot')",
|
|
940
|
+
required: true,
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
name: "purpose",
|
|
944
|
+
description: "What the Chat AI should do (e.g., 'Answer questions about products from documentation')",
|
|
945
|
+
required: true,
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
name: "data_sources",
|
|
949
|
+
description: "Comma-separated data sources (e.g., 'Product docs, FAQ pages, Help articles')",
|
|
950
|
+
required: false,
|
|
951
|
+
},
|
|
952
|
+
],
|
|
953
|
+
},
|
|
954
|
+
render: (args) => [
|
|
955
|
+
{
|
|
956
|
+
role: "user",
|
|
957
|
+
content: {
|
|
958
|
+
type: "text",
|
|
959
|
+
text: `Create a Chat AI Employee:
|
|
960
|
+
|
|
961
|
+
**Name**: ${args.name}
|
|
962
|
+
**Purpose**: ${args.purpose}
|
|
963
|
+
${args.data_sources ? `**Data Sources**: ${args.data_sources}` : ""}
|
|
964
|
+
|
|
965
|
+
## Instructions
|
|
966
|
+
|
|
967
|
+
### Step 1: Read Templates (Resources)
|
|
968
|
+
Read these resources to get templates and reference data:
|
|
969
|
+
- \`ema://templates/chat-ai/config\` - Chat AI persona configuration template
|
|
970
|
+
- \`ema://templates/chat-ai/readme\` - Deployment guide template
|
|
971
|
+
- \`ema://catalog/agents-summary\` - Available agents for workflow composition
|
|
972
|
+
- \`ema://catalog/patterns\` - Common workflow patterns
|
|
973
|
+
|
|
974
|
+
### Step 2: Read Validation Rules (Resources)
|
|
975
|
+
Read these resources to ensure correct workflow design:
|
|
976
|
+
- \`ema://rules/input-sources\` - Which agent inputs accept which data types
|
|
977
|
+
- \`ema://rules/anti-patterns\` - Common mistakes to avoid
|
|
978
|
+
|
|
979
|
+
### Step 3: Get Agent Recommendations (Tool)
|
|
980
|
+
Call \`action(suggest="${args.purpose}")\` for recommended agents and pattern.
|
|
981
|
+
|
|
982
|
+
### Step 4: Get Guidance (Tool)
|
|
983
|
+
Call \`reference(guidance="conversation-vs-query")\` to understand:
|
|
984
|
+
- When to use user_query vs chat_conversation
|
|
985
|
+
- Search input requirements
|
|
986
|
+
|
|
987
|
+
### Step 5: Generate Output
|
|
988
|
+
Using the templates from Step 1 and guidance from Steps 3-4, generate:
|
|
989
|
+
|
|
990
|
+
**Folder structure:**
|
|
991
|
+
\`\`\`
|
|
992
|
+
${args.name.toLowerCase().replace(/\s+/g, "-")}/
|
|
993
|
+
├── README.md # Deployment guide (based on ema://templates/chat-ai/readme)
|
|
994
|
+
├── workflow-prompt.md # Auto Builder prompt
|
|
995
|
+
├── persona-config.json # Chat settings (based on ema://templates/chat-ai/config)
|
|
996
|
+
└── docs/ # Knowledge base documents
|
|
997
|
+
└── _metadata.json
|
|
998
|
+
\`\`\`
|
|
999
|
+
|
|
1000
|
+
### Step 6: Validate
|
|
1001
|
+
Call \`reference(validate_prompt=<generated_prompt>)\` to verify the prompt.
|
|
1002
|
+
|
|
1003
|
+
Now begin by reading the resources, then proceed with generation.`,
|
|
1004
|
+
},
|
|
1005
|
+
},
|
|
1006
|
+
],
|
|
1007
|
+
},
|
|
1008
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1009
|
+
// Direct Workflow Generation (Bypasses Auto Builder)
|
|
1010
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1011
|
+
workflow_generate: {
|
|
1012
|
+
definition: {
|
|
1013
|
+
name: "workflow_generate",
|
|
1014
|
+
description: "Generate a complete workflow_def and proto_config directly, bypassing Auto Builder. Produces ready-to-deploy JSON configurations.",
|
|
1015
|
+
arguments: [
|
|
1016
|
+
{
|
|
1017
|
+
name: "name",
|
|
1018
|
+
description: "Name for the AI Employee",
|
|
1019
|
+
required: true,
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
name: "description",
|
|
1023
|
+
description: "What the AI Employee does",
|
|
1024
|
+
required: true,
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
name: "persona_type",
|
|
1028
|
+
description: "Type: 'voice', 'chat', or 'dashboard'",
|
|
1029
|
+
required: true,
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
name: "pattern",
|
|
1033
|
+
description: "Workflow pattern: 'kb_search' (FAQ/docs), 'intent_routing' (multi-intent), 'tool_calling' (external actions)",
|
|
1034
|
+
required: true,
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
name: "intents",
|
|
1038
|
+
description: "For intent_routing: comma-separated intent names with handler type, e.g., 'Search:search,Help:llm,Transfer:fixed'",
|
|
1039
|
+
required: false,
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
name: "tools",
|
|
1043
|
+
description: "For tool_calling: comma-separated tool names with namespace, e.g., 'Create_Ticket:service_now,Send_Email:outlook'",
|
|
1044
|
+
required: false,
|
|
1045
|
+
},
|
|
1046
|
+
],
|
|
1047
|
+
},
|
|
1048
|
+
render: (args) => [
|
|
1049
|
+
{
|
|
1050
|
+
role: "user",
|
|
1051
|
+
content: {
|
|
1052
|
+
type: "text",
|
|
1053
|
+
text: `Generate a complete workflow configuration for: ${args.name}
|
|
1054
|
+
|
|
1055
|
+
**Description**: ${args.description}
|
|
1056
|
+
**Persona Type**: ${args.persona_type}
|
|
1057
|
+
**Pattern**: ${args.pattern}
|
|
1058
|
+
${args.intents ? `**Intents**: ${args.intents}` : ""}
|
|
1059
|
+
${args.tools ? `**Tools**: ${args.tools}` : ""}
|
|
1060
|
+
|
|
1061
|
+
## Instructions
|
|
1062
|
+
|
|
1063
|
+
Generate deployment-ready JSON using the consolidated \`workflow\` tool (local compiler):
|
|
1064
|
+
|
|
1065
|
+
### Step 1: Generate workflow_def + proto_config (Direct / Deterministic)
|
|
1066
|
+
Call:
|
|
1067
|
+
\`workflow(input=<requirements>, type="${args.persona_type}", use_autobuilder=false)\`
|
|
1068
|
+
|
|
1069
|
+
Where \`<requirements>\` includes:
|
|
1070
|
+
- Name: ${args.name}
|
|
1071
|
+
- Description: ${args.description}
|
|
1072
|
+
- Pattern hint: ${args.pattern}
|
|
1073
|
+
${args.intents ? `- Intents: ${args.intents}` : ""}
|
|
1074
|
+
${args.tools ? `- Tools: ${args.tools}` : ""}
|
|
1075
|
+
|
|
1076
|
+
If the tool returns \`status="needs_input"\`, ask the missing questions, then call \`workflow(...)\` again with the additional details.
|
|
1077
|
+
|
|
1078
|
+
### Step 2: (Optional) Validate the generated workflow
|
|
1079
|
+
Call \`workflow(mode="analyze", workflow_def=<workflow_def>)\` and fix any critical issues before deploying.
|
|
1080
|
+
|
|
1081
|
+
### Step 3: Deploy (Optional)
|
|
1082
|
+
If you already have a persona, deploy directly:
|
|
1083
|
+
\`workflow(mode="deploy", persona_id="<persona_id>", workflow_def=<workflow_def>, proto_config=<proto_config>)\`
|
|
1084
|
+
|
|
1085
|
+
If you need to create one first:
|
|
1086
|
+
\`persona(mode="create", name="${args.name}", type="${args.persona_type}")\`
|
|
1087
|
+
then deploy as above.
|
|
1088
|
+
|
|
1089
|
+
## Output Format
|
|
1090
|
+
|
|
1091
|
+
Provide the final configurations in this format:
|
|
1092
|
+
|
|
1093
|
+
\`\`\`json
|
|
1094
|
+
// workflow_def.json
|
|
1095
|
+
{workflow_def}
|
|
1096
|
+
\`\`\`
|
|
1097
|
+
|
|
1098
|
+
\`\`\`json
|
|
1099
|
+
// proto_config.json
|
|
1100
|
+
{proto_config}
|
|
1101
|
+
\`\`\`
|
|
1102
|
+
|
|
1103
|
+
Now generate by calling \`workflow(input=<requirements>, type="${args.persona_type}", use_autobuilder=false)\`.`,
|
|
1104
|
+
},
|
|
1105
|
+
},
|
|
1106
|
+
],
|
|
1107
|
+
},
|
|
1108
|
+
workflow_deploy: {
|
|
1109
|
+
definition: {
|
|
1110
|
+
name: "workflow_deploy",
|
|
1111
|
+
description: "Deploy a generated workflow to an Ema environment. Takes workflow_def and proto_config and creates/updates an AI Employee.",
|
|
1112
|
+
arguments: [
|
|
1113
|
+
{
|
|
1114
|
+
name: "name",
|
|
1115
|
+
description: "Name for the AI Employee",
|
|
1116
|
+
required: true,
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "env",
|
|
1120
|
+
description: "Target environment (default: demo)",
|
|
1121
|
+
required: false,
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
name: "update_existing",
|
|
1125
|
+
description: "If 'true', update existing AI Employee with same name instead of creating new",
|
|
1126
|
+
required: false,
|
|
1127
|
+
},
|
|
1128
|
+
],
|
|
1129
|
+
},
|
|
1130
|
+
render: (args) => [
|
|
1131
|
+
{
|
|
1132
|
+
role: "user",
|
|
1133
|
+
content: {
|
|
1134
|
+
type: "text",
|
|
1135
|
+
text: `Deploy workflow configuration for: ${args.name}
|
|
1136
|
+
|
|
1137
|
+
**Target Environment**: ${args.env || "demo"}
|
|
1138
|
+
**Update Existing**: ${args.update_existing === "true" ? "Yes" : "No (create new)"}
|
|
1139
|
+
|
|
1140
|
+
## Instructions
|
|
1141
|
+
|
|
1142
|
+
### Pre-Deploy Checklist
|
|
1143
|
+
|
|
1144
|
+
Before deploying, ensure you have:
|
|
1145
|
+
1. ✅ Generated workflow_def using workflow_generate prompt
|
|
1146
|
+
2. ✅ Generated proto_config/persona settings
|
|
1147
|
+
3. ✅ Validated the workflow (no critical issues)
|
|
1148
|
+
|
|
1149
|
+
### Step 1: Check for Existing
|
|
1150
|
+
|
|
1151
|
+
${args.update_existing === "true" ? `
|
|
1152
|
+
Call \`persona(id="${args.name}", env="${args.env || "demo"}")\`
|
|
1153
|
+
to find the existing AI Employee (and capture its persona ID).
|
|
1154
|
+
` : `
|
|
1155
|
+
Call \`persona(query="${args.name}", env="${args.env || "demo"}")\`
|
|
1156
|
+
to check whether an AI Employee with this name already exists (and capture the persona ID if present).
|
|
1157
|
+
`}
|
|
1158
|
+
|
|
1159
|
+
### Step 2: Create or Update
|
|
1160
|
+
|
|
1161
|
+
${args.update_existing === "true" ? `
|
|
1162
|
+
If not found, create it:
|
|
1163
|
+
\`persona(mode="create", name="${args.name}", type="chat", env="${args.env || "demo"}")\`
|
|
1164
|
+
` : `
|
|
1165
|
+
Create a new AI Employee:
|
|
1166
|
+
\`persona(mode="create", name="${args.name}", type="chat", env="${args.env || "demo"}")\`
|
|
1167
|
+
`}
|
|
1168
|
+
|
|
1169
|
+
### Step 3: Configure Workflow
|
|
1170
|
+
|
|
1171
|
+
Deploy the workflow via MCP:
|
|
1172
|
+
\`workflow(mode="deploy", persona_id="<persona_id>", workflow_def=<workflow_def>, proto_config=<proto_config>, env="${args.env || "demo"}")\`
|
|
1173
|
+
|
|
1174
|
+
### Step 4: Test
|
|
1175
|
+
|
|
1176
|
+
After deployment:
|
|
1177
|
+
1. Open the AI Employee in simulator
|
|
1178
|
+
2. Test each intent/path
|
|
1179
|
+
3. Verify responses are correct
|
|
1180
|
+
4. Check HITL flows work (if applicable)
|
|
1181
|
+
|
|
1182
|
+
### Step 5: Activate
|
|
1183
|
+
|
|
1184
|
+
Once tested:
|
|
1185
|
+
1. Call \`persona(id="<persona_id>", mode="update", enabled=true, env="${args.env || "demo"}")\`
|
|
1186
|
+
2. Monitor initial conversations
|
|
1187
|
+
3. Iterate based on feedback
|
|
1188
|
+
|
|
1189
|
+
## Deployment Summary
|
|
1190
|
+
|
|
1191
|
+
Provide a deployment summary including:
|
|
1192
|
+
- AI Employee ID (if created/updated)
|
|
1193
|
+
- Environment
|
|
1194
|
+
- Workflow configuration details
|
|
1195
|
+
- Test results
|
|
1196
|
+
- Next steps
|
|
1197
|
+
|
|
1198
|
+
Now proceed with deployment.`,
|
|
1199
|
+
},
|
|
1200
|
+
},
|
|
1201
|
+
],
|
|
1202
|
+
},
|
|
1203
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1204
|
+
// Workflow Understanding & Extension
|
|
1205
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1206
|
+
workflow_explain: {
|
|
1207
|
+
definition: {
|
|
1208
|
+
name: "workflow_explain",
|
|
1209
|
+
description: "Analyze and explain a workflow's purpose, logic, data flow, and outputs. Essential for understanding intent before making modifications.",
|
|
1210
|
+
arguments: [
|
|
1211
|
+
{
|
|
1212
|
+
name: "persona_id",
|
|
1213
|
+
description: "ID of the AI Employee to explain (use with env)",
|
|
1214
|
+
required: false,
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "workflow_def",
|
|
1218
|
+
description: "Raw workflow_def JSON to explain (alternative to persona_id)",
|
|
1219
|
+
required: false,
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
name: "env",
|
|
1223
|
+
description: "Environment: 'demo', 'staging', 'prod' (default: demo)",
|
|
1224
|
+
required: false,
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
name: "depth",
|
|
1228
|
+
description: "Analysis depth: 'summary', 'detailed', 'full' (default: detailed)",
|
|
1229
|
+
required: false,
|
|
1230
|
+
},
|
|
1231
|
+
],
|
|
1232
|
+
},
|
|
1233
|
+
render: (args) => [
|
|
1234
|
+
{
|
|
1235
|
+
role: "user",
|
|
1236
|
+
content: {
|
|
1237
|
+
type: "text",
|
|
1238
|
+
text: `Analyze and explain the following workflow comprehensively.
|
|
1239
|
+
|
|
1240
|
+
${args.persona_id ? `**Persona ID**: ${args.persona_id}` : ""}
|
|
1241
|
+
${args.env ? `**Environment**: ${args.env}` : ""}
|
|
1242
|
+
${args.depth ? `**Analysis Depth**: ${args.depth}` : "**Analysis Depth**: detailed"}
|
|
1243
|
+
${args.workflow_def ? `**Workflow Definition**: Provided inline` : ""}
|
|
1244
|
+
|
|
1245
|
+
## Instructions
|
|
1246
|
+
|
|
1247
|
+
${args.persona_id ? `First, fetch the workflow:
|
|
1248
|
+
\`persona(id="${args.persona_id}", include_workflow=true, env="${args.env || "demo"}")\`
|
|
1249
|
+
|
|
1250
|
+
Then analyze it using:
|
|
1251
|
+
\`workflow(persona_id="${args.persona_id}", mode="analyze", env="${args.env || "demo"}")\`
|
|
1252
|
+
` : ""}
|
|
1253
|
+
|
|
1254
|
+
## Required Analysis Sections
|
|
1255
|
+
|
|
1256
|
+
### 1. PURPOSE & GOALS
|
|
1257
|
+
Explain the workflow's primary purpose:
|
|
1258
|
+
- **What problem does it solve?** (e.g., "Handles IT support requests via voice")
|
|
1259
|
+
- **Who is the target user?** (e.g., "Employees seeking IT help")
|
|
1260
|
+
- **What outcomes does it produce?** (e.g., "Creates tickets, provides answers")
|
|
1261
|
+
- **Business value**: Why does this workflow exist?
|
|
1262
|
+
|
|
1263
|
+
### 2. INTENT CLASSIFICATION
|
|
1264
|
+
Identify and explain the routing logic:
|
|
1265
|
+
- **Categories/Intents**: List all categories the chat_categorizer handles
|
|
1266
|
+
- **Trigger conditions**: What phrases/conditions route to each intent?
|
|
1267
|
+
- **Fallback handling**: How are unmatched queries handled?
|
|
1268
|
+
|
|
1269
|
+
### 3. DATA FLOW ANALYSIS
|
|
1270
|
+
Map how data moves through the workflow:
|
|
1271
|
+
- **Input sources**: Where data enters (trigger, user_query, chat_conversation)
|
|
1272
|
+
- **Transformations**: How data is processed (search, LLM, extraction)
|
|
1273
|
+
- **Output destinations**: Where results go (responses, external systems)
|
|
1274
|
+
|
|
1275
|
+
Create a simplified flow diagram:
|
|
1276
|
+
\`\`\`
|
|
1277
|
+
trigger → categorizer → [branch based on intent]
|
|
1278
|
+
├→ search → respond_with_sources
|
|
1279
|
+
├→ tool_caller → confirmation
|
|
1280
|
+
└→ fallback → escalation
|
|
1281
|
+
\`\`\`
|
|
1282
|
+
|
|
1283
|
+
### 4. NODE ANALYSIS
|
|
1284
|
+
For each action node, explain:
|
|
1285
|
+
- **Purpose**: What this node does
|
|
1286
|
+
- **Inputs**: What data it receives and from where
|
|
1287
|
+
- **Outputs**: What it produces
|
|
1288
|
+
- **Dependencies**: What must run before it
|
|
1289
|
+
|
|
1290
|
+
### 5. EXTERNAL INTEGRATIONS
|
|
1291
|
+
Identify external systems:
|
|
1292
|
+
- **Tools**: List external_action_caller tools (e.g., ServiceNow, Salesforce)
|
|
1293
|
+
- **Data sources**: Knowledge bases, web search, APIs
|
|
1294
|
+
- **Output channels**: Email, notifications, ticket systems
|
|
1295
|
+
|
|
1296
|
+
### 6. LOGIC & DECISION POINTS
|
|
1297
|
+
Explain conditional logic:
|
|
1298
|
+
- **Routing decisions**: How categorizer routes to different paths
|
|
1299
|
+
- **Conditional branches**: Any switch/if logic
|
|
1300
|
+
- **HITL gates**: Where human intervention is required
|
|
1301
|
+
- **Validation checks**: Data validation before actions
|
|
1302
|
+
|
|
1303
|
+
### 7. OUTPUTS & RESULTS
|
|
1304
|
+
What the workflow produces:
|
|
1305
|
+
- **Primary output**: Main response to user
|
|
1306
|
+
- **Side effects**: Tickets created, emails sent, etc.
|
|
1307
|
+
- **Success criteria**: How to know workflow succeeded
|
|
1308
|
+
|
|
1309
|
+
### 8. OPTIMIZATION OPPORTUNITIES
|
|
1310
|
+
Based on analysis, identify:
|
|
1311
|
+
- **Redundancies**: Duplicate processing, unnecessary nodes
|
|
1312
|
+
- **Type mismatches**: Input/output type conflicts
|
|
1313
|
+
- **Missing error handling**: Unhandled edge cases
|
|
1314
|
+
- **Performance concerns**: Sequential operations that could parallelize
|
|
1315
|
+
|
|
1316
|
+
## Output Format
|
|
1317
|
+
|
|
1318
|
+
Provide a structured explanation that can be used to:
|
|
1319
|
+
1. Onboard new developers to understand the workflow
|
|
1320
|
+
2. Guide modifications and extensions
|
|
1321
|
+
3. Inform optimization decisions
|
|
1322
|
+
4. Document the system for stakeholders
|
|
1323
|
+
|
|
1324
|
+
Include a one-paragraph executive summary at the start.`,
|
|
1325
|
+
},
|
|
1326
|
+
},
|
|
1327
|
+
],
|
|
1328
|
+
},
|
|
1329
|
+
workflow_extend: {
|
|
1330
|
+
definition: {
|
|
1331
|
+
name: "workflow_extend",
|
|
1332
|
+
description: "Extend an existing workflow with new capabilities while preserving existing logic. Guides through understanding current state, planning additions, and implementing changes.",
|
|
1333
|
+
arguments: [
|
|
1334
|
+
{
|
|
1335
|
+
name: "persona_id",
|
|
1336
|
+
description: "ID of the AI Employee to extend",
|
|
1337
|
+
required: true,
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
name: "requirements",
|
|
1341
|
+
description: "Description of new capabilities to add",
|
|
1342
|
+
required: true,
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
name: "env",
|
|
1346
|
+
description: "Environment: 'demo', 'staging', 'prod' (default: demo)",
|
|
1347
|
+
required: false,
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
name: "preserve_intents",
|
|
1351
|
+
description: "Comma-separated list of intents that must not be modified",
|
|
1352
|
+
required: false,
|
|
1353
|
+
},
|
|
1354
|
+
],
|
|
1355
|
+
},
|
|
1356
|
+
render: (args) => [
|
|
1357
|
+
{
|
|
1358
|
+
role: "user",
|
|
1359
|
+
content: {
|
|
1360
|
+
type: "text",
|
|
1361
|
+
text: `Extend an existing AI Employee workflow with new capabilities.
|
|
1362
|
+
|
|
1363
|
+
**Persona ID**: ${args.persona_id}
|
|
1364
|
+
**Environment**: ${args.env || "demo"}
|
|
1365
|
+
**New Requirements**:
|
|
1366
|
+
${args.requirements}
|
|
1367
|
+
${args.preserve_intents ? `**Protected Intents**: ${args.preserve_intents}` : ""}
|
|
1368
|
+
|
|
1369
|
+
## Phase 0: Clarification Checkpoint
|
|
1370
|
+
|
|
1371
|
+
**BEFORE proceeding, analyze the requirements for clarity:**
|
|
1372
|
+
|
|
1373
|
+
### Requirement Clarity Checklist:
|
|
1374
|
+
| Aspect | Clear? | If Unclear, Ask |
|
|
1375
|
+
|--------|--------|-----------------|
|
|
1376
|
+
| **What to add** | ✓/✗ | "What specific capability should be added?" |
|
|
1377
|
+
| **Where it connects** | ✓/✗ | "Should this run before/after/parallel to existing logic?" |
|
|
1378
|
+
| **Trigger conditions** | ✓/✗ | "When should this new feature activate?" |
|
|
1379
|
+
| **Data requirements** | ✓/✗ | "What data does this need? From where?" |
|
|
1380
|
+
| **Output expectations** | ✓/✗ | "What should the result look like?" |
|
|
1381
|
+
| **Preservation rules** | ✓/✗ | "Which existing paths must remain unchanged?" |
|
|
1382
|
+
|
|
1383
|
+
### If requirements are UNCLEAR:
|
|
1384
|
+
Ask clarification questions BEFORE fetching the workflow:
|
|
1385
|
+
\`\`\`
|
|
1386
|
+
Questions to resolve:
|
|
1387
|
+
1. [Most critical missing info]
|
|
1388
|
+
2. [Second priority]
|
|
1389
|
+
3. [Nice to have]
|
|
1390
|
+
|
|
1391
|
+
Defaults I'll use if you don't specify:
|
|
1392
|
+
- [Default 1]
|
|
1393
|
+
- [Default 2]
|
|
1394
|
+
|
|
1395
|
+
Reply with answers, or say "proceed with defaults"
|
|
1396
|
+
\`\`\`
|
|
1397
|
+
|
|
1398
|
+
### If requirements are CLEAR:
|
|
1399
|
+
Proceed to Phase 1.
|
|
1400
|
+
|
|
1401
|
+
---
|
|
1402
|
+
|
|
1403
|
+
## Phase 1: Understand Current State
|
|
1404
|
+
|
|
1405
|
+
### Step 1.1: Fetch and Analyze
|
|
1406
|
+
\`\`\`
|
|
1407
|
+
persona(id="${args.persona_id}", include_workflow=true, env="${args.env || "demo"}")
|
|
1408
|
+
workflow(persona_id="${args.persona_id}", mode="analyze", env="${args.env || "demo"}")
|
|
1409
|
+
\`\`\`
|
|
1410
|
+
|
|
1411
|
+
### Step 1.2: Document Existing Logic
|
|
1412
|
+
Before making changes, document:
|
|
1413
|
+
- **Current intents**: List all categories and their handlers
|
|
1414
|
+
- **Data flow**: How data moves trigger → response
|
|
1415
|
+
- **External integrations**: Tools, APIs, data sources
|
|
1416
|
+
- **Output structure**: What the workflow produces
|
|
1417
|
+
|
|
1418
|
+
### Step 1.3: Identify Impact Points
|
|
1419
|
+
Based on the requirements, identify:
|
|
1420
|
+
- **New nodes needed**: What actions to add
|
|
1421
|
+
- **Existing nodes affected**: What needs modification
|
|
1422
|
+
- **New intents/categories**: Routing changes
|
|
1423
|
+
- **New data sources**: Additional inputs needed
|
|
1424
|
+
|
|
1425
|
+
### Step 1.4: Clarification Round 2 (Post-Analysis)
|
|
1426
|
+
After understanding the existing workflow, check if NEW questions arise:
|
|
1427
|
+
- Does the request conflict with existing logic?
|
|
1428
|
+
- Are there dependencies that weren't obvious?
|
|
1429
|
+
- Is the scope larger than initially understood?
|
|
1430
|
+
|
|
1431
|
+
If new ambiguities found, pause and clarify before Phase 2.
|
|
1432
|
+
|
|
1433
|
+
---
|
|
1434
|
+
|
|
1435
|
+
## Phase 2: Plan Extensions
|
|
1436
|
+
|
|
1437
|
+
### Step 2.1: Gap Analysis
|
|
1438
|
+
Compare current state to requirements:
|
|
1439
|
+
| Requirement | Current State | Gap | Solution |
|
|
1440
|
+
|-------------|--------------|-----|----------|
|
|
1441
|
+
| [requirement 1] | [exists/missing] | [what's missing] | [how to add] |
|
|
1442
|
+
|
|
1443
|
+
### Step 2.2: Agent Selection
|
|
1444
|
+
For each new capability, identify the right agent:
|
|
1445
|
+
\`action(mode="recommend", capability="<required_capability>")\`
|
|
1446
|
+
|
|
1447
|
+
Common agents for extensions:
|
|
1448
|
+
- **text_categorizer**: Actor/role identification
|
|
1449
|
+
- **entity_extraction_with_documents**: Extract structured data
|
|
1450
|
+
- **json_mapper**: Transform data structures
|
|
1451
|
+
- **live_web_search**: Real-time data
|
|
1452
|
+
- **combine_search_results**: Merge multiple sources
|
|
1453
|
+
- **personalized_content_generator**: Rich content generation
|
|
1454
|
+
- **custom_agent**: Complex logic with custom prompts
|
|
1455
|
+
- **send_email_agent**: Email notifications
|
|
1456
|
+
- **call_llm**: Flexible LLM processing
|
|
1457
|
+
|
|
1458
|
+
### Step 2.3: Design Data Flow
|
|
1459
|
+
For new capabilities:
|
|
1460
|
+
1. **Inputs**: What data they need
|
|
1461
|
+
2. **Processing**: What transformations occur
|
|
1462
|
+
3. **Outputs**: What they produce
|
|
1463
|
+
4. **Connections**: How they connect to existing nodes
|
|
1464
|
+
|
|
1465
|
+
## Phase 3: Implement Extensions
|
|
1466
|
+
|
|
1467
|
+
### Step 3.1: Preserve Existing Logic
|
|
1468
|
+
${args.preserve_intents ? `
|
|
1469
|
+
**CRITICAL**: Do NOT modify these intents: ${args.preserve_intents}
|
|
1470
|
+
|
|
1471
|
+
These handlers must remain unchanged:
|
|
1472
|
+
- Keep their categorizer conditions
|
|
1473
|
+
- Keep their node connections
|
|
1474
|
+
- Keep their output mappings
|
|
1475
|
+
` : `
|
|
1476
|
+
Review existing intents and preserve:
|
|
1477
|
+
- Working routing logic
|
|
1478
|
+
- Validated data flows
|
|
1479
|
+
- Tested integrations
|
|
1480
|
+
`}
|
|
1481
|
+
|
|
1482
|
+
### Step 3.2: Add New Capabilities
|
|
1483
|
+
For each new requirement:
|
|
1484
|
+
|
|
1485
|
+
1. **Add nodes**: Insert new action nodes with proper:
|
|
1486
|
+
- Unique names (e.g., \`actor_identifier\`, \`entity_extractor\`)
|
|
1487
|
+
- Correct action types from the agent catalog
|
|
1488
|
+
- Input bindings from existing nodes or trigger
|
|
1489
|
+
|
|
1490
|
+
2. **Update routing**: Modify categorizer to include new categories:
|
|
1491
|
+
- Add category definitions
|
|
1492
|
+
- Define routing conditions
|
|
1493
|
+
- Add example phrases
|
|
1494
|
+
|
|
1495
|
+
3. **Connect data flow**: Wire inputs/outputs:
|
|
1496
|
+
- Use \`actionOutput\` bindings
|
|
1497
|
+
- Use \`multiBinding\` for multiple inputs
|
|
1498
|
+
- Use \`named_inputs\` for additional context
|
|
1499
|
+
|
|
1500
|
+
### Step 3.3: Generate Extended Workflow
|
|
1501
|
+
\`\`\`
|
|
1502
|
+
workflow(
|
|
1503
|
+
persona_id="${args.persona_id}",
|
|
1504
|
+
mode="generate",
|
|
1505
|
+
input="<detailed requirements with current workflow context>",
|
|
1506
|
+
env="${args.env || "demo"}"
|
|
1507
|
+
)
|
|
1508
|
+
\`\`\`
|
|
1509
|
+
|
|
1510
|
+
## Phase 4: Validate & Deploy
|
|
1511
|
+
|
|
1512
|
+
### Step 4.1: Analyze Changes
|
|
1513
|
+
\`workflow(persona_id="${args.persona_id}", mode="analyze")\`
|
|
1514
|
+
|
|
1515
|
+
Verify:
|
|
1516
|
+
- [ ] No type mismatches
|
|
1517
|
+
- [ ] No broken connections
|
|
1518
|
+
- [ ] All new nodes properly linked
|
|
1519
|
+
- [ ] Existing functionality preserved
|
|
1520
|
+
|
|
1521
|
+
### Step 4.2: Preview Changes
|
|
1522
|
+
\`workflow(persona_id="${args.persona_id}", mode="optimize", preview=true)\`
|
|
1523
|
+
|
|
1524
|
+
### Step 4.3: Deploy
|
|
1525
|
+
\`workflow(persona_id="${args.persona_id}", mode="deploy", workflow_def=<extended_workflow>)\`
|
|
1526
|
+
|
|
1527
|
+
## Extension Patterns
|
|
1528
|
+
|
|
1529
|
+
### Pattern: Add Actor Identification
|
|
1530
|
+
\`\`\`
|
|
1531
|
+
trigger → text_categorizer(actor) → [client|advisor|unknown]
|
|
1532
|
+
├→ known_actor → continue_flow
|
|
1533
|
+
└→ unknown → call_llm(identify) → validate
|
|
1534
|
+
\`\`\`
|
|
1535
|
+
|
|
1536
|
+
### Pattern: Add Entity Extraction
|
|
1537
|
+
\`\`\`
|
|
1538
|
+
trigger → entity_extraction_with_documents → json_mapper → downstream_nodes
|
|
1539
|
+
\`\`\`
|
|
1540
|
+
|
|
1541
|
+
### Pattern: Add Parallel Search
|
|
1542
|
+
\`\`\`
|
|
1543
|
+
trigger → [parallel]
|
|
1544
|
+
├→ search(kb)
|
|
1545
|
+
└→ live_web_search
|
|
1546
|
+
combine_search_results → respond
|
|
1547
|
+
\`\`\`
|
|
1548
|
+
|
|
1549
|
+
### Pattern: Add Email Notification
|
|
1550
|
+
\`\`\`
|
|
1551
|
+
response_node → fixed_response(email_parts) → send_email_agent
|
|
1552
|
+
\`\`\`
|
|
1553
|
+
|
|
1554
|
+
### Pattern: Add Multi-Branch Merger
|
|
1555
|
+
\`\`\`
|
|
1556
|
+
categorizer → [intent_a, intent_b, intent_c]
|
|
1557
|
+
↓
|
|
1558
|
+
call_llm(merger) → unified_response
|
|
1559
|
+
\`\`\`
|
|
1560
|
+
|
|
1561
|
+
## Output Requirements
|
|
1562
|
+
|
|
1563
|
+
Provide:
|
|
1564
|
+
1. **Extension Plan**: Detailed steps for each new capability
|
|
1565
|
+
2. **Node Additions**: Specific nodes to add with configurations
|
|
1566
|
+
3. **Routing Changes**: Updated categorizer categories
|
|
1567
|
+
4. **Data Flow Diagram**: Visual representation of extended workflow
|
|
1568
|
+
5. **Validation Checklist**: Tests for new and existing functionality
|
|
1569
|
+
6. **Deployment Commands**: Ready-to-execute MCP commands`,
|
|
1570
|
+
},
|
|
1571
|
+
},
|
|
1572
|
+
],
|
|
1573
|
+
},
|
|
1574
|
+
workflow_analyze_intent: {
|
|
1575
|
+
definition: {
|
|
1576
|
+
name: "workflow_analyze_intent",
|
|
1577
|
+
description: "Deep analysis of workflow intent, goals, and business logic. Use before optimization to understand the 'why' behind the workflow structure.",
|
|
1578
|
+
arguments: [
|
|
1579
|
+
{
|
|
1580
|
+
name: "persona_id",
|
|
1581
|
+
description: "ID of the AI Employee to analyze",
|
|
1582
|
+
required: true,
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
name: "env",
|
|
1586
|
+
description: "Environment: 'demo', 'staging', 'prod' (default: demo)",
|
|
1587
|
+
required: false,
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
name: "focus",
|
|
1591
|
+
description: "Focus area: 'routing', 'data_flow', 'integrations', 'outputs', 'all' (default: all)",
|
|
1592
|
+
required: false,
|
|
1593
|
+
},
|
|
1594
|
+
],
|
|
1595
|
+
},
|
|
1596
|
+
render: (args) => [
|
|
1597
|
+
{
|
|
1598
|
+
role: "user",
|
|
1599
|
+
content: {
|
|
1600
|
+
type: "text",
|
|
1601
|
+
text: `Perform deep intent analysis on a workflow to understand its purpose and business logic.
|
|
1602
|
+
|
|
1603
|
+
**Persona ID**: ${args.persona_id}
|
|
1604
|
+
**Environment**: ${args.env || "demo"}
|
|
1605
|
+
**Focus Area**: ${args.focus || "all"}
|
|
1606
|
+
|
|
1607
|
+
## Step 1: Fetch Workflow Data
|
|
1608
|
+
|
|
1609
|
+
\`\`\`
|
|
1610
|
+
persona(id="${args.persona_id}", include_workflow=true, env="${args.env || "demo"}")
|
|
1611
|
+
workflow(persona_id="${args.persona_id}", mode="analyze", env="${args.env || "demo"}")
|
|
1612
|
+
\`\`\`
|
|
1613
|
+
|
|
1614
|
+
## Step 2: Intent Analysis Framework
|
|
1615
|
+
|
|
1616
|
+
### Business Intent Layer
|
|
1617
|
+
Answer these questions:
|
|
1618
|
+
1. **Primary Mission**: What is this AI Employee's main job?
|
|
1619
|
+
2. **User Journey**: What experience should users have?
|
|
1620
|
+
3. **Success Metrics**: How do we measure this workflow working?
|
|
1621
|
+
4. **Failure Modes**: What happens when things go wrong?
|
|
1622
|
+
|
|
1623
|
+
### Functional Intent Layer
|
|
1624
|
+
For each major path in the workflow:
|
|
1625
|
+
1. **Trigger Condition**: What initiates this path?
|
|
1626
|
+
2. **Processing Goal**: What transformation happens?
|
|
1627
|
+
3. **Expected Outcome**: What should result?
|
|
1628
|
+
4. **Side Effects**: What else happens (tickets, emails, logs)?
|
|
1629
|
+
|
|
1630
|
+
### Technical Intent Layer
|
|
1631
|
+
For each node:
|
|
1632
|
+
1. **Why this agent?**: Why was this specific action type chosen?
|
|
1633
|
+
2. **Data requirements**: What inputs are essential vs optional?
|
|
1634
|
+
3. **Output usage**: Where does this node's output go?
|
|
1635
|
+
4. **Error handling**: What happens if this node fails?
|
|
1636
|
+
|
|
1637
|
+
## Step 3: Intent Mapping
|
|
1638
|
+
|
|
1639
|
+
Create an intent map:
|
|
1640
|
+
\`\`\`
|
|
1641
|
+
WORKFLOW: [Name]
|
|
1642
|
+
├── GOAL: [Primary business goal]
|
|
1643
|
+
├── USERS: [Target user types]
|
|
1644
|
+
├── INTENTS:
|
|
1645
|
+
│ ├── [Intent 1]: [Business purpose]
|
|
1646
|
+
│ │ └── PATH: trigger → [nodes] → [outcome]
|
|
1647
|
+
│ ├── [Intent 2]: [Business purpose]
|
|
1648
|
+
│ │ └── PATH: trigger → [nodes] → [outcome]
|
|
1649
|
+
│ └── [Fallback]: [How unmatched handled]
|
|
1650
|
+
├── INTEGRATIONS:
|
|
1651
|
+
│ ├── [System 1]: [Why integrated]
|
|
1652
|
+
│ └── [System 2]: [Why integrated]
|
|
1653
|
+
└── OUTPUTS:
|
|
1654
|
+
├── [Output 1]: [Purpose]
|
|
1655
|
+
└── [Output 2]: [Purpose]
|
|
1656
|
+
\`\`\`
|
|
1657
|
+
|
|
1658
|
+
## Step 4: Logic Analysis
|
|
1659
|
+
|
|
1660
|
+
### Decision Points
|
|
1661
|
+
For each categorizer/router:
|
|
1662
|
+
- **Decision criteria**: How does it decide?
|
|
1663
|
+
- **Category definitions**: What defines each category?
|
|
1664
|
+
- **Edge cases**: What about ambiguous inputs?
|
|
1665
|
+
|
|
1666
|
+
### Data Transformations
|
|
1667
|
+
For each processing node:
|
|
1668
|
+
- **Input shape**: What structure enters?
|
|
1669
|
+
- **Transformation logic**: What changes?
|
|
1670
|
+
- **Output shape**: What structure exits?
|
|
1671
|
+
|
|
1672
|
+
### Integration Logic
|
|
1673
|
+
For each external call:
|
|
1674
|
+
- **When triggered**: Under what conditions?
|
|
1675
|
+
- **What data sent**: What information flows out?
|
|
1676
|
+
- **What data received**: What comes back?
|
|
1677
|
+
- **How used**: Where does the response go?
|
|
1678
|
+
|
|
1679
|
+
## Step 5: Optimization Insights
|
|
1680
|
+
|
|
1681
|
+
Based on intent analysis, identify:
|
|
1682
|
+
|
|
1683
|
+
### Alignment Issues
|
|
1684
|
+
- Nodes that don't serve clear intent
|
|
1685
|
+
- Redundant processing
|
|
1686
|
+
- Missing error paths
|
|
1687
|
+
|
|
1688
|
+
### Enhancement Opportunities
|
|
1689
|
+
- Intents that could be added
|
|
1690
|
+
- Data that could be captured
|
|
1691
|
+
- Outputs that could be enriched
|
|
1692
|
+
|
|
1693
|
+
### Structural Improvements
|
|
1694
|
+
- Parallel processing opportunities
|
|
1695
|
+
- Caching opportunities
|
|
1696
|
+
- Simplification possibilities
|
|
1697
|
+
|
|
1698
|
+
## Output Format
|
|
1699
|
+
|
|
1700
|
+
Provide:
|
|
1701
|
+
1. **Executive Summary**: 2-3 sentence overview
|
|
1702
|
+
2. **Intent Map**: Visual hierarchy of goals/intents/paths
|
|
1703
|
+
3. **Logic Explanation**: Natural language description of how it works
|
|
1704
|
+
4. **Decision Tree**: How routing decisions are made
|
|
1705
|
+
5. **Optimization Recommendations**: Improvements aligned with intent
|
|
1706
|
+
6. **Questions for Stakeholders**: Clarifications needed for better optimization`,
|
|
1707
|
+
},
|
|
1708
|
+
},
|
|
1709
|
+
],
|
|
1710
|
+
},
|
|
1711
|
+
};
|
|
1712
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1713
|
+
// Prompt Registry
|
|
1714
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1715
|
+
export class PromptRegistry {
|
|
1716
|
+
/**
|
|
1717
|
+
* List all available prompts
|
|
1718
|
+
*/
|
|
1719
|
+
list() {
|
|
1720
|
+
return Object.values(PROMPTS).map((p) => p.definition);
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Get a rendered prompt by name with arguments
|
|
1724
|
+
*/
|
|
1725
|
+
get(name, args = {}) {
|
|
1726
|
+
const prompt = PROMPTS[name];
|
|
1727
|
+
if (!prompt) {
|
|
1728
|
+
return {
|
|
1729
|
+
code: "NOT_FOUND",
|
|
1730
|
+
message: `Prompt not found: ${name}. Use prompts/list to see available prompts.`,
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
// Validate required arguments
|
|
1734
|
+
for (const arg of prompt.definition.arguments) {
|
|
1735
|
+
if (arg.required && !args[arg.name]) {
|
|
1736
|
+
return {
|
|
1737
|
+
code: "MISSING_REQUIRED_ARG",
|
|
1738
|
+
message: `Missing required argument: ${arg.name}`,
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
// Render the prompt
|
|
1743
|
+
const messages = prompt.render(args);
|
|
1744
|
+
return {
|
|
1745
|
+
description: prompt.definition.description,
|
|
1746
|
+
messages,
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
// Helper to check if result is an error
|
|
1751
|
+
export function isPromptError(result) {
|
|
1752
|
+
return "code" in result;
|
|
1753
|
+
}
|