@ema.co/mcp-toolkit 2026.1.24 → 2026.1.26-3

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.

Files changed (81) hide show
  1. package/README.md +10 -2
  2. package/dist/mcp/handlers/action/index.js +3 -18
  3. package/dist/mcp/handlers/data/index.js +385 -41
  4. package/dist/mcp/handlers/data/templates.js +107 -0
  5. package/dist/mcp/handlers/deprecation.js +50 -0
  6. package/dist/mcp/handlers/env/index.js +8 -4
  7. package/dist/mcp/handlers/knowledge/index.js +44 -237
  8. package/dist/mcp/handlers/persona/create.js +5 -11
  9. package/dist/mcp/handlers/persona/index.js +5 -1
  10. package/dist/mcp/handlers/persona/version.js +234 -0
  11. package/dist/mcp/handlers/reference/index.js +101 -1
  12. package/dist/mcp/handlers/sync/index.js +3 -18
  13. package/dist/mcp/handlers/template/index.js +75 -10
  14. package/dist/mcp/handlers/workflow/analyze.js +171 -0
  15. package/dist/mcp/handlers/workflow/compare.js +70 -0
  16. package/dist/mcp/handlers/workflow/compile.js +39 -0
  17. package/dist/mcp/handlers/workflow/deploy.js +73 -0
  18. package/dist/mcp/handlers/workflow/generate.js +350 -0
  19. package/dist/mcp/handlers/workflow/index.js +136 -0
  20. package/dist/mcp/handlers/workflow/modify.js +456 -0
  21. package/dist/mcp/handlers/workflow/optimize.js +136 -0
  22. package/dist/mcp/handlers/workflow/types.js +4 -0
  23. package/dist/mcp/handlers/workflow/utils.js +132 -0
  24. package/dist/mcp/handlers-consolidated.js +62 -2691
  25. package/dist/mcp/prompts.js +13 -14
  26. package/dist/mcp/resources.js +55 -54
  27. package/dist/mcp/server.js +93 -124
  28. package/dist/mcp/{tools-v2.js → tools.js} +1 -1
  29. package/dist/mcp/workflow-operations.js +2 -2
  30. package/dist/sdk/client-adapter.js +267 -32
  31. package/dist/sdk/client.js +31 -15
  32. package/dist/sdk/ema-client.js +183 -0
  33. package/dist/sdk/generated/template-fallbacks.js +123 -0
  34. package/dist/sdk/guidance.js +65 -11
  35. package/dist/sdk/index.js +3 -1
  36. package/dist/sdk/knowledge.js +16 -86
  37. package/dist/sdk/workflow-intent.js +27 -0
  38. package/dist/sdk/workflow-transformer.js +0 -342
  39. package/docs/DEBUG-ANALYSIS-unused-category-type-mismatch.md +481 -0
  40. package/docs/TODO-fix-analyzer-and-modify.md +182 -0
  41. package/package.json +9 -4
  42. package/dist/mcp/tools-consolidated.js +0 -866
  43. package/dist/mcp/tools-legacy.js +0 -736
  44. package/docs/CODEBASE-ANALYSIS-2026-01-23.md +0 -936
  45. package/docs/CODEBASE-ANALYSIS-PRIORITIZED.md +0 -774
  46. package/docs/api-contracts.md +0 -216
  47. package/docs/auto-builder-analysis.md +0 -271
  48. package/docs/blog/mcp-tool-design-lessons.md +0 -309
  49. package/docs/data-architecture.md +0 -166
  50. package/docs/ema-auto-builder-guide.html +0 -394
  51. package/docs/lessons-learned.md +0 -209
  52. package/docs/llm-native-workflow-design.md +0 -252
  53. package/docs/local-generation.md +0 -508
  54. package/docs/mcp-flow-diagram.md +0 -135
  55. package/docs/migration/action-composition-migration.md +0 -270
  56. package/docs/naming-conventions.md +0 -278
  57. package/docs/proposals/HANDOFF-tool-restructure.md +0 -526
  58. package/docs/proposals/action-composition.md +0 -490
  59. package/docs/proposals/explicit-method-restructure.md +0 -328
  60. package/docs/proposals/mcp-tool-restructure-2026-01.md +0 -366
  61. package/docs/proposals/self-contained-guidance.md +0 -427
  62. package/docs/proto-sdk-generation.md +0 -242
  63. package/docs/release-impact.md +0 -102
  64. package/docs/release-process.md +0 -157
  65. package/docs/staging.RULE.md +0 -142
  66. package/docs/test-persona-creation.md +0 -196
  67. package/docs/tool-consolidation-v2.md +0 -225
  68. package/docs/tool-response-standards.md +0 -256
  69. package/resources/docs/getting-started.md +0 -97
  70. package/resources/templates/auto-builder-rules.md +0 -224
  71. package/resources/templates/chat-ai/README.md +0 -119
  72. package/resources/templates/chat-ai/persona-config.json +0 -111
  73. package/resources/templates/dashboard-ai/README.md +0 -156
  74. package/resources/templates/dashboard-ai/persona-config.json +0 -180
  75. package/resources/templates/demo-scenarios/README.md +0 -63
  76. package/resources/templates/demo-scenarios/test-published-package.md +0 -116
  77. package/resources/templates/document-gen-ai/README.md +0 -132
  78. package/resources/templates/document-gen-ai/persona-config.json +0 -316
  79. package/resources/templates/voice-ai/README.md +0 -123
  80. package/resources/templates/voice-ai/persona-config.json +0 -74
  81. package/resources/templates/voice-ai/workflow-prompt.md +0 -121
@@ -1,866 +0,0 @@
1
- /**
2
- * Consolidated MCP Tools for Ema
3
- *
4
- * Follows Unix CLI patterns:
5
- * - Single command with flags instead of separate get/list/create tools
6
- * - Consistent terminology: "persona" (not mixed "ai_employee")
7
- * - Mode flags for different operations on same resource
8
- *
9
- * ~45 tools → 9 commands:
10
- * 1. env - Environment listing
11
- * 2. persona - AI Employee management
12
- * 3. workflow - Workflow generation, analysis, deploy, optimize
13
- * 4. action - Actions/agents lookup
14
- * 5. template - Patterns, widgets, templates
15
- * 6. knowledge - Data sources & embedding
16
- * 7. reference - Platform concepts & guidance
17
- * 8. sync - Environment sync
18
- * 9. demo - Demo data utilities (RAG document generation)
19
- */
20
- // Helper to add env parameter to schema
21
- function withEnvParam(props, required = [], envNames = [], defaultEnv = "demo") {
22
- return {
23
- type: "object",
24
- properties: {
25
- ...props,
26
- env: {
27
- type: "string",
28
- description: `Target environment. Available: ${envNames.join(", ") || "demo, staging, dev"}. Default: ${defaultEnv}`,
29
- },
30
- },
31
- required,
32
- };
33
- }
34
- /**
35
- * Generate consolidated tool definitions
36
- */
37
- export function generateConsolidatedTools(envNames, defaultEnv) {
38
- const withEnv = (props, required = []) => withEnvParam(props, required, envNames, defaultEnv);
39
- return [
40
- // ═══════════════════════════════════════════════════════════════════════
41
- // 1. ENV - Environment listing (simplest tool)
42
- // ═══════════════════════════════════════════════════════════════════════
43
- {
44
- name: "env",
45
- description: "List available Ema environments and toolkit info. Returns environments (with default marker) and toolkit name/version.",
46
- inputSchema: { type: "object", properties: {}, required: [] },
47
- },
48
- // ═══════════════════════════════════════════════════════════════════════
49
- // 2. PERSONA - Unified AI Employee management (create, modify, analyze, list)
50
- // ═══════════════════════════════════════════════════════════════════════
51
- {
52
- name: "persona",
53
- description: `AI Employee management. Explicit mode required.
54
-
55
- ## Modes (explicit \`mode\` parameter required)
56
-
57
- | Mode | Purpose | Required Params |
58
- |------|---------|-----------------|
59
- | \`list\` | List all personas | - |
60
- | \`get\` | Get specific persona | \`id\` |
61
- | \`create\` | Create new persona | \`name\`, \`type\` or \`from\` |
62
- | \`update\` | Update config | \`id\`, \`proto_config\` |
63
- | \`clone\` | Clone persona | \`from\`, \`name\` |
64
- | \`compare\` | Compare two | \`id\`, \`compare_to\` |
65
- | \`sanitize\` | Sanitize PII | \`id\` |
66
- | \`analyze\` | Analyze issues | \`id\`, optional: \`fix\`, \`include\` |
67
- | \`templates\` | List templates | - |
68
-
69
- ## Examples
70
-
71
- \`\`\`
72
- // List & Get
73
- persona(mode="list")
74
- persona(mode="get", id="abc-123")
75
- persona(mode="get", id="abc-123", include_workflow=true)
76
-
77
- // Create from template
78
- persona(mode="create", from="Voice AI Starter", name="My SDR", input="qualifies leads", preview=false)
79
-
80
- // Create new (no template)
81
- persona(mode="create", name="My SDR", type="voice", input="qualifies leads", preview=false)
82
-
83
- // Update config (proto_config)
84
- persona(mode="update", id="abc-123", proto_config={widgets: [{name: "conversationSettings", conversationSettings: {...}}]})
85
-
86
- // Update workflow via LLM-native WorkflowSpec
87
- persona(mode="update", id="abc-123", workflow_spec={name: "...", nodes: [...], resultMappings: [...]})
88
-
89
- // Clone
90
- persona(mode="clone", from="source-id", name="My Copy", include_data=true)
91
-
92
- // Compare
93
- persona(mode="compare", id="abc-123", compare_to="def-456")
94
-
95
- // Analyze (returns workflow_spec + schema + issues)
96
- persona(mode="analyze", id="abc-123")
97
- persona(mode="analyze", id="abc-123", include=["workflow", "data"])
98
-
99
- // Workflow modification flow (Agent builds fixes, MCP deploys):
100
- // 1. Analyze to get workflow_spec + schema + issues
101
- // persona(mode="analyze", id="abc-123")
102
- // → returns {workflow_spec: {...}, schema: "...", issues: [...]}
103
- // 2. Agent reviews issues, asks user which to fix
104
- // 3. Agent modifies the spec (add nodes, change inputs, etc.)
105
- // 4. Deploy the agent-built spec
106
- // persona(mode="update", id="abc-123", workflow_spec=<agent_built_spec>)
107
- \`\`\`
108
-
109
- ## ⚠️ ASK BEFORE CREATING
110
-
111
- **Before creating a new AI Employee, ASK THE USER:**
112
- 1. What should it do? (purpose, intents, capabilities)
113
- 2. What type? (voice, chat, dashboard)
114
- 3. What name?
115
-
116
- ## Key Rules
117
-
118
- 1. **EXPLICIT MODE** - Always specify mode parameter
119
- 2. **ONE CALL** - Put everything in one call
120
- 3. **STOP after success** - Don't make follow-up "fix" calls
121
- 4. **preview=false** - Required to actually deploy`,
122
- inputSchema: withEnv({
123
- // === MODE (explicit, required) ===
124
- mode: {
125
- type: "string",
126
- enum: [
127
- "list", "get", "create", "update", "clone", "compare", "sanitize", "templates", "analyze", "intent",
128
- "version_create", "version_list", "version_get", "version_compare", "version_restore", "version_policy"
129
- ],
130
- description: "Operation mode. REQUIRED. If omitted, tool will ask for clarification.",
131
- },
132
- // === IDENTITY (for existing personas) ===
133
- id: {
134
- type: "string",
135
- description: "Persona ID (UUID) or exact name. Required for get/update/compare/sanitize."
136
- },
137
- identifier: {
138
- type: "string",
139
- deprecated: true,
140
- description: "DEPRECATED: use id.",
141
- },
142
- // === CREATE FROM BASE (unified: template or persona) ===
143
- from: {
144
- type: "string",
145
- description: "Base to create/clone from: template ID, persona ID, or name. Used with mode='create' or mode='clone'.",
146
- },
147
- include_data: {
148
- type: "boolean",
149
- description: "When cloning from persona: include knowledge files and dashboard rows. Default: true for persona, N/A for template.",
150
- },
151
- // === CREATE/MODIFY ===
152
- input: {
153
- type: "string",
154
- description: "Natural language description. For new: 'Voice AI for sales...'. For modify: 'add HITL before email'.",
155
- },
156
- type: {
157
- type: "string",
158
- enum: ["voice", "chat", "dashboard"],
159
- description: "AI Employee type. Required when creating without 'from'."
160
- },
161
- name: { type: "string", description: "REQUIRED for new: The actual persona name shown in Ema platform." },
162
- description: { type: "string", description: "Description of what it does." },
163
- preview: {
164
- type: "boolean",
165
- description: "Default: true (safe). Set false to deploy changes."
166
- },
167
- sanitize: { type: "boolean", description: "Sanitize/obfuscate PII and sensitive data (for demo environments)" },
168
- sanitize_examples: { type: "array", items: { type: "string" }, description: "Additional items to treat as sensitive (e.g., company names)" },
169
- // === ANALYZE ===
170
- fix: {
171
- type: "boolean",
172
- description: "DEPRECATED: Returns preview only. Agent should review issues and build workflow_spec fixes.",
173
- },
174
- include: {
175
- type: "array",
176
- items: { type: "string", enum: ["workflow", "config", "data", "issues", "connections", "fixes", "metrics"] },
177
- description: "What to include. For analyze: ['workflow','config','data']. For get: ['issues','connections','fixes','metrics'].",
178
- },
179
- include_workflow: { type: "boolean", description: "Include full workflow_def in response" },
180
- include_fingerprint: { type: "boolean", description: "Include config hash" },
181
- // === INTENT (qualification/refinement) ===
182
- previous_answers: {
183
- type: "object",
184
- additionalProperties: { type: "string" },
185
- description: "For mode='intent': answers to previous qualification questions (iterative flow).",
186
- },
187
- iteration: {
188
- type: "integer",
189
- minimum: 1,
190
- description: "For mode='intent': iteration number (1 = first call, 2+ = after providing answers).",
191
- },
192
- max_complexity: {
193
- type: "string",
194
- enum: ["simple", "moderate", "complex"],
195
- description: "For mode='intent': cap complexity level for gradual rollout.",
196
- },
197
- // === LIST/SEARCH ===
198
- all: { type: "boolean", description: "List all personas" },
199
- query: { type: "string", description: "Search by name (partial match)" },
200
- status: { type: "string", description: "Filter: 'active', 'inactive', 'draft'" },
201
- trigger_type: { type: "string", description: "Filter: 'voice', 'chat', 'dashboard'" },
202
- limit: { type: "number", description: "Max results (default: 50)" },
203
- // === COMPARE ===
204
- compare_to: { type: "string", description: "Second persona ID for comparison" },
205
- compare_env: { type: "string", description: "Environment of compare_to persona" },
206
- // === ADVANCED/OVERRIDE ===
207
- proto_config: {
208
- type: "object",
209
- description: "Override voice/chat settings. Usually auto-generated from input."
210
- },
211
- workflow: {
212
- type: "object",
213
- description: "Direct workflow_def JSON (advanced). Usually auto-generated."
214
- },
215
- workflow_spec: {
216
- type: "object",
217
- description: "LLM-native WorkflowSpec. SDK compiles to workflow_def. Use with mode='update'. Get schema from mode='analyze'."
218
- },
219
- include_spec: {
220
- type: "boolean",
221
- description: "For mode='analyze': include decompiled workflow_spec + schema in response. Default: true."
222
- },
223
- workflow_def: {
224
- type: "object",
225
- description: "Alias for workflow (backwards compatibility)."
226
- },
227
- enabled: { type: "boolean", description: "Enable/disable persona" },
228
- // === DEPRECATED (use 'from' instead) ===
229
- template_id: { type: "string", description: "DEPRECATED: use from. Specific template ID." },
230
- clone_from: { type: "string", description: "DEPRECATED: use from. Clone from existing persona ID." },
231
- clone_data: { type: "boolean", description: "DEPRECATED: use include_data." },
232
- // === TEMPLATES ===
233
- templates: { type: "boolean", description: "List available templates" },
234
- // === VERSION MANAGEMENT ===
235
- // Note: mode enum is defined above, version_* modes are included there
236
- version: { type: "string", description: "Version identifier (e.g., 'v3', 'latest')" },
237
- v1: { type: "string", description: "First version for comparison" },
238
- v2: { type: "string", description: "Second version for comparison" },
239
- message: { type: "string", description: "Version message/description" },
240
- auto_on_deploy: { type: "boolean", description: "Auto-create version on deploy" },
241
- auto_on_sync: { type: "boolean", description: "Auto-create version on sync" },
242
- max_versions: { type: "number", description: "Max versions to keep" },
243
- }),
244
- },
245
- // ═══════════════════════════════════════════════════════════════════════
246
- // 3. WORKFLOW - DEPRECATED: Use persona() instead
247
- // ═══════════════════════════════════════════════════════════════════════
248
- {
249
- name: "workflow",
250
- description: `⚠️ DEPRECATED: Use \`persona()\` instead. This tool routes to persona.
251
-
252
- ## Migration Guide
253
-
254
- OLD (deprecated):
255
- workflow(input="...", type="voice", name="Bot", preview=false)
256
- workflow(persona_id="abc", input="add HITL")
257
-
258
- NEW (use this):
259
- persona(input="...", type="voice", name="Bot", preview=false)
260
- persona(id="abc", input="add HITL")
261
-
262
- The \`persona\` tool now handles everything: create, modify, analyze, list.
263
- This \`workflow\` tool still works but shows a deprecation warning.`,
264
- inputSchema: withEnv({
265
- // === REQUIRED for creating/modifying ===
266
- input: {
267
- type: "string",
268
- description: "Natural language description of what you want. Examples: 'Voice AI for sales development' (new) or 'add HITL before emails' (modify existing)",
269
- },
270
- // === REQUIRED for modifying existing ===
271
- persona_id: {
272
- type: "string",
273
- description: "ID of existing persona to modify or analyze. Omit for creating new personas."
274
- },
275
- // === REQUIRED for new Voice/Chat/Dashboard ===
276
- type: {
277
- type: "string",
278
- enum: ["voice", "chat", "dashboard"],
279
- description: "REQUIRED for new personas. Type of AI Employee to create."
280
- },
281
- // === Control deployment ===
282
- preview: {
283
- type: "boolean",
284
- description: "Default: true (safe). Set false to deploy changes to Ema platform."
285
- },
286
- // === For new personas (greenfield with preview=false) ===
287
- name: {
288
- type: "string",
289
- description: "Name for the new persona. Required when creating with preview=false."
290
- },
291
- description: {
292
- type: "string",
293
- description: "Description of what the persona does."
294
- },
295
- // === Voice/Chat settings (auto-generated, but can override) ===
296
- proto_config: {
297
- type: "object",
298
- description: "Voice/chat settings. Auto-generated from input. Override specific settings like welcomeMessage, identityAndPurpose."
299
- },
300
- // === For analysis/optimization ===
301
- optimize: {
302
- type: "boolean",
303
- description: "DEPRECATED: Returns suggestions only. Agent should build workflow_spec fixes.",
304
- },
305
- include: {
306
- type: "array",
307
- items: { type: "string", enum: ["issues", "connections", "fixes", "metrics"] },
308
- description: "What to include in analysis output.",
309
- },
310
- // === Advanced/Legacy ===
311
- workflow_def: {
312
- type: "object",
313
- description: "Direct workflow JSON (advanced). Usually auto-generated from input."
314
- },
315
- compare_to: { type: "string", description: "Second persona ID for comparison" },
316
- mode: {
317
- type: "string",
318
- enum: ["generate", "extend", "optimize", "analyze", "compare", "compile"],
319
- description: "Usually auto-detected. Only specify for compile mode."
320
- },
321
- nodes: { type: "array", description: "For compile mode: node definitions" },
322
- result_mappings: { type: "array", description: "For compile mode: output mappings" },
323
- }),
324
- },
325
- // ═══════════════════════════════════════════════════════════════════════
326
- // 4. ACTION - Actions/agents lookup (API + reference docs)
327
- // ═══════════════════════════════════════════════════════════════════════
328
- {
329
- name: "action",
330
- description: `Unified action/agent lookup. Gets live API data AND reference docs.
331
-
332
- **Get single**:
333
- action(id="chat_categorizer")
334
- action(id="abc-123-uuid")
335
- action(id="search", include_docs=true)
336
-
337
- **List/Search**:
338
- action(all=true)
339
- action(category="routing")
340
- action(query="search")
341
- action(persona_id="abc") # Actions in workflow
342
-
343
- **Suggest for use case**:
344
- action(suggest="IT helpdesk with ticket creation")
345
-
346
- **Categories**:
347
- action(categories=true)`,
348
- inputSchema: withEnv({
349
- // ID (or name)
350
- id: {
351
- type: "string",
352
- description: "Action ID or name (e.g., 'chat_categorizer')"
353
- },
354
- // Deprecated alias (backwards compatibility)
355
- identifier: {
356
- type: "string",
357
- deprecated: true,
358
- description: "DEPRECATED: use id. Action ID or name (e.g., 'chat_categorizer')",
359
- },
360
- // List/Search flags
361
- all: { type: "boolean", description: "List all available actions" },
362
- query: { type: "string", description: "Search by name" },
363
- category: { type: "string", description: "Filter by category" },
364
- persona_id: { type: "string", description: "List actions in this workflow" },
365
- enabled: { type: "boolean", description: "Filter by enabled status" },
366
- limit: { type: "number", description: "Max results" },
367
- // Include flags
368
- include_docs: { type: "boolean", description: "Include full documentation" },
369
- // Suggest mode
370
- suggest: { type: "string", description: "Get recommendations for use case" },
371
- // List categories
372
- categories: { type: "boolean", description: "List action categories" },
373
- }),
374
- },
375
- // ═══════════════════════════════════════════════════════════════════════
376
- // 5. TEMPLATE - Patterns, widgets, persona templates
377
- // ═══════════════════════════════════════════════════════════════════════
378
- {
379
- name: "template",
380
- description: `Get qualifying questions and reference patterns.
381
-
382
- ## 🎯 PRIMARY USE: Get Questions to Ask User
383
-
384
- **Before creating an AI Employee, call this to get what to ask:**
385
- template(questions=true) // All qualifying questions
386
- template(questions=true, category="Voice") // Voice-specific questions
387
-
388
- Returns structured questions about: type, intents, data sources, actions, approvals, etc.
389
- Ask the user these questions, then put answers into ONE workflow() call.
390
-
391
- ## Reference (understand options, not for manual building)
392
-
393
- template(pattern="intent-routing") // See pattern structure
394
- template(patterns=true) // List available patterns
395
- template(widgets="voice") // Widget reference
396
-
397
- ⚠️ Do NOT copy/paste configs from these - MCP generates them internally.`,
398
- inputSchema: {
399
- type: "object",
400
- properties: {
401
- // Workflow patterns
402
- pattern: {
403
- type: "string",
404
- enum: ["simple-kb-search", "intent-routing", "multi-source-search", "tool-calling", "hitl-approval", "document-processing", "guardrails-pattern"],
405
- description: "Get specific workflow pattern"
406
- },
407
- patterns: { type: "boolean", description: "List all workflow patterns" },
408
- // Widget reference
409
- widgets: {
410
- type: "string",
411
- enum: ["voice", "chat", "dashboard"],
412
- description: "Get widget reference for persona type"
413
- },
414
- // Persona config template
415
- config: {
416
- type: "string",
417
- enum: ["voice", "chat", "dashboard"],
418
- description: "Get config template (voice settings, etc.)"
419
- },
420
- // Qualifying questions
421
- questions: { type: "boolean", description: "Get qualifying questions" },
422
- category: {
423
- type: "string",
424
- enum: ["AI Type", "Intent", "Data", "Actions", "Validation", "Output", "Voice", "Guardrails"],
425
- description: "Filter questions by category"
426
- },
427
- required_only: { type: "boolean", description: "Only required questions" },
428
- // Filter
429
- type: {
430
- type: "string",
431
- enum: ["voice", "chat", "dashboard"],
432
- description: "Filter patterns by persona type"
433
- },
434
- },
435
- required: [],
436
- },
437
- },
438
- // ═══════════════════════════════════════════════════════════════════════
439
- // 6. KNOWLEDGE - DEPRECATED: Use data() instead
440
- // ═══════════════════════════════════════════════════════════════════════
441
- {
442
- name: "knowledge",
443
- description: `DEPRECATED: Use \`data()\` instead. This tool routes to data internally.
444
-
445
- ## Migration Guide
446
-
447
- | OLD (deprecated) | NEW |
448
- |------------------|-----|
449
- | knowledge(persona_id="abc", mode="list") | data(persona_id="abc", mode="list") |
450
- | knowledge(persona_id="abc", mode="upload", file="...") | data(persona_id="abc", mode="upload", file="...") |
451
- | knowledge(persona_id="abc", mode="delete", file_id="...") | data(persona_id="abc", mode="delete", file_id="...") |
452
- | knowledge(persona_id="abc", mode="status") | data(persona_id="abc", mode="embedding") |
453
- | knowledge(persona_id="abc", mode="toggle", enabled=true) | data(persona_id="abc", mode="embedding", enabled=true) |
454
-
455
- The \`data\` tool now also supports generation:
456
- data(persona_id="abc", mode="generate", input="...")
457
- data(persona_id="abc", mode="generate", from="customer", count=5)
458
-
459
- This tool still works but shows a deprecation warning.`,
460
- inputSchema: withEnv({
461
- persona_id: { type: "string", description: "AI Employee ID (required)" },
462
- mode: {
463
- type: "string",
464
- enum: ["list", "aggregates", "upload", "delete", "status", "toggle", "attach", "dashboard_rows", "dashboard_clone"],
465
- description: "Operation. Default: 'list'"
466
- },
467
- // List flags
468
- page: { type: "number", description: "Page number (default: 1)" },
469
- limit: { type: "number", description: "Items per page (default: 50)" },
470
- widget_name: { type: "string", description: "Widget name (default: 'fileUpload')" },
471
- // Upload flags
472
- file: { type: "string", description: "File path for upload" },
473
- tags: { type: "string", description: "Tags for uploaded file" },
474
- // Delete flags
475
- file_id: { type: "string", description: "File ID to delete" },
476
- // Toggle flags
477
- enabled: { type: "boolean", description: "Enable/disable embedding" },
478
- // Attach flags
479
- node_name: { type: "string", description: "Workflow node name to attach data source to (e.g., 'knowledge_search_1')" },
480
- // Dashboard clone flags
481
- source_persona_id: { type: "string", description: "Source persona ID for dashboard clone" },
482
- sanitize: { type: "boolean", description: "Sanitize/obfuscate data during clone" },
483
- sanitize_examples: { type: "array", items: { type: "string" }, description: "Additional sensitive items to sanitize" },
484
- }, ["persona_id"]),
485
- },
486
- // ═══════════════════════════════════════════════════════════════════════
487
- // 7. REFERENCE - All reference info (envs, actions, templates, patterns, concepts, guidance)
488
- // ═══════════════════════════════════════════════════════════════════════
489
- {
490
- name: "reference",
491
- description: `All reference information: environments, actions, templates, patterns, concepts, guidance.
492
-
493
- **Environments**:
494
- reference(type="envs")
495
-
496
- **Actions** (workflow building blocks):
497
- reference(type="actions") # List all
498
- reference(type="actions", query="email") # Search
499
- reference(type="actions", id="send_email") # Get specific
500
- reference(type="actions", suggest="IT helpdesk") # Suggest for use case
501
- reference(type="actions", categories=true) # List categories
502
-
503
- **Templates & Patterns**:
504
- reference(type="templates") # List persona templates
505
- reference(type="patterns") # List workflow patterns
506
- reference(type="patterns", pattern="intent-routing") # Get specific
507
-
508
- **Widgets**:
509
- reference(type="widgets", persona_type="voice")
510
-
511
- **Concepts & Guidance**:
512
- reference(concept="HITL")
513
- reference(guidance="categorizer-routing")
514
- reference(questions=true) # Qualifying questions
515
-
516
- **Debugging**:
517
- reference(mistakes=true)
518
- reference(checklist=true)
519
- reference(execution=true)
520
-
521
- **Validation**:
522
- reference(check_types={source: "CHAT_CONVERSATION", target: "TEXT"})`,
523
- inputSchema: withEnv({
524
- // Type selector (v2)
525
- type: {
526
- type: "string",
527
- enum: ["envs", "actions", "templates", "patterns", "widgets", "concepts"],
528
- description: "What type of reference information"
529
- },
530
- // Actions
531
- id: { type: "string", description: "Action ID for details" },
532
- query: { type: "string", description: "Search actions by name" },
533
- suggest: { type: "string", description: "Suggest actions for use case" },
534
- categories: { type: "boolean", description: "List action categories" },
535
- category: { type: "string", description: "Filter by category" },
536
- include_docs: { type: "boolean", description: "Include full documentation" },
537
- limit: { type: "number", description: "Max results" },
538
- // Patterns
539
- pattern: {
540
- type: "string",
541
- enum: ["simple-kb-search", "intent-routing", "multi-source-search", "tool-calling", "hitl-approval", "document-processing", "guardrails-pattern"],
542
- description: "Get specific pattern"
543
- },
544
- // Widgets
545
- persona_type: { type: "string", enum: ["voice", "chat", "dashboard"], description: "Persona type for widgets" },
546
- // Concepts
547
- concept: { type: "string", description: "Get definition of platform term" },
548
- concepts: { type: "boolean", description: "List all platform concepts" },
549
- // Questions
550
- questions: { type: "boolean", description: "Get qualifying questions" },
551
- required_only: { type: "boolean", description: "Only required questions" },
552
- // Guidance
553
- guidance: {
554
- type: "string",
555
- enum: [
556
- "categorizer-routing", "type-compatibility", "named-inputs",
557
- "hitl-patterns", "hitl-policy", "multi-source-search", "voice-tool-calling",
558
- "guardrails", "output-mapping", "workflow-execution", "conversation-vs-query",
559
- "workflow-structure", "search-node-timing", "node-execution-conditions",
560
- "array-preservation", "search-filtering", "fallback-response-inputs",
561
- "separate-vs-merged-inputs", "folder-path-filtering", "automated-extraction-json"
562
- ],
563
- description: "Get guidance on topic"
564
- },
565
- // Debugging
566
- mistakes: { type: "boolean", description: "Get common mistakes list" },
567
- checklist: { type: "boolean", description: "Get debug checklist" },
568
- execution: { type: "boolean", description: "Get workflow execution model" },
569
- // Validation
570
- check_types: {
571
- type: "object",
572
- properties: {
573
- source: { type: "string", description: "Source output type" },
574
- target: { type: "string", description: "Target input type" },
575
- },
576
- description: "Check type compatibility"
577
- },
578
- validate_prompt: { type: "string", description: "Validate workflow prompt" },
579
- }),
580
- },
581
- // ═══════════════════════════════════════════════════════════════════════
582
- // 7b. DATA - Manage persona data (files + generation)
583
- // ═══════════════════════════════════════════════════════════════════════
584
- {
585
- name: "data",
586
- description: `Manage AI Employee data: list, upload, generate, modify, sanitize, delete.
587
-
588
- ## Mode is REQUIRED for clarity. If omitted, tool will clarify.
589
-
590
- **List files**:
591
- data(persona_id="abc", mode="list")
592
- data(persona_id="abc", mode="list", limit=50)
593
-
594
- **Get specific file**:
595
- data(persona_id="abc", mode="get", file_id="file-123")
596
-
597
- **Upload file**:
598
- data(persona_id="abc", mode="upload", file="/path/to/doc.pdf")
599
-
600
- **Generate new content** (via Document Generation API):
601
- data(persona_id="abc", mode="generate", input="Generate 5 customer profiles for B2B SaaS")
602
- data(persona_id="abc", mode="generate", from="demo-sales-sdr")
603
- data(persona_id="abc", mode="generate", from="customer", count=10)
604
-
605
- **Modify existing document**:
606
- data(persona_id="abc", mode="modify", file_id="file-123", input="Rewrite for legal compliance")
607
-
608
- **Sanitize data** (replace PII):
609
- data(persona_id="abc", mode="sanitize")
610
- data(persona_id="abc", mode="sanitize", include_workflow=true)
611
-
612
- **Delete file**:
613
- data(persona_id="abc", mode="delete", file_id="file-123")
614
-
615
- **Embedding status/toggle**:
616
- data(persona_id="abc", mode="embedding")
617
- data(persona_id="abc", mode="embedding", enabled=true)
618
-
619
- **List available templates**:
620
- data(mode="templates")
621
- data(mode="templates", template="customer")`,
622
- inputSchema: withEnv({
623
- persona_id: { type: "string", description: "AI Employee ID (required for most operations)" },
624
- mode: {
625
- type: "string",
626
- enum: ["list", "get", "upload", "generate", "modify", "sanitize", "delete", "embedding", "templates"],
627
- description: "Operation to perform. REQUIRED for clarity - tool will ask if omitted."
628
- },
629
- // === Identify existing resource ===
630
- file_id: { type: "string", description: "File/document ID for get/modify/delete" },
631
- // === Generation params ===
632
- from: { type: "string", description: "Template name for generate mode (e.g., 'demo-sales-sdr', 'customer', 'faq')" },
633
- input: { type: "string", description: "Natural language instructions for generate/modify" },
634
- count: { type: "number", description: "Number of items to generate (default: 1)" },
635
- format: {
636
- type: "string",
637
- enum: ["markdown", "json", "html"],
638
- description: "Output format for generation (default: markdown)"
639
- },
640
- data: { type: "object", description: "Additional data context for generation" },
641
- // === Template info ===
642
- template: { type: "string", description: "Get specific template details" },
643
- // === List options ===
644
- limit: { type: "number", description: "Max results (default: 50)" },
645
- page: { type: "number", description: "Page number (default: 1)" },
646
- // === Upload params ===
647
- file: { type: "string", description: "File path for upload" },
648
- tags: { type: "string", description: "Tags for uploaded file" },
649
- // === Sanitize options ===
650
- include_workflow: { type: "boolean", description: "Also sanitize workflow config" },
651
- sanitize_examples: { type: "array", items: { type: "string" }, description: "Additional sensitive items to sanitize" },
652
- // === Embedding toggle ===
653
- enabled: { type: "boolean", description: "Enable/disable embedding" },
654
- }),
655
- },
656
- // ═══════════════════════════════════════════════════════════════════════
657
- // 8. SYNC - Environment synchronization
658
- // ═══════════════════════════════════════════════════════════════════════
659
- {
660
- name: "sync",
661
- description: `Sync AI Employees across environments.
662
-
663
- **Sync single**:
664
- sync(id="IT Support", target="dev")
665
- sync(id="abc-123", target="staging", dry_run=true)
666
-
667
- **Sync all tagged**:
668
- sync(target="dev", scope="all")
669
-
670
- **Status**:
671
- sync(mode="status", id="abc-123")
672
- sync(mode="status", list_synced=true)
673
-
674
- **Config**:
675
- sync(mode="config")`,
676
- inputSchema: {
677
- type: "object",
678
- properties: {
679
- // What to sync
680
- id: { type: "string", description: "Persona ID or name" },
681
- // Deprecated alias (backwards compatibility)
682
- identifier: { type: "string", deprecated: true, description: "DEPRECATED: use id. Persona ID or name" },
683
- // Mode
684
- mode: {
685
- type: "string",
686
- enum: ["run", "status", "config"],
687
- description: "Operation. Default: 'run'"
688
- },
689
- // Sync flags
690
- source: { type: "string", description: "Source environment (default: current)" },
691
- target: { type: "string", description: "Target environment (required for run)" },
692
- scope: {
693
- type: "string",
694
- enum: ["one", "all"],
695
- description: "Sync one or all tagged"
696
- },
697
- dry_run: { type: "boolean", description: "Simulate without changes" },
698
- include_status: { type: "boolean", description: "Also sync enabled/disabled" },
699
- // Status flags
700
- list_synced: { type: "boolean", description: "List all synced personas" },
701
- master_env: { type: "string", description: "Filter by master environment" },
702
- env: { type: "string", description: "Target environment for status queries" },
703
- },
704
- required: [],
705
- },
706
- },
707
- // ═══════════════════════════════════════════════════════════════════════
708
- // 9. DEMO - DEPRECATED: Use data() and persona() instead
709
- // ═══════════════════════════════════════════════════════════════════════
710
- {
711
- name: "demo",
712
- description: `DEPRECATED: Use \`data()\` and \`persona()\` instead. This tool routes to them internally.
713
-
714
- ## Migration Guide
715
-
716
- | OLD (deprecated) | NEW |
717
- |------------------|-----|
718
- | demo(mode="kit", persona_id="...", scenario="sales-sdr") | persona(from="demo-sales-sdr", include_data=true) |
719
- | demo(mode="generate", entity="customer", data={...}) | data(persona_id="...", mode="generate", from="customer", data={...}) |
720
- | demo(mode="scenarios") | data(mode="templates") |
721
- | demo(mode="template", entity="customer") | data(mode="templates", template="customer") |
722
-
723
- The \`data\` tool now supports document generation:
724
- data(persona_id="abc", mode="generate", input="Generate 5 customer profiles")
725
- data(persona_id="abc", mode="generate", from="demo-sales-sdr")
726
-
727
- The \`persona\` tool supports demo kit creation:
728
- persona(from="demo-sales-sdr", name="My Demo", include_data=true)
729
-
730
- This tool still works but shows a deprecation warning.`,
731
- inputSchema: {
732
- type: "object",
733
- properties: {
734
- mode: {
735
- type: "string",
736
- enum: ["kit", "validate_kit", "scenarios", "consolidate", "generate", "validate", "template"],
737
- description: "Operation"
738
- },
739
- // Kit generation flags
740
- persona_id: { type: "string", description: "Persona ID for kit generation" },
741
- scenario: {
742
- type: "string",
743
- enum: ["sales-sdr", "support-tier1", "hr-assistant"],
744
- description: "Demo scenario template"
745
- },
746
- custom_qa: {
747
- type: "array",
748
- description: "Custom Q&A pairs [{question, answer}]"
749
- },
750
- // Consolidate flags
751
- source: { type: "string", description: "Source directory" },
752
- output: { type: "string", description: "Output directory" },
753
- primary: { type: "string", description: "Primary JSON file" },
754
- joins: {
755
- type: "array",
756
- description: "Files to join [{file, on, as}]"
757
- },
758
- // Entity type
759
- entity: {
760
- type: "string",
761
- enum: ["customer", "product", "employee", "faq", "policy", "benefit", "company"],
762
- description: "Entity type"
763
- },
764
- // Generate flags
765
- data: { type: "object", description: "Entity data for generation" },
766
- related: { type: "object", description: "Related data to include" },
767
- // Validate flags
768
- file: { type: "string", description: "File path to validate" },
769
- content: { type: "string", description: "Content to validate" },
770
- // Common
771
- tags: { type: "string", description: "Tags for metadata" },
772
- },
773
- required: [],
774
- },
775
- },
776
- ];
777
- }
778
- /**
779
- * Tool name mapping for backward compatibility
780
- * Maps old tool names to new consolidated tool + args
781
- */
782
- export const LEGACY_TOOL_MAPPING = {
783
- // Environment
784
- list_environments: { tool: "env", transform: () => ({}) },
785
- // Persona tools → persona
786
- get_persona: { tool: "persona", transform: (a) => ({ ...a, mode: "get" }) },
787
- find_personas: { tool: "persona", transform: (a) => ({ ...a, all: true }) },
788
- create_ai_employee: { tool: "persona", transform: (a) => ({ ...a, mode: "create" }) },
789
- update_ai_employee: { tool: "persona", transform: (a) => ({ ...a, mode: "update", id: a.persona_id }) },
790
- compare_ai_employees: { tool: "persona", transform: (a) => ({ id: a.persona_id_1, mode: "compare", compare_to: a.persona_id_2, compare_env: a.env_2 }) },
791
- list_ai_employee_templates: { tool: "persona", transform: () => ({ templates: true }) },
792
- // Workflow tools → workflow
793
- deploy_workflow: { tool: "workflow", transform: (a) => ({ ...a, mode: "deploy" }) },
794
- optimize_workflow: { tool: "workflow", transform: (a) => ({ ...a, mode: "optimize", id: a.identifier }) },
795
- compile_workflow: { tool: "workflow", transform: (a) => ({ ...a, mode: "compile" }) },
796
- analyze_workflow: { tool: "workflow", transform: (a) => ({ ...a, mode: "analyze" }) },
797
- detect_workflow_issues: { tool: "workflow", transform: (a) => ({ ...a, mode: "analyze" }) },
798
- validate_workflow_connections: { tool: "workflow", transform: (a) => ({ ...a, mode: "analyze", include: ["connections"] }) },
799
- suggest_workflow_fixes: { tool: "workflow", transform: (a) => ({ ...a, mode: "analyze", include: ["fixes"] }) },
800
- compare_workflow_versions: { tool: "workflow", transform: (a) => ({ persona_id: a.persona_id_before, mode: "compare", compare_to: a.persona_id_after }) },
801
- get_workflow_metrics: { tool: "workflow", transform: (a) => ({ ...a, mode: "analyze", include: ["metrics"] }) },
802
- // Action tools → action
803
- get_workflow_action: { tool: "action", transform: (a) => a },
804
- find_workflow_actions: { tool: "action", transform: (a) => ({ ...a, all: true }) },
805
- list_auto_builder_agents: { tool: "action", transform: (a) => ({ ...a, all: true, include_docs: true }) },
806
- get_auto_builder_agent: { tool: "action", transform: (a) => ({ id: a.action_name, include_docs: true }) },
807
- suggest_agents_for_use_case: { tool: "action", transform: (a) => ({ suggest: a.use_case }) },
808
- // Template tools → template
809
- get_workflow_pattern: { tool: "template", transform: (a) => ({ pattern: a.pattern_name }) },
810
- list_workflow_patterns: { tool: "template", transform: (a) => ({ patterns: true, type: a.persona_type }) },
811
- get_widget_reference: { tool: "template", transform: (a) => ({ widgets: a.persona_type }) },
812
- get_voice_persona_template: { tool: "template", transform: () => ({ config: "voice" }) },
813
- get_qualifying_questions: { tool: "template", transform: (a) => ({ questions: true, ...a }) },
814
- // Knowledge tools → data (knowledge is deprecated)
815
- upload_data_source: { tool: "data", transform: (a) => ({ ...a, mode: "upload", file: a.file_path }) },
816
- delete_data_source: { tool: "data", transform: (a) => ({ ...a, mode: "delete" }) },
817
- list_data_sources: { tool: "data", transform: (a) => ({ ...a, mode: "list" }) },
818
- get_embedding_status: { tool: "data", transform: (a) => ({ ...a, mode: "embedding" }) },
819
- toggle_embedding: { tool: "data", transform: (a) => ({ ...a, mode: "embedding" }) },
820
- // Reference tools → reference
821
- get_platform_concept: { tool: "reference", transform: (a) => ({ concept: a.term }) },
822
- list_platform_concepts: { tool: "reference", transform: () => ({ concepts: true }) },
823
- get_common_mistakes: { tool: "reference", transform: () => ({ mistakes: true }) },
824
- get_debug_checklist: { tool: "reference", transform: () => ({ checklist: true }) },
825
- get_workflow_execution_model: { tool: "reference", transform: () => ({ execution: true }) },
826
- get_auto_builder_guidance: { tool: "reference", transform: (a) => ({ guidance: a.topic }) },
827
- validate_workflow_prompt: { tool: "reference", transform: (a) => ({ validate_prompt: a.prompt }) },
828
- check_type_compatibility: { tool: "reference", transform: (a) => ({ check_types: { source: a.source_type, target: a.target_type } }) },
829
- // Demo data tools → data (demo is deprecated)
830
- consolidate_demo_data: { tool: "demo", transform: (a) => ({ mode: "consolidate", source: a.source_dir, output: a.output_dir, ...a }) },
831
- generate_demo_document: { tool: "data", transform: (a) => ({ mode: "generate", from: a.entity_type, data: a.data }) },
832
- validate_demo_document: { tool: "demo", transform: (a) => ({ mode: "validate", file: a.file_path, content: a.content }) },
833
- get_demo_data_template: { tool: "data", transform: (a) => ({ mode: "templates", template: a.entity_type }) },
834
- };
835
- // Summary of consolidation
836
- export const CONSOLIDATION_SUMMARY = {
837
- before: 45,
838
- after: 7,
839
- active_tools: [
840
- { name: "env", replaces: ["list_environments"] },
841
- { name: "persona", replaces: ["get_persona", "find_personas", "create_ai_employee", "update_ai_employee", "compare_ai_employees", "list_ai_employee_templates"] },
842
- { name: "data", replaces: ["upload_data_source", "delete_data_source", "list_data_sources", "get_embedding_status", "toggle_embedding", "generate_demo_document", "get_demo_data_template"], note: "Also includes document generation" },
843
- { name: "action", replaces: ["get_workflow_action", "find_workflow_actions", "list_auto_builder_agents", "get_auto_builder_agent", "suggest_agents_for_use_case"] },
844
- { name: "template", replaces: ["get_workflow_pattern", "list_workflow_patterns", "get_widget_reference", "get_voice_persona_template", "get_qualifying_questions"] },
845
- { name: "reference", replaces: ["get_platform_concept", "list_platform_concepts", "get_common_mistakes", "get_debug_checklist", "get_workflow_execution_model", "get_auto_builder_guidance", "validate_workflow_prompt", "check_type_compatibility"] },
846
- { name: "sync", replaces: ["sync", "sync_info"] },
847
- ],
848
- deprecated_tools: [
849
- { name: "workflow", status: "deprecated", use_instead: "persona" },
850
- { name: "knowledge", status: "deprecated", use_instead: "data" },
851
- { name: "demo", status: "deprecated", use_instead: "data + persona" },
852
- ],
853
- // Legacy mapping preserved for backwards compatibility
854
- tools: [
855
- { name: "env", replaces: ["list_environments"] },
856
- { name: "persona", replaces: ["get_persona", "find_personas", "create_ai_employee", "update_ai_employee", "compare_ai_employees", "list_ai_employee_templates"] },
857
- { name: "workflow", replaces: ["workflow", "deploy_workflow", "optimize_workflow", "compile_workflow", "analyze_workflow", "detect_workflow_issues", "validate_workflow_connections", "suggest_workflow_fixes", "compare_workflow_versions", "get_workflow_metrics"], deprecated: true },
858
- { name: "action", replaces: ["get_workflow_action", "find_workflow_actions", "list_auto_builder_agents", "get_auto_builder_agent", "suggest_agents_for_use_case"] },
859
- { name: "template", replaces: ["get_workflow_pattern", "list_workflow_patterns", "get_widget_reference", "get_voice_persona_template", "get_qualifying_questions"] },
860
- { name: "knowledge", replaces: ["upload_data_source", "delete_data_source", "list_data_sources", "get_embedding_status", "toggle_embedding"], deprecated: true },
861
- { name: "data", replaces: ["generate_demo_document", "get_demo_data_template"] },
862
- { name: "reference", replaces: ["get_platform_concept", "list_platform_concepts", "get_common_mistakes", "get_debug_checklist", "get_workflow_execution_model", "get_auto_builder_guidance", "validate_workflow_prompt", "check_type_compatibility"] },
863
- { name: "sync", replaces: ["sync", "sync_info"] },
864
- { name: "demo", replaces: ["consolidate_demo_data", "validate_demo_document"], deprecated: true },
865
- ],
866
- };