@ema.co/mcp-toolkit 2026.1.25 → 2026.1.26-4
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.
Potentially problematic release.
This version of @ema.co/mcp-toolkit might be problematic. Click here for more details.
- package/README.md +10 -2
- package/dist/mcp/handlers/action/index.js +3 -18
- package/dist/mcp/handlers/data/index.js +385 -41
- package/dist/mcp/handlers/data/templates.js +107 -0
- package/dist/mcp/handlers/deprecation.js +50 -0
- package/dist/mcp/handlers/env/index.js +8 -4
- package/dist/mcp/handlers/knowledge/index.js +44 -237
- package/dist/mcp/handlers/persona/create.js +47 -18
- package/dist/mcp/handlers/persona/index.js +14 -11
- package/dist/mcp/handlers/persona/update.js +4 -2
- package/dist/mcp/handlers/persona/version.js +234 -0
- package/dist/mcp/handlers/sync/index.js +3 -18
- package/dist/mcp/handlers/template/index.js +75 -10
- package/dist/mcp/handlers/workflow/analyze.js +171 -0
- package/dist/mcp/handlers/workflow/compare.js +70 -0
- package/dist/mcp/handlers/workflow/deploy.js +73 -0
- package/dist/mcp/handlers/workflow/generate.js +350 -0
- package/dist/mcp/handlers/workflow/index.js +294 -0
- package/dist/mcp/handlers/workflow/modify.js +456 -0
- package/dist/mcp/handlers/workflow/optimize.js +136 -0
- package/dist/mcp/handlers/workflow/types.js +4 -0
- package/dist/mcp/handlers/workflow/utils.js +30 -0
- package/dist/mcp/handlers-consolidated.js +73 -2696
- package/dist/mcp/prompts.js +83 -43
- package/dist/mcp/resources.js +382 -57
- package/dist/mcp/server.js +199 -391
- package/dist/mcp/{tools-v2.js → tools.js} +20 -54
- package/dist/mcp/workflow-operations.js +2 -2
- package/dist/sdk/client-adapter.js +267 -32
- package/dist/sdk/client.js +45 -16
- package/dist/sdk/ema-client.js +183 -0
- package/dist/sdk/generated/deprecated-actions.js +171 -0
- package/dist/sdk/generated/template-fallbacks.js +123 -0
- package/dist/sdk/guidance.js +65 -11
- package/dist/sdk/index.js +3 -1
- package/dist/sdk/knowledge.js +139 -86
- package/dist/sdk/workflow-intent.js +27 -0
- package/dist/sdk/workflow-transformer.js +0 -342
- package/docs/mcp-tools-guide.md +37 -45
- package/package.json +10 -4
- package/dist/mcp/handlers/persona/analyze.js +0 -275
- package/dist/mcp/handlers/persona/compare.js +0 -32
- package/dist/mcp/tools-consolidated.js +0 -875
- package/dist/mcp/tools-legacy.js +0 -736
- package/docs/CODEBASE-ANALYSIS-2026-01-23.md +0 -936
- package/docs/CODEBASE-ANALYSIS-PRIORITIZED.md +0 -774
- package/docs/api-contracts.md +0 -216
- package/docs/auto-builder-analysis.md +0 -271
- package/docs/blog/mcp-tool-design-lessons.md +0 -309
- package/docs/data-architecture.md +0 -166
- package/docs/demos/ap-invoice-generation.md +0 -347
- package/docs/demos/ap-invoice-processing.md +0 -271
- package/docs/ema-auto-builder-guide.html +0 -394
- package/docs/lessons-learned.md +0 -209
- package/docs/llm-native-workflow-design.md +0 -252
- package/docs/local-generation.md +0 -508
- package/docs/mcp-flow-diagram.md +0 -135
- package/docs/migration/action-composition-migration.md +0 -270
- package/docs/naming-conventions.md +0 -278
- package/docs/proposals/HANDOFF-tool-restructure.md +0 -526
- package/docs/proposals/action-composition.md +0 -490
- package/docs/proposals/explicit-method-restructure.md +0 -328
- package/docs/proposals/mcp-tool-restructure-2026-01.md +0 -366
- package/docs/proposals/self-contained-guidance.md +0 -427
- package/docs/proto-sdk-generation.md +0 -242
- package/docs/release-impact.md +0 -102
- package/docs/release-process.md +0 -157
- package/docs/staging.RULE.md +0 -142
- package/docs/test-persona-creation.md +0 -196
- package/docs/tool-consolidation-v2.md +0 -225
- package/docs/tool-response-standards.md +0 -256
- package/resources/demo-kits/README.md +0 -175
- package/resources/demo-kits/finance-ap/manifest.json +0 -150
- package/resources/demo-kits/tags.json +0 -91
- package/resources/docs/getting-started.md +0 -97
- package/resources/templates/auto-builder-rules.md +0 -224
- package/resources/templates/chat-ai/README.md +0 -119
- package/resources/templates/chat-ai/persona-config.json +0 -111
- package/resources/templates/dashboard-ai/README.md +0 -156
- package/resources/templates/dashboard-ai/persona-config.json +0 -180
- package/resources/templates/demo-scenarios/README.md +0 -63
- package/resources/templates/demo-scenarios/test-published-package.md +0 -116
- package/resources/templates/document-gen-ai/README.md +0 -132
- package/resources/templates/document-gen-ai/persona-config.json +0 -316
- package/resources/templates/voice-ai/README.md +0 -123
- package/resources/templates/voice-ai/persona-config.json +0 -74
- package/resources/templates/voice-ai/workflow-prompt.md +0 -121
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "finance-ap",
|
|
3
|
-
"name": "Finance - Accounts Payable Automation",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "End-to-end AP invoice processing and generation automation. Demonstrates inbound invoice processing (AP) and outbound invoice generation (AR).",
|
|
6
|
-
"domain": "finance",
|
|
7
|
-
"tags": [
|
|
8
|
-
"finance",
|
|
9
|
-
"invoice",
|
|
10
|
-
"automation",
|
|
11
|
-
"ap-automation",
|
|
12
|
-
"ar-automation",
|
|
13
|
-
"coupa",
|
|
14
|
-
"usage-billing"
|
|
15
|
-
],
|
|
16
|
-
"personas": [
|
|
17
|
-
{
|
|
18
|
-
"id": "fa91cb51-58fe-4255-b2d2-0b3e3a72cf7e",
|
|
19
|
-
"name": "AP Invoice Processing",
|
|
20
|
-
"role": "primary",
|
|
21
|
-
"description": "Processes inbound invoices: extract data, validate against PO, create in Coupa, notify supplier",
|
|
22
|
-
"workflow_nodes": 5,
|
|
23
|
-
"integrations": ["coupa"]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"id": "d73c8dca-d340-4541-a7ff-ae69f2810906",
|
|
27
|
-
"name": "AP Invoice Generation",
|
|
28
|
-
"role": "primary",
|
|
29
|
-
"description": "Generates outbound invoices: validate customer/usage/contract, generate professional document",
|
|
30
|
-
"workflow_nodes": 12,
|
|
31
|
-
"integrations": ["salesforce", "usage-api", "contract-db"]
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"prerequisites": {
|
|
35
|
-
"integrations": ["coupa", "salesforce"],
|
|
36
|
-
"data": ["sample-invoices", "sample-contracts", "usage-data"],
|
|
37
|
-
"environment": "demo"
|
|
38
|
-
},
|
|
39
|
-
"demo_flow": [
|
|
40
|
-
{
|
|
41
|
-
"step": 1,
|
|
42
|
-
"title": "The Problem",
|
|
43
|
-
"duration_minutes": 2,
|
|
44
|
-
"talking_points": [
|
|
45
|
-
"Manual data entry takes 15-20 min per invoice",
|
|
46
|
-
"30-40% first-pass match rate",
|
|
47
|
-
"Supplier complaints about payment status"
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"step": 2,
|
|
52
|
-
"title": "Inbound Processing Demo",
|
|
53
|
-
"duration_minutes": 5,
|
|
54
|
-
"persona": "fa91cb51-58fe-4255-b2d2-0b3e3a72cf7e",
|
|
55
|
-
"actions": [
|
|
56
|
-
"Upload sample invoice",
|
|
57
|
-
"Show extraction results",
|
|
58
|
-
"Show PO validation",
|
|
59
|
-
"Show Coupa entry creation",
|
|
60
|
-
"Show supplier notification"
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"step": 3,
|
|
65
|
-
"title": "Outbound Generation Demo",
|
|
66
|
-
"duration_minutes": 5,
|
|
67
|
-
"persona": "d73c8dca-d340-4541-a7ff-ae69f2810906",
|
|
68
|
-
"actions": [
|
|
69
|
-
"Show data source connections",
|
|
70
|
-
"Show customer validation",
|
|
71
|
-
"Show usage aggregation",
|
|
72
|
-
"Show contract validation",
|
|
73
|
-
"Show generated invoice document"
|
|
74
|
-
]
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"step": 4,
|
|
78
|
-
"title": "ROI Discussion",
|
|
79
|
-
"duration_minutes": 2,
|
|
80
|
-
"talking_points": [
|
|
81
|
-
"$10.50 savings per invoice",
|
|
82
|
-
"95% time reduction for generation",
|
|
83
|
-
"Revenue leakage prevention"
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"step": 5,
|
|
88
|
-
"title": "Next Steps",
|
|
89
|
-
"duration_minutes": 1,
|
|
90
|
-
"actions": [
|
|
91
|
-
"Propose pilot program",
|
|
92
|
-
"Share ROI calculator"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
"target_audience": {
|
|
97
|
-
"primary": "AP Manager / Controller",
|
|
98
|
-
"secondary": ["CFO", "RevOps Manager", "IT Director"],
|
|
99
|
-
"company_size": "mid-market to enterprise",
|
|
100
|
-
"industries": ["manufacturing", "retail", "saas", "distribution"]
|
|
101
|
-
},
|
|
102
|
-
"roi_metrics": {
|
|
103
|
-
"ap_processing": {
|
|
104
|
-
"time_saved_per_invoice": "13 minutes",
|
|
105
|
-
"volume_per_month": 10000,
|
|
106
|
-
"cost_per_invoice_before": 12,
|
|
107
|
-
"cost_per_invoice_after": 1.5,
|
|
108
|
-
"monthly_savings": 105000
|
|
109
|
-
},
|
|
110
|
-
"invoice_generation": {
|
|
111
|
-
"time_saved_per_invoice": "2.5 hours",
|
|
112
|
-
"volume_per_month": 500,
|
|
113
|
-
"cost_per_invoice_before": 150,
|
|
114
|
-
"cost_per_invoice_after": 4,
|
|
115
|
-
"monthly_savings": 73000
|
|
116
|
-
},
|
|
117
|
-
"revenue_protection": {
|
|
118
|
-
"error_rate_before": "5%",
|
|
119
|
-
"error_rate_after": "0.5%",
|
|
120
|
-
"monthly_billings": 10000000,
|
|
121
|
-
"protected_revenue": 450000
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
"objections": [
|
|
125
|
-
{
|
|
126
|
-
"objection": "We already have OCR",
|
|
127
|
-
"response": "OCR extracts text. Ema understands context, validates against your systems, and takes action."
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"objection": "Our pricing is too complex",
|
|
131
|
-
"response": "The more complex your pricing, the more value from automation. Can I see your most complex contract?"
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"objection": "Security concerns",
|
|
135
|
-
"response": "Ema connects via your existing APIs. Credentials in your vault, full audit logging."
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
"leave_behinds": [
|
|
139
|
-
"ROI Calculator (Excel)",
|
|
140
|
-
"Architecture Diagram",
|
|
141
|
-
"Sample Validation Report",
|
|
142
|
-
"Customer Case Study"
|
|
143
|
-
],
|
|
144
|
-
"related_kits": [
|
|
145
|
-
"finance-treasury",
|
|
146
|
-
"finance-reporting"
|
|
147
|
-
],
|
|
148
|
-
"created": "2026-01-24",
|
|
149
|
-
"updated": "2026-01-24"
|
|
150
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "1.0.0",
|
|
3
|
-
"description": "Tagging taxonomy for demo kits and personas",
|
|
4
|
-
"categories": {
|
|
5
|
-
"domain": {
|
|
6
|
-
"description": "Business domain or department",
|
|
7
|
-
"tags": [
|
|
8
|
-
{ "id": "finance", "name": "Finance", "description": "Financial operations, accounting, treasury" },
|
|
9
|
-
{ "id": "sales", "name": "Sales", "description": "Sales operations, SDR, AE workflows" },
|
|
10
|
-
{ "id": "support", "name": "Support", "description": "Customer support and service" },
|
|
11
|
-
{ "id": "hr", "name": "HR", "description": "Human resources, recruiting, employee services" },
|
|
12
|
-
{ "id": "it", "name": "IT", "description": "IT operations, security, infrastructure" },
|
|
13
|
-
{ "id": "legal", "name": "Legal", "description": "Legal operations, contracts, compliance" },
|
|
14
|
-
{ "id": "marketing", "name": "Marketing", "description": "Marketing operations, campaigns, analytics" },
|
|
15
|
-
{ "id": "operations", "name": "Operations", "description": "General business operations" },
|
|
16
|
-
{ "id": "procurement", "name": "Procurement", "description": "Procurement, vendor management" }
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
"capability": {
|
|
20
|
-
"description": "Technical capability or interaction type",
|
|
21
|
-
"tags": [
|
|
22
|
-
{ "id": "voice", "name": "Voice", "description": "Voice/phone interactions" },
|
|
23
|
-
{ "id": "chat", "name": "Chat", "description": "Chat/messaging interactions" },
|
|
24
|
-
{ "id": "dashboard", "name": "Dashboard", "description": "Dashboard/data processing" },
|
|
25
|
-
{ "id": "document", "name": "Document", "description": "Document generation" },
|
|
26
|
-
{ "id": "automation", "name": "Automation", "description": "Process automation" },
|
|
27
|
-
{ "id": "analysis", "name": "Analysis", "description": "Data analysis and insights" },
|
|
28
|
-
{ "id": "extraction", "name": "Extraction", "description": "Data/entity extraction" },
|
|
29
|
-
{ "id": "validation", "name": "Validation", "description": "Data validation and verification" }
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
"use_case": {
|
|
33
|
-
"description": "Specific use case or process",
|
|
34
|
-
"tags": [
|
|
35
|
-
{ "id": "invoice", "name": "Invoice", "description": "Invoice processing or generation" },
|
|
36
|
-
{ "id": "billing", "name": "Billing", "description": "Billing operations" },
|
|
37
|
-
{ "id": "onboarding", "name": "Onboarding", "description": "Employee or customer onboarding" },
|
|
38
|
-
{ "id": "compliance", "name": "Compliance", "description": "Compliance and audit" },
|
|
39
|
-
{ "id": "reporting", "name": "Reporting", "description": "Reporting and analytics" },
|
|
40
|
-
{ "id": "routing", "name": "Routing", "description": "Request/ticket routing" },
|
|
41
|
-
{ "id": "scheduling", "name": "Scheduling", "description": "Meeting/appointment scheduling" },
|
|
42
|
-
{ "id": "order", "name": "Order", "description": "Order processing" },
|
|
43
|
-
{ "id": "claims", "name": "Claims", "description": "Claims processing" }
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"integration": {
|
|
47
|
-
"description": "External system integrations",
|
|
48
|
-
"tags": [
|
|
49
|
-
{ "id": "coupa", "name": "Coupa", "description": "Coupa procurement platform" },
|
|
50
|
-
{ "id": "salesforce", "name": "Salesforce", "description": "Salesforce CRM" },
|
|
51
|
-
{ "id": "servicenow", "name": "ServiceNow", "description": "ServiceNow ITSM" },
|
|
52
|
-
{ "id": "workday", "name": "Workday", "description": "Workday HCM" },
|
|
53
|
-
{ "id": "sap", "name": "SAP", "description": "SAP ERP" },
|
|
54
|
-
{ "id": "oracle", "name": "Oracle", "description": "Oracle applications" },
|
|
55
|
-
{ "id": "netsuite", "name": "NetSuite", "description": "Oracle NetSuite" },
|
|
56
|
-
{ "id": "hubspot", "name": "HubSpot", "description": "HubSpot CRM/marketing" },
|
|
57
|
-
{ "id": "zendesk", "name": "Zendesk", "description": "Zendesk support" },
|
|
58
|
-
{ "id": "jira", "name": "Jira", "description": "Atlassian Jira" }
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
"complexity": {
|
|
62
|
-
"description": "Demo complexity level",
|
|
63
|
-
"tags": [
|
|
64
|
-
{ "id": "simple", "name": "Simple", "description": "1-5 workflow nodes, single integration" },
|
|
65
|
-
{ "id": "moderate", "name": "Moderate", "description": "5-10 workflow nodes, 2-3 integrations" },
|
|
66
|
-
{ "id": "complex", "name": "Complex", "description": "10+ workflow nodes, multiple integrations" }
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
"bundle": {
|
|
70
|
-
"description": "Kit organization",
|
|
71
|
-
"tags": [
|
|
72
|
-
{ "id": "demo-kit", "name": "Demo Kit", "description": "Complete demo package with scripts" },
|
|
73
|
-
{ "id": "bundle", "name": "Bundle", "description": "Collection of related kits" },
|
|
74
|
-
{ "id": "template", "name": "Template", "description": "Reusable template" },
|
|
75
|
-
{ "id": "example", "name": "Example", "description": "Example/reference implementation" }
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"tag_rules": {
|
|
80
|
-
"required_for_kit": ["domain"],
|
|
81
|
-
"recommended_for_kit": ["capability", "use_case"],
|
|
82
|
-
"max_tags_per_category": 3
|
|
83
|
-
},
|
|
84
|
-
"search_aliases": {
|
|
85
|
-
"ap": ["finance", "invoice", "accounts-payable"],
|
|
86
|
-
"ar": ["finance", "billing", "accounts-receivable"],
|
|
87
|
-
"sdr": ["sales", "outbound", "prospecting"],
|
|
88
|
-
"tier1": ["support", "customer-service"],
|
|
89
|
-
"faq": ["support", "knowledge", "self-service"]
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Getting Started with Ema MCP
|
|
2
|
-
|
|
3
|
-
Welcome! This guide helps you work effectively with Ema AI Employees.
|
|
4
|
-
|
|
5
|
-
## First Steps
|
|
6
|
-
|
|
7
|
-
### 1. List Available Personas
|
|
8
|
-
```
|
|
9
|
-
persona(mode="list")
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
### 2. Get Details on One
|
|
13
|
-
```
|
|
14
|
-
persona(mode="get", id="persona-name-or-id")
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### 3. Create Your First AI Employee
|
|
18
|
-
```
|
|
19
|
-
persona(mode="create", name="My Assistant", type="voice", input="Handles customer support inquiries", preview=true)
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Key Concepts
|
|
23
|
-
|
|
24
|
-
| Term | Meaning |
|
|
25
|
-
|------|---------|
|
|
26
|
-
| **Persona** | An AI Employee (Voice, Chat, or Dashboard) |
|
|
27
|
-
| **Workflow** | The logic that powers a persona |
|
|
28
|
-
| **Action** | A building block in workflows (search, email, ticket, etc.) |
|
|
29
|
-
| **HITL** | Human-in-the-loop - approval before taking action |
|
|
30
|
-
|
|
31
|
-
## Essential Rules
|
|
32
|
-
|
|
33
|
-
### 1. Always Preview First
|
|
34
|
-
```
|
|
35
|
-
preview=true # Safe - shows what would happen
|
|
36
|
-
preview=false # Deploys to production
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. One Call, Complete Information
|
|
40
|
-
Don't make multiple calls. Put all parameters in one call:
|
|
41
|
-
```
|
|
42
|
-
# ✅ Good
|
|
43
|
-
persona(mode="create", name="Bot", type="voice", input="...", preview=false)
|
|
44
|
-
|
|
45
|
-
# ❌ Bad - multiple calls
|
|
46
|
-
persona(mode="create", name="Bot")
|
|
47
|
-
persona(mode="update", ...)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### 3. Ask Before Creating
|
|
51
|
-
Before creating a new persona, ask:
|
|
52
|
-
- What should it do? (purpose)
|
|
53
|
-
- What type? (voice/chat/dashboard)
|
|
54
|
-
- What name?
|
|
55
|
-
|
|
56
|
-
### 4. Use Templates
|
|
57
|
-
List available templates:
|
|
58
|
-
```
|
|
59
|
-
persona(mode="templates")
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Create from template (recommended):
|
|
63
|
-
```
|
|
64
|
-
persona(mode="create", from="Voice AI Starter", name="My SDR", preview=false)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Common Operations
|
|
68
|
-
|
|
69
|
-
| Task | Command |
|
|
70
|
-
|------|---------|
|
|
71
|
-
| List all personas | `persona(mode="list")` |
|
|
72
|
-
| Get one | `persona(mode="get", id="...")` |
|
|
73
|
-
| Create new | `persona(mode="create", name="...", type="voice", input="...")` |
|
|
74
|
-
| Update | `persona(mode="update", id="...", proto_config={...})` |
|
|
75
|
-
| Analyze issues | `persona(mode="analyze", id="...")` |
|
|
76
|
-
| Compare two | `persona(mode="compare", id="...", compare_to="...")` |
|
|
77
|
-
|
|
78
|
-
## Getting Help
|
|
79
|
-
|
|
80
|
-
- **List actions**: `action(all=true)`
|
|
81
|
-
- **Get guidance**: `reference(guidance="hitl-patterns")`
|
|
82
|
-
- **Common mistakes**: `reference(mistakes=true)`
|
|
83
|
-
- **Check templates**: `template(patterns=true)`
|
|
84
|
-
|
|
85
|
-
## Environments
|
|
86
|
-
|
|
87
|
-
Most users have multiple environments (demo, staging, prod).
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
# List environments
|
|
91
|
-
env()
|
|
92
|
-
|
|
93
|
-
# Target specific environment
|
|
94
|
-
persona(mode="list", env="prod")
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Default is usually `demo` (safe for testing).
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# Auto-Builder Workflow Rules
|
|
2
|
-
|
|
3
|
-
> These rules are used by the LLM when generating workflow graphs for Ema AI Employees.
|
|
4
|
-
|
|
5
|
-
## Action-Specific Instructions
|
|
6
|
-
|
|
7
|
-
### Chat Categorizer (Intent Classifier)
|
|
8
|
-
- Classifies user intent into predefined categories for routing
|
|
9
|
-
- **CRITICAL**: ALWAYS include a `Fallback` category - workflow validation fails without it
|
|
10
|
-
- **MUST** create a handler node for EACH category defined
|
|
11
|
-
- Downstream nodes use `runIf` conditions to check `category` output against `enumValue`
|
|
12
|
-
- **Output**: `category` (enum value) - use `runIf` with `enumValue: "<CategoryName>"` to route
|
|
13
|
-
- **DO NOT** use `category_<Name>` format - use `output: "category"` compared to `enumValue`
|
|
14
|
-
- Example categories: `[Password_Reset, Software_Issue, Account_Access, Fallback]`
|
|
15
|
-
|
|
16
|
-
#### Graphing Instructions
|
|
17
|
-
- Connect `chat_conversation` to the categorizer's `conversation` input (NOT `user_query`)
|
|
18
|
-
- Each category needs a downstream node with `runIf` comparing `category` to `enumValue`
|
|
19
|
-
- Example runIf structure:
|
|
20
|
-
```json
|
|
21
|
-
{
|
|
22
|
-
"runIf": {
|
|
23
|
-
"lhs": {"actionOutput": {"actionName": "chat_categorizer0", "output": "category"}},
|
|
24
|
-
"operator": 1,
|
|
25
|
-
"rhs": {"inline": {"enumValue": "Password_Reset"}}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Type Compatibility
|
|
31
|
-
- **CHAT_CONVERSATION**: Only compatible with `chat_categorizer.conversation` input
|
|
32
|
-
- **TEXT_WITH_SOURCES**: Used by most other agents (search, respond, call_llm)
|
|
33
|
-
- **SEARCH_RESULT**: Only compatible with `respond_with_sources.search_results` or `named_inputs`
|
|
34
|
-
|
|
35
|
-
#### Common Type Conversions
|
|
36
|
-
- ✅ `trigger.user_query → search.query` (TEXT_WITH_SOURCES → TEXT_WITH_SOURCES)
|
|
37
|
-
- ❌ `trigger.chat_conversation → search.query` (CHAT_CONVERSATION ≠ TEXT_WITH_SOURCES)
|
|
38
|
-
- ✅ `search.search_results → respond_with_sources.search_results` (compatible)
|
|
39
|
-
- ✅ `search.search_results → call_llm.named_inputs_*` (ANY accepts everything)
|
|
40
|
-
- **Use `conversation_to_search_query`** to convert CHAT_CONVERSATION → TEXT_WITH_SOURCES
|
|
41
|
-
|
|
42
|
-
### Conversation Summarizer (conversation_to_search_query)
|
|
43
|
-
- Converts conversation history to a condensed search query
|
|
44
|
-
- **When to use**:
|
|
45
|
-
- Before search nodes when you have `chat_conversation` but need `TEXT_WITH_SOURCES`
|
|
46
|
-
- For managing long conversation context windows (LLM token limits)
|
|
47
|
-
- **When NOT to use**: When `trigger.user_query` is sufficient for simple queries
|
|
48
|
-
|
|
49
|
-
### Combine Search Results
|
|
50
|
-
- Combines and weights search results from multiple sources into a unified list
|
|
51
|
-
- Handles both segment-level and chunk-level results while preserving document relationships
|
|
52
|
-
- **IMPORTANT**: Avoid using this agent unless necessary. Use alternatives:
|
|
53
|
-
- **Rerank Search Results** (`combine_and_rerank_search_results`): Intelligently combines with relevance ranking and max limit
|
|
54
|
-
- **Respond** (`call_llm`): Allows adding any number of search results via named_inputs with prompt-based ranking control
|
|
55
|
-
|
|
56
|
-
### Named Inputs (for call_llm, general_hitl)
|
|
57
|
-
- When connecting to `named_inputs`, use the suffix pattern: `named_inputs_<descriptive_name>`
|
|
58
|
-
- Replace spaces with underscores in the name
|
|
59
|
-
- Examples:
|
|
60
|
-
- `named_inputs_External_Tool_Results` for external action results
|
|
61
|
-
- `named_inputs_Web_Search_Data` for web search results
|
|
62
|
-
- `named_inputs_Financial_Analysis` for market research data
|
|
63
|
-
- Each named input will be labeled with the descriptive name in the workflow UI
|
|
64
|
-
- The planner should specify descriptive names like: "Connect to named_inputs as 'External Tool Results'"
|
|
65
|
-
- The grapher will convert this to: `target_input: "named_inputs_External_Tool_Results"`
|
|
66
|
-
- **Accepts ANY type**: Use named_inputs when you need to pass SEARCH_RESULT or other types to call_llm
|
|
67
|
-
|
|
68
|
-
### Human Collaboration (general_hitl)
|
|
69
|
-
|
|
70
|
-
#### Planning Instructions
|
|
71
|
-
- Human Collaboration is a special type of categorizer with two fixed categories: "HITL Success" and "HITL Failure" with no fallback categories
|
|
72
|
-
- Use it to pause workflow execution for human input, verification, or decision-making
|
|
73
|
-
- Always plan for both success and failure paths after Human Collaboration
|
|
74
|
-
- **Success criteria**: Define what makes HITL succeed (e.g., "The user approves the output", "The user is happy with the result")
|
|
75
|
-
- **Failure criteria**: Define what makes HITL fail (e.g., "The user wants to restart the workflow", "The user rejects the data")
|
|
76
|
-
- **CRITICAL**: Use HITL for ANY action with external side effects (create ticket, send email, update records)
|
|
77
|
-
|
|
78
|
-
#### Graphing Instructions
|
|
79
|
-
- Human Collaboration (general_hitl) outputs follow a special pattern:
|
|
80
|
-
- Success path: `hitl_status_HITL Success`
|
|
81
|
-
- Failure path: `hitl_status_HITL Failure`
|
|
82
|
-
- Connect these outputs to the `trigger_when` input of subsequent actions
|
|
83
|
-
- **IMPORTANT**: Use exact output names with underscores replaced by spaces in the suffix:
|
|
84
|
-
- `source_output: "hitl_status_HITL Success"` (with space between HITL and Success)
|
|
85
|
-
- `source_output: "hitl_status_HITL Failure"` (with space between HITL and Failure)
|
|
86
|
-
- Each Human Collaboration node MUST have at least one outgoing edge
|
|
87
|
-
- **Both paths must lead to valid response nodes and terminate at WORKFLOW_OUTPUT**
|
|
88
|
-
- Example connection:
|
|
89
|
-
```json
|
|
90
|
-
{
|
|
91
|
-
"source_node_id": "general_hitl0r146c",
|
|
92
|
-
"source_output": "hitl_status_HITL Success",
|
|
93
|
-
"target_input": "trigger_when"
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### External Tool Caller (external_action_caller)
|
|
98
|
-
- Calls external APIs/tools (ServiceNow, Salesforce, Workday, etc.)
|
|
99
|
-
- **CRITICAL**: Check `chat_conversation` for existing records before creating new ones to avoid duplicates on follow-up messages
|
|
100
|
-
- **Always use HITL before** actions with external side effects (create, update, delete, send)
|
|
101
|
-
- Accepts both `query` (TEXT_WITH_SOURCES) and optional `conversation` (CHAT_CONVERSATION) inputs
|
|
102
|
-
|
|
103
|
-
### Respond with Sources (respond_with_sources)
|
|
104
|
-
- Generates response grounded in search results with citations
|
|
105
|
-
- **Enable `use_citation_based_filtering`** for trust and verifiability
|
|
106
|
-
- **Implement confidence thresholds** for quality control - abstain when uncertain
|
|
107
|
-
- Accepts `query` (TEXT_WITH_SOURCES) and `search_results` (SEARCH_RESULT)
|
|
108
|
-
|
|
109
|
-
### WORKFLOW_OUTPUT Mapping
|
|
110
|
-
- **ALL paths must terminate at WORKFLOW_OUTPUT**
|
|
111
|
-
- Every response node (call_llm, respond_with_sources, fixed_response, etc.) needs an edge to WORKFLOW_OUTPUT
|
|
112
|
-
- Missing WORKFLOW_OUTPUT mapping = responses don't reach the user
|
|
113
|
-
- Example: `respond_market.response_with_sources → WORKFLOW_OUTPUT`
|
|
114
|
-
|
|
115
|
-
### Common Mistakes to Avoid
|
|
116
|
-
1. **Missing Fallback category**: Workflow validation fails, unhandled intents crash
|
|
117
|
-
2. **Missing HITL on sensitive actions**: Unintended actions with external side effects
|
|
118
|
-
3. **Creating duplicate records**: Always check chat_conversation before creating new records
|
|
119
|
-
4. **Type mismatches**: Use conversation_to_search_query when needed
|
|
120
|
-
5. **Vague agent instructions**: Be specific about tone, format, and boundaries
|
|
121
|
-
6. **Not mapping to WORKFLOW_OUTPUT**: Responses won't reach the user
|
|
122
|
-
7. **Not citing sources**: Enable use_citation_based_filtering for trust
|
|
123
|
-
8. **Ignoring confidence scores**: Abstain when uncertain rather than guessing
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
## General Instructions
|
|
128
|
-
|
|
129
|
-
### Validator System Overview
|
|
130
|
-
Your generated workflows will be processed by a validator system that includes:
|
|
131
|
-
- TypeValidator: Strictly enforces type compatibility between connected nodes
|
|
132
|
-
- WorkflowGenerator: Converts valid graphs to workflow definitions
|
|
133
|
-
- InputProcessor: Handles complex input processing and multibinding logic
|
|
134
|
-
- Categorizer validation: Ensures categorizers have proper outgoing edges
|
|
135
|
-
|
|
136
|
-
### Workflow Construction Rules
|
|
137
|
-
|
|
138
|
-
#### 1. Structure Analysis
|
|
139
|
-
- Extract the workflow structure from the natural language description
|
|
140
|
-
- Identify the type of interface: dashboard (document_trigger) or chatbot (chat_trigger)
|
|
141
|
-
|
|
142
|
-
#### 2. Node Mapping
|
|
143
|
-
- Map each workflow step to appropriate nodes from the available_nodes list
|
|
144
|
-
- You can use multiple instances of the same node if needed
|
|
145
|
-
- Always include at least 3 nodes in total
|
|
146
|
-
- Assign each node a unique ID, with node name as prefix (except trigger nodes)
|
|
147
|
-
|
|
148
|
-
#### 3. Edge Creation and Type Validation
|
|
149
|
-
- INPUT AND OUTPUT `wellKnownType` MUST MATCH when creating edges - validator will reject mismatches
|
|
150
|
-
- List Level Validation: The source output's `listLevel` MUST be less than or equal to the target input's `listLevel`
|
|
151
|
-
- If source listLevel equals target listLevel: only ONE edge can be created to that input
|
|
152
|
-
- If source listLevel is less than target listLevel: multiple edges can be created from different sources
|
|
153
|
-
|
|
154
|
-
#### 4. Categorizer Validation Rules
|
|
155
|
-
- **CRITICAL**: If a node has output `category` (such as chat_categorizer, text_categorizer, document_categorizer), it MUST have handler nodes with runIf conditions
|
|
156
|
-
- The runIf format MUST BE: `output: "category"` compared to `enumValue: "<CategoryName>"`
|
|
157
|
-
- Example: `runIf: { lhs: { actionOutput: { output: "category" } }, operator: 1, rhs: { inline: { enumValue: "Support" } } }`
|
|
158
|
-
- **DO NOT use `category_<Name>` format** - the output is always just `"category"`, compared against the enum value
|
|
159
|
-
- Always add a Fallback category handler
|
|
160
|
-
- **You MUST create a handler with runIf for each category or routing will fail**
|
|
161
|
-
|
|
162
|
-
#### 5. WELL_KNOWN_TYPE_ANY Rules
|
|
163
|
-
- Inputs with `wellKnownType: "WELL_KNOWN_TYPE_ANY"` accept ANY output type
|
|
164
|
-
- Common in `named_inputs` fields (call_llm, general_hitl actions)
|
|
165
|
-
- Type validation is bypassed for WELL_KNOWN_TYPE_ANY inputs - any source can connect
|
|
166
|
-
- For named_inputs specifically:
|
|
167
|
-
- Use suffix pattern: `"target_input": "named_inputs_<descriptive_name>"`
|
|
168
|
-
- Replace spaces with underscores in the name
|
|
169
|
-
- Example: `"named_inputs_External_Tool_Results"`, `"named_inputs_Web_Search_Data"`
|
|
170
|
-
- The validator extracts the name and creates namedBinding structures
|
|
171
|
-
|
|
172
|
-
#### 6. Document Trigger Specific Rules
|
|
173
|
-
- When the initial node is "document_trigger", only use document_metasearch or file_search if additional sources are needed
|
|
174
|
-
- When the initial node is "document_trigger", each output is shown as a column to the user, so make sure to think about what columns user likely wants to see and create nodes and output edges separately
|
|
175
|
-
- The number of columns are equal to the number of outputs
|
|
176
|
-
|
|
177
|
-
#### 7. Chat Trigger Specific Rules
|
|
178
|
-
- When the initial node is "chat_trigger", the output is a chat conversation returned to the user
|
|
179
|
-
- Every incoming edge to WORKFLOW_OUTPUT node is being shown to the user
|
|
180
|
-
- Make sure to create an edge for each output that the user should see
|
|
181
|
-
|
|
182
|
-
#### 8. Special Requirements
|
|
183
|
-
- Always start with either document_trigger or chat_trigger node
|
|
184
|
-
- Always end with WORKFLOW_OUTPUT node - all user-visible outputs must connect here
|
|
185
|
-
- Include `is_document` property based on the starting trigger type
|
|
186
|
-
|
|
187
|
-
#### 9. Critical Validation Rules
|
|
188
|
-
- Follow the exact workflow structure described in the plan
|
|
189
|
-
- Use only nodes from the available_nodes list
|
|
190
|
-
- Ensure perfect input/output type compatibility for all edges
|
|
191
|
-
- Generate valid, parseable output (JSON for grapher, markdown for planner)
|
|
192
|
-
|
|
193
|
-
### JSON Graph Structure
|
|
194
|
-
The final graph must follow this structure:
|
|
195
|
-
```json
|
|
196
|
-
{
|
|
197
|
-
"user_query": "description of the workflow",
|
|
198
|
-
"is_document": true/false,
|
|
199
|
-
"graph": {
|
|
200
|
-
"node_id": {
|
|
201
|
-
"action_name": "action_name_from_available_nodes",
|
|
202
|
-
"display_name": "Human readable display name",
|
|
203
|
-
"incoming_edges": [
|
|
204
|
-
{
|
|
205
|
-
"source_node_id": "source_node_id",
|
|
206
|
-
"source_output": "output_name_from_source_node",
|
|
207
|
-
"target_input": "input_name_for_this_node"
|
|
208
|
-
}
|
|
209
|
-
]
|
|
210
|
-
},
|
|
211
|
-
"WORKFLOW_OUTPUT": {
|
|
212
|
-
"action_name": "WorkflowOutputSink",
|
|
213
|
-
"display_name": "Workflow Output",
|
|
214
|
-
"incoming_edges": [
|
|
215
|
-
{
|
|
216
|
-
"source_node_id": "node_id",
|
|
217
|
-
"source_output": "output_name",
|
|
218
|
-
"target_input": "node_id.output_name"
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
```
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# {Persona Name}
|
|
2
|
-
|
|
3
|
-
**Type**: Chat AI
|
|
4
|
-
**Created**: {Date}
|
|
5
|
-
**Version**: 1.0
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
{Brief description of what this Chat AI Employee does}
|
|
10
|
-
|
|
11
|
-
## Deployment Steps
|
|
12
|
-
|
|
13
|
-
### Step 1: Create Workflow in Auto Builder
|
|
14
|
-
|
|
15
|
-
1. Go to [Ema Auto Builder](https://builder.ema.co/)
|
|
16
|
-
2. Create new AI Employee → Select **Chat AI**
|
|
17
|
-
3. Copy contents of `workflow-prompt.md` into the prompt field
|
|
18
|
-
4. Click "Generate Workflow"
|
|
19
|
-
5. Review generated nodes and verify:
|
|
20
|
-
- All categorizers have edges for every category
|
|
21
|
-
- Search nodes connect to respond nodes correctly
|
|
22
|
-
- Fallback paths are present
|
|
23
|
-
|
|
24
|
-
### Step 2: Configure Chat Settings
|
|
25
|
-
|
|
26
|
-
1. Navigate to "Chat Settings" section
|
|
27
|
-
2. Apply settings from `persona-config.json`:
|
|
28
|
-
|
|
29
|
-
| Field | Source |
|
|
30
|
-
|-------|--------|
|
|
31
|
-
| Name | `chatbotSdkConfig.name` |
|
|
32
|
-
| Theme Color | `chatbotSdkConfig.theme.primaryColor` |
|
|
33
|
-
| Logo | `chatbotSdkConfig.logo` |
|
|
34
|
-
| Allowed Domains | `chatbotSdkConfig.allowedDomains` |
|
|
35
|
-
|
|
36
|
-
### Step 3: Configure Knowledge Base
|
|
37
|
-
|
|
38
|
-
1. Navigate to "Knowledge Base" section
|
|
39
|
-
2. Upload documents from `docs/` folder
|
|
40
|
-
3. Configure tags from `persona-config.json`:
|
|
41
|
-
- Tag Types: `fileTagging.tagTypes`
|
|
42
|
-
4. Enable chunking: `fileUpload.useChunking`
|
|
43
|
-
|
|
44
|
-
### Step 4: Configure Feedback
|
|
45
|
-
|
|
46
|
-
1. Navigate to "Feedback" section
|
|
47
|
-
2. Apply settings:
|
|
48
|
-
- Question: `feedbackMessage.message.question`
|
|
49
|
-
- Frequency: `feedbackMessage.feedbackFrequency`
|
|
50
|
-
|
|
51
|
-
### Step 5: Deploy Widget
|
|
52
|
-
|
|
53
|
-
1. Get embed code from "Deploy" section
|
|
54
|
-
2. Add to your website:
|
|
55
|
-
|
|
56
|
-
```html
|
|
57
|
-
<script src="https://widget.ema.co/chat/{persona-id}.js"></script>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Step 6: Test
|
|
61
|
-
|
|
62
|
-
1. **Preview Mode**: Use the built-in chat preview
|
|
63
|
-
2. **Test Scenarios**:
|
|
64
|
-
- Test knowledge base queries
|
|
65
|
-
- Test each category branch
|
|
66
|
-
- Test fallback handling
|
|
67
|
-
- Test source citations
|
|
68
|
-
3. **Edge Cases**:
|
|
69
|
-
- Test with off-topic queries
|
|
70
|
-
- Test with multi-turn conversations
|
|
71
|
-
- Test with complex questions
|
|
72
|
-
|
|
73
|
-
## Files
|
|
74
|
-
|
|
75
|
-
| File | Description |
|
|
76
|
-
|------|-------------|
|
|
77
|
-
| `workflow-prompt.md` | Auto Builder prompt with safeguards |
|
|
78
|
-
| `persona-config.json` | Chat AI configuration |
|
|
79
|
-
| `proto-config.json` | Full API-deployable config |
|
|
80
|
-
| `docs/` | Knowledge base documents |
|
|
81
|
-
|
|
82
|
-
## Testing Checklist
|
|
83
|
-
|
|
84
|
-
- [ ] Workflow generates without validation errors
|
|
85
|
-
- [ ] Knowledge search returns relevant results
|
|
86
|
-
- [ ] Source citations appear correctly
|
|
87
|
-
- [ ] All category paths work
|
|
88
|
-
- [ ] Fallback provides helpful response
|
|
89
|
-
- [ ] Widget loads on allowed domains
|
|
90
|
-
- [ ] Feedback collection works
|
|
91
|
-
|
|
92
|
-
## Maintenance
|
|
93
|
-
|
|
94
|
-
| Change Type | Action |
|
|
95
|
-
|-------------|--------|
|
|
96
|
-
| Workflow logic | Update `workflow-prompt.md`, re-generate |
|
|
97
|
-
| Chat settings | Update `persona-config.json`, apply in UI |
|
|
98
|
-
| Knowledge content | Update docs in `docs/`, re-upload |
|
|
99
|
-
| Allowed domains | Update `chatbotSdkConfig.allowedDomains` |
|
|
100
|
-
|
|
101
|
-
## Troubleshooting
|
|
102
|
-
|
|
103
|
-
### Widget doesn't load
|
|
104
|
-
|
|
105
|
-
- Check `allowedDomains` includes your domain
|
|
106
|
-
- Verify embed code is correct
|
|
107
|
-
- Check browser console for errors
|
|
108
|
-
|
|
109
|
-
### Poor search results
|
|
110
|
-
|
|
111
|
-
- Review document chunking settings
|
|
112
|
-
- Add more specific tags
|
|
113
|
-
- Improve document structure
|
|
114
|
-
|
|
115
|
-
### Missing source citations
|
|
116
|
-
|
|
117
|
-
- Ensure `disableSources: false`
|
|
118
|
-
- Verify documents have clear headings
|
|
119
|
-
- Check that search is returning results
|