@ema.co/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/LICENSE +21 -0
- package/README.md +321 -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 +4723 -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 +98 -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,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generation Schema
|
|
3
|
+
*
|
|
4
|
+
* Transforms AGENT_CATALOG into a compact format for workflow generation.
|
|
5
|
+
* This avoids the token waste of including full documentation in prompts.
|
|
6
|
+
*
|
|
7
|
+
* The auto-builder sends ~70K tokens of documentation per request.
|
|
8
|
+
* This schema reduces that to ~5K tokens of actionable constraints.
|
|
9
|
+
*/
|
|
10
|
+
import { AGENT_CATALOG } from "./knowledge.js";
|
|
11
|
+
import { INPUT_SOURCE_RULES } from "./validation-rules.js";
|
|
12
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
// Schema Generation
|
|
14
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
15
|
+
/**
|
|
16
|
+
* Build a compact agent lookup from the full catalog
|
|
17
|
+
*/
|
|
18
|
+
export function buildCompactAgents() {
|
|
19
|
+
const agents = {};
|
|
20
|
+
for (const agent of AGENT_CATALOG) {
|
|
21
|
+
const inputs = {};
|
|
22
|
+
for (const input of agent.inputs ?? []) {
|
|
23
|
+
inputs[input.name] = { type: input.type, required: input.required };
|
|
24
|
+
}
|
|
25
|
+
const outputs = {};
|
|
26
|
+
for (const output of agent.outputs ?? []) {
|
|
27
|
+
outputs[output.name] = output.type;
|
|
28
|
+
}
|
|
29
|
+
agents[agent.actionName] = {
|
|
30
|
+
name: agent.displayName,
|
|
31
|
+
category: agent.category,
|
|
32
|
+
inputs,
|
|
33
|
+
outputs,
|
|
34
|
+
constraints: agent.criticalRules,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return agents;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build type compatibility rules
|
|
41
|
+
*/
|
|
42
|
+
export function buildTypeRules() {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
sourceType: "WELL_KNOWN_TYPE_CHAT_CONVERSATION",
|
|
46
|
+
targetTypes: ["WELL_KNOWN_TYPE_CHAT_CONVERSATION", "WELL_KNOWN_TYPE_ANY"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
sourceType: "WELL_KNOWN_TYPE_TEXT_WITH_SOURCES",
|
|
50
|
+
targetTypes: ["WELL_KNOWN_TYPE_TEXT_WITH_SOURCES", "WELL_KNOWN_TYPE_ANY"],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
sourceType: "WELL_KNOWN_TYPE_SEARCH_RESULT",
|
|
54
|
+
targetTypes: ["WELL_KNOWN_TYPE_SEARCH_RESULT", "WELL_KNOWN_TYPE_ANY"],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
sourceType: "WELL_KNOWN_TYPE_DOCUMENT",
|
|
58
|
+
targetTypes: ["WELL_KNOWN_TYPE_DOCUMENT", "WELL_KNOWN_TYPE_ANY"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
sourceType: "WELL_KNOWN_TYPE_ENUM",
|
|
62
|
+
targetTypes: ["WELL_KNOWN_TYPE_ENUM", "WELL_KNOWN_TYPE_ANY"],
|
|
63
|
+
},
|
|
64
|
+
// ANY can connect to ANY
|
|
65
|
+
{
|
|
66
|
+
sourceType: "WELL_KNOWN_TYPE_ANY",
|
|
67
|
+
targetTypes: ["WELL_KNOWN_TYPE_ANY", "WELL_KNOWN_TYPE_TEXT_WITH_SOURCES", "WELL_KNOWN_TYPE_SEARCH_RESULT"],
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Build structural constraints for workflow validation
|
|
73
|
+
*/
|
|
74
|
+
export function buildConstraints() {
|
|
75
|
+
return {
|
|
76
|
+
categorizers: [
|
|
77
|
+
"MUST have at least one outgoing edge for each category",
|
|
78
|
+
"MUST include a Fallback category",
|
|
79
|
+
"Output format: category::<CategoryName>",
|
|
80
|
+
"Target input: trigger_when",
|
|
81
|
+
"Category outputs are ONLY for control flow - cannot connect to WORKFLOW_OUTPUT",
|
|
82
|
+
],
|
|
83
|
+
hitl: [
|
|
84
|
+
"MUST have both success and failure paths",
|
|
85
|
+
"Success path: source_output 'hitl_status_HITL Success' (note: space, not underscore)",
|
|
86
|
+
"Failure path: source_output 'hitl_status_HITL Failure' (note: space, not underscore)",
|
|
87
|
+
"Both paths must eventually reach WORKFLOW_OUTPUT",
|
|
88
|
+
"Unlike regular categorizers, NO Fallback category - only Success/Failure",
|
|
89
|
+
],
|
|
90
|
+
outputs: [
|
|
91
|
+
"All user-visible outputs MUST connect to WORKFLOW_OUTPUT",
|
|
92
|
+
"Format: target_input = '<node_id>.<output_name>'",
|
|
93
|
+
"Every workflow path must reach WORKFLOW_OUTPUT",
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate the complete compact schema for workflow generation
|
|
99
|
+
*/
|
|
100
|
+
export function generateSchema() {
|
|
101
|
+
return {
|
|
102
|
+
agents: buildCompactAgents(),
|
|
103
|
+
typeRules: buildTypeRules(),
|
|
104
|
+
inputRules: INPUT_SOURCE_RULES.map(rule => ({
|
|
105
|
+
action: rule.actionPattern,
|
|
106
|
+
recommended: rule.recommended,
|
|
107
|
+
avoid: rule.avoid,
|
|
108
|
+
severity: rule.severity,
|
|
109
|
+
})),
|
|
110
|
+
constraints: buildConstraints(),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generate a Markdown summary suitable for LLM prompts
|
|
115
|
+
* This is ~5K tokens vs ~70K for full documentation
|
|
116
|
+
*/
|
|
117
|
+
export function generateSchemaMarkdown() {
|
|
118
|
+
const schema = generateSchema();
|
|
119
|
+
let md = `# Workflow Generation Schema\n\n`;
|
|
120
|
+
// Agent summary table
|
|
121
|
+
md += `## Available Agents (${Object.keys(schema.agents).length})\n\n`;
|
|
122
|
+
md += `| Action | Category | Inputs | Outputs |\n`;
|
|
123
|
+
md += `|--------|----------|--------|--------|\n`;
|
|
124
|
+
for (const [actionName, agent] of Object.entries(schema.agents)) {
|
|
125
|
+
const inputs = Object.entries(agent.inputs)
|
|
126
|
+
.map(([name, { type, required }]) => `${name}${required ? "*" : ""}`)
|
|
127
|
+
.join(", ") || "-";
|
|
128
|
+
const outputs = Object.keys(agent.outputs).join(", ") || "-";
|
|
129
|
+
md += `| \`${actionName}\` | ${agent.category} | ${inputs} | ${outputs} |\n`;
|
|
130
|
+
}
|
|
131
|
+
// Type rules
|
|
132
|
+
md += `\n## Type Compatibility\n\n`;
|
|
133
|
+
for (const rule of schema.typeRules) {
|
|
134
|
+
const targets = rule.targetTypes.map(t => `\`${t}\``).join(", ");
|
|
135
|
+
md += `- \`${rule.sourceType}\` → ${targets}\n`;
|
|
136
|
+
}
|
|
137
|
+
// Input rules
|
|
138
|
+
md += `\n## Input Source Rules\n\n`;
|
|
139
|
+
md += `| Action | Recommended | Avoid | Severity |\n`;
|
|
140
|
+
md += `|--------|-------------|-------|----------|\n`;
|
|
141
|
+
for (const rule of schema.inputRules) {
|
|
142
|
+
const avoid = rule.avoid.length ? rule.avoid.join(", ") : "-";
|
|
143
|
+
md += `| \`${rule.action}\` | \`${rule.recommended}\` | ${avoid} | ${rule.severity} |\n`;
|
|
144
|
+
}
|
|
145
|
+
// Structural constraints
|
|
146
|
+
md += `\n## Structural Constraints\n\n`;
|
|
147
|
+
md += `### Categorizers\n`;
|
|
148
|
+
for (const c of schema.constraints.categorizers) {
|
|
149
|
+
md += `- ${c}\n`;
|
|
150
|
+
}
|
|
151
|
+
md += `\n### HITL (Human-in-the-Loop)\n`;
|
|
152
|
+
for (const c of schema.constraints.hitl) {
|
|
153
|
+
md += `- ${c}\n`;
|
|
154
|
+
}
|
|
155
|
+
md += `\n### Workflow Output\n`;
|
|
156
|
+
for (const c of schema.constraints.outputs) {
|
|
157
|
+
md += `- ${c}\n`;
|
|
158
|
+
}
|
|
159
|
+
return md;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get compact agent info for a specific action
|
|
163
|
+
*/
|
|
164
|
+
export function getAgentSchema(actionName) {
|
|
165
|
+
const schema = generateSchema();
|
|
166
|
+
return schema.agents[actionName];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Validate if a connection is type-compatible
|
|
170
|
+
*/
|
|
171
|
+
export function isTypeCompatible(sourceType, targetType) {
|
|
172
|
+
// ANY accepts anything
|
|
173
|
+
if (targetType === "WELL_KNOWN_TYPE_ANY")
|
|
174
|
+
return true;
|
|
175
|
+
// Same type is always compatible
|
|
176
|
+
if (sourceType === targetType)
|
|
177
|
+
return true;
|
|
178
|
+
// Check explicit rules
|
|
179
|
+
const schema = generateSchema();
|
|
180
|
+
const rule = schema.typeRules.find(r => r.sourceType === sourceType);
|
|
181
|
+
return rule?.targetTypes.includes(targetType) ?? false;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get recommended input source for an action
|
|
185
|
+
*/
|
|
186
|
+
export function getRecommendedInput(actionName) {
|
|
187
|
+
const rule = INPUT_SOURCE_RULES.find(r => actionName.toLowerCase().includes(r.actionPattern.toLowerCase()));
|
|
188
|
+
return rule?.recommended;
|
|
189
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ema Toolkit SDK
|
|
3
|
+
*
|
|
4
|
+
* Core library providing programmatic access to:
|
|
5
|
+
* - EmaClient: API client for Ema platform
|
|
6
|
+
* - SyncSDK: Persona synchronization across environments
|
|
7
|
+
* - Config: Configuration loading and validation
|
|
8
|
+
* - Models: TypeScript types for API entities
|
|
9
|
+
*/
|
|
10
|
+
// API Client
|
|
11
|
+
export { EmaClient, EmaApiError } from "./client.js";
|
|
12
|
+
// Sync SDK
|
|
13
|
+
export { SyncSDK, } from "./sync.js";
|
|
14
|
+
// Sync Options (hierarchical config from .ema.yaml)
|
|
15
|
+
export { loadSyncOptions, clearSyncOptionsCache, resolveSyncBehavior, getRoutingTargets, validateSyncOptions, } from "./sync-options.js";
|
|
16
|
+
export { SYNC_METADATA_KEY } from "./models.js";
|
|
17
|
+
export { loadConfig, loadConfigOptional, validateConfig, configToYaml, resolveBearerToken, getMasterEnv, getEnvByName } from "./config.js";
|
|
18
|
+
// State Store
|
|
19
|
+
export { StateStore } from "./state.js";
|
|
20
|
+
// Auto Builder Knowledge Base
|
|
21
|
+
export {
|
|
22
|
+
// Catalogs & References
|
|
23
|
+
AGENT_CATALOG, WIDGET_CATALOG, WORKFLOW_PATTERNS, QUALIFYING_QUESTIONS, PLATFORM_CONCEPTS, WORKFLOW_EXECUTION_MODEL, COMMON_MISTAKES, DEBUG_CHECKLIST, GUIDANCE_TOPICS, VOICE_PERSONA_TEMPLATE, PROJECT_TYPES,
|
|
24
|
+
// Helper Functions
|
|
25
|
+
getAgentsByCategory, getAgentByName, getWidgetsForPersonaType, checkTypeCompatibility, getQualifyingQuestionsByCategory, getRequiredQualifyingQuestions, getConceptByTerm, suggestAgentsForUseCase, validateWorkflowPrompt,
|
|
26
|
+
// Workflow Analysis Functions
|
|
27
|
+
parseWorkflowDef, detectWorkflowIssues, validateWorkflowConnections, analyzeWorkflow, suggestWorkflowFixes,
|
|
28
|
+
// Validation Rules (Single Source of Truth)
|
|
29
|
+
VALIDATION_INPUT_RULES, ANTI_PATTERNS, OPTIMIZATION_RULES, findInputSourceRule, findAntiPatternByIssueType, generateMarkdownDocumentation, exportRulesAsJSON, } from "./knowledge.js";
|
|
30
|
+
// Workflow Compiler (Template-driven workflow generation)
|
|
31
|
+
export {
|
|
32
|
+
// Core compiler
|
|
33
|
+
compileWorkflow,
|
|
34
|
+
// Settings builders
|
|
35
|
+
buildVoiceConfig, buildChatConfig, } from "./workflow-generator.js";
|
|
36
|
+
// Workflow Intent (Normalization layer)
|
|
37
|
+
export { parseInput, validateIntent, intentToSpec, detectInputType, parseNaturalLanguage, parsePartialSpec, } from "./workflow-intent.js";
|
|
38
|
+
// Generation Schema (Compact format for LLM-based generation)
|
|
39
|
+
export { generateSchema, generateSchemaMarkdown, buildCompactAgents, buildTypeRules, buildConstraints, getAgentSchema, isTypeCompatible, getRecommendedInput, } from "./generation-schema.js";
|