@ema.co/mcp-toolkit 1.4.0 → 1.4.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.
- package/README.md +23 -1
- package/dist/cli/index.js +0 -0
- package/dist/mcp/handlers-consolidated.js +850 -108
- package/dist/mcp/prompts.js +134 -0
- package/dist/mcp/resources.js +4 -4
- package/dist/mcp/server.js +9 -215
- package/dist/mcp/tools-consolidated.js +75 -52
- package/dist/sdk/client.js +164 -20
- package/dist/sdk/contracts.js +1 -0
- package/docs/mcp-tools-guide.md +134 -17
- package/package.json +5 -3
- package/dist/config.js +0 -136
- package/dist/emaClient.js +0 -398
- package/dist/models.js +0 -8
- package/dist/state.js +0 -88
- package/dist/syncOptions.js +0 -216
package/dist/mcp/prompts.js
CHANGED
|
@@ -680,6 +680,140 @@ Now begin the comparison.`,
|
|
|
680
680
|
],
|
|
681
681
|
},
|
|
682
682
|
// ─────────────────────────────────────────────────────────────────────────
|
|
683
|
+
// Version Management
|
|
684
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
685
|
+
persona_version: {
|
|
686
|
+
definition: {
|
|
687
|
+
name: "persona_version",
|
|
688
|
+
description: "Manage AI Employee versions - create snapshots, list history, compare, or restore.",
|
|
689
|
+
arguments: [
|
|
690
|
+
{
|
|
691
|
+
name: "persona_id",
|
|
692
|
+
description: "ID or exact name of the AI Employee",
|
|
693
|
+
required: true,
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
name: "action",
|
|
697
|
+
description: "Action: 'snapshot' (create), 'list' (history), 'compare' (diff), 'restore' (rollback), 'policy' (auto-settings)",
|
|
698
|
+
required: true,
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
name: "version",
|
|
702
|
+
description: "Version identifier for compare/restore (e.g., 'v3', 'latest')",
|
|
703
|
+
required: false,
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
name: "message",
|
|
707
|
+
description: "Message for snapshot (e.g., 'Before adding HITL')",
|
|
708
|
+
required: false,
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
name: "env",
|
|
712
|
+
description: "Environment (default: demo)",
|
|
713
|
+
required: false,
|
|
714
|
+
},
|
|
715
|
+
],
|
|
716
|
+
},
|
|
717
|
+
render: (args) => [
|
|
718
|
+
{
|
|
719
|
+
role: "user",
|
|
720
|
+
content: {
|
|
721
|
+
type: "text",
|
|
722
|
+
text: `Manage versions for AI Employee: ${args.persona_id}
|
|
723
|
+
|
|
724
|
+
**Action**: ${args.action}
|
|
725
|
+
**Environment**: ${args.env || "demo"}
|
|
726
|
+
${args.version ? `**Version**: ${args.version}` : ""}
|
|
727
|
+
${args.message ? `**Message**: ${args.message}` : ""}
|
|
728
|
+
|
|
729
|
+
## Instructions
|
|
730
|
+
|
|
731
|
+
${args.action === "snapshot" ? `
|
|
732
|
+
### Create Snapshot
|
|
733
|
+
1. First verify the persona exists:
|
|
734
|
+
\`persona(id="${args.persona_id}", env="${args.env || "demo"}")\`
|
|
735
|
+
|
|
736
|
+
2. Create the snapshot:
|
|
737
|
+
\`persona(id="${args.persona_id}", mode="version_create", message="${args.message || "Manual snapshot"}", env="${args.env || "demo"}")\`
|
|
738
|
+
|
|
739
|
+
3. Confirm the snapshot was created by listing versions:
|
|
740
|
+
\`persona(id="${args.persona_id}", mode="version_list", env="${args.env || "demo"}")\`
|
|
741
|
+
` : ""}${args.action === "list" ? `
|
|
742
|
+
### List Version History
|
|
743
|
+
1. Get version history:
|
|
744
|
+
\`persona(id="${args.persona_id}", mode="version_list", env="${args.env || "demo"}")\`
|
|
745
|
+
|
|
746
|
+
2. Present the versions in a table showing:
|
|
747
|
+
- Version name (v1, v2, etc.)
|
|
748
|
+
- Created timestamp
|
|
749
|
+
- Trigger (manual, deploy, sync)
|
|
750
|
+
- Message
|
|
751
|
+
- Content hash (for deduplication)
|
|
752
|
+
` : ""}${args.action === "compare" ? `
|
|
753
|
+
### Compare Versions
|
|
754
|
+
1. List versions first to see available:
|
|
755
|
+
\`persona(id="${args.persona_id}", mode="version_list", env="${args.env || "demo"}")\`
|
|
756
|
+
|
|
757
|
+
2. Compare two versions:
|
|
758
|
+
\`persona(id="${args.persona_id}", mode="version_compare", v1="${args.version || "v1"}", v2="latest", env="${args.env || "demo"}")\`
|
|
759
|
+
|
|
760
|
+
3. Present changes:
|
|
761
|
+
- Fields that changed
|
|
762
|
+
- Nodes added/removed/modified
|
|
763
|
+
- Data sources added/removed
|
|
764
|
+
` : ""}${args.action === "restore" ? `
|
|
765
|
+
### Restore to Previous Version
|
|
766
|
+
**Warning**: This will modify the live AI Employee!
|
|
767
|
+
|
|
768
|
+
1. List versions to find the one to restore:
|
|
769
|
+
\`persona(id="${args.persona_id}", mode="version_list", env="${args.env || "demo"}")\`
|
|
770
|
+
|
|
771
|
+
2. Get details of the target version:
|
|
772
|
+
\`persona(id="${args.persona_id}", mode="version_get", version="${args.version || "v1"}", env="${args.env || "demo"}")\`
|
|
773
|
+
|
|
774
|
+
3. Confirm with user before proceeding, then restore:
|
|
775
|
+
\`persona(id="${args.persona_id}", mode="version_restore", version="${args.version || "v1"}", env="${args.env || "demo"}")\`
|
|
776
|
+
|
|
777
|
+
Note: A "before restore" snapshot is automatically created for safety.
|
|
778
|
+
` : ""}${args.action === "policy" ? `
|
|
779
|
+
### Configure Auto-Versioning Policy
|
|
780
|
+
1. Get current policy:
|
|
781
|
+
\`persona(id="${args.persona_id}", mode="version_policy", env="${args.env || "demo"}")\`
|
|
782
|
+
|
|
783
|
+
2. Enable auto-snapshot on deploy:
|
|
784
|
+
\`persona(id="${args.persona_id}", mode="version_policy", auto_on_deploy=true, env="${args.env || "demo"}")\`
|
|
785
|
+
|
|
786
|
+
3. Enable auto-snapshot on sync:
|
|
787
|
+
\`persona(id="${args.persona_id}", mode="version_policy", auto_on_sync=true, env="${args.env || "demo"}")\`
|
|
788
|
+
|
|
789
|
+
4. Set max versions to keep (prunes oldest):
|
|
790
|
+
\`persona(id="${args.persona_id}", mode="version_policy", max_versions=10, env="${args.env || "demo"}")\`
|
|
791
|
+
` : ""}
|
|
792
|
+
## Output Format
|
|
793
|
+
|
|
794
|
+
\`\`\`markdown
|
|
795
|
+
## Version Management: {Persona Name}
|
|
796
|
+
|
|
797
|
+
### Action: ${args.action}
|
|
798
|
+
{result of the action}
|
|
799
|
+
|
|
800
|
+
### Version History (if applicable)
|
|
801
|
+
| Version | Created | Trigger | Message |
|
|
802
|
+
|---------|---------|---------|---------|
|
|
803
|
+
| v3 | 2026-01-12 | deploy | Pre-deploy snapshot |
|
|
804
|
+
| v2 | 2026-01-11 | manual | Before adding HITL |
|
|
805
|
+
| v1 | 2026-01-10 | manual | Initial snapshot |
|
|
806
|
+
|
|
807
|
+
### Next Steps
|
|
808
|
+
{recommendations based on action taken}
|
|
809
|
+
\`\`\`
|
|
810
|
+
|
|
811
|
+
Now proceed with the ${args.action} action.`,
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
],
|
|
815
|
+
},
|
|
816
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
683
817
|
// Validate Prompt
|
|
684
818
|
// ─────────────────────────────────────────────────────────────────────────
|
|
685
819
|
prompt_validate: {
|
package/dist/mcp/resources.js
CHANGED
|
@@ -141,10 +141,10 @@ const RESOURCE_MAP = {
|
|
|
141
141
|
description: "Dashboard AI deployment guide: batch processing setup, input configuration",
|
|
142
142
|
mimeType: "text/markdown",
|
|
143
143
|
},
|
|
144
|
-
// Cursor Rules -
|
|
145
|
-
"ema://rules/
|
|
146
|
-
path: ".cursor/rules/
|
|
147
|
-
description: "
|
|
144
|
+
// Cursor Rules - MCP usage guidance
|
|
145
|
+
"ema://rules/mcp-usage": {
|
|
146
|
+
path: ".cursor/rules/ema-mcp.md",
|
|
147
|
+
description: "MCP usage guide: workflow modes, preview flag, brownfield extension, common patterns",
|
|
148
148
|
mimeType: "text/markdown",
|
|
149
149
|
},
|
|
150
150
|
};
|
package/dist/mcp/server.js
CHANGED
|
@@ -34,8 +34,6 @@ import { AGENT_CATALOG, WORKFLOW_PATTERNS, QUALIFYING_QUESTIONS, PLATFORM_CONCEP
|
|
|
34
34
|
analyzeWorkflow, detectWorkflowIssues, validateWorkflowConnections, suggestWorkflowFixes, } from "../sdk/knowledge.js";
|
|
35
35
|
// Workflow Compiler (Template-driven)
|
|
36
36
|
import { compileWorkflow, } from "../sdk/workflow-generator.js";
|
|
37
|
-
// Workflow Intent (Normalization layer)
|
|
38
|
-
import { parseInput, intentToSpec, } from "../sdk/workflow-intent.js";
|
|
39
37
|
// Consolidated Tools (Unix CLI pattern) - NEW UNIFIED INTERFACE
|
|
40
38
|
import { generateConsolidatedTools, } from "./tools-consolidated.js";
|
|
41
39
|
// Legacy Tools (backwards compatibility) - DEPRECATED, OFF BY DEFAULT
|
|
@@ -43,7 +41,7 @@ import { generateLegacyTools, } from "./tools-legacy.js";
|
|
|
43
41
|
// Feature flag: Legacy tools are DISABLED by default to prevent LLM confusion
|
|
44
42
|
// Set EMA_ENABLE_LEGACY_TOOLS=true only if you need backwards compatibility
|
|
45
43
|
const ENABLE_LEGACY_TOOLS = process.env.EMA_ENABLE_LEGACY_TOOLS === "true";
|
|
46
|
-
import { handleEnv, handlePersona, handleAction, handleTemplate, handleKnowledge, handleReference, } from "./handlers-consolidated.js";
|
|
44
|
+
import { handleEnv, handlePersona, handleWorkflow, handleAction, handleTemplate, handleKnowledge, handleReference, } from "./handlers-consolidated.js";
|
|
47
45
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
48
46
|
// Autobuilder Prompt Generation
|
|
49
47
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -4295,7 +4293,8 @@ const toolHandlers = {
|
|
|
4295
4293
|
const statusLog = persona.status_log;
|
|
4296
4294
|
const fileUploadLog = statusLog?.fileUpload ?? [];
|
|
4297
4295
|
// Try to get actual file list from API
|
|
4298
|
-
const
|
|
4296
|
+
const filesResult = await client.listDataSourceFiles(personaId);
|
|
4297
|
+
const files = filesResult.files;
|
|
4299
4298
|
return {
|
|
4300
4299
|
environment: client["env"].name,
|
|
4301
4300
|
persona_id: personaId,
|
|
@@ -4303,6 +4302,7 @@ const toolHandlers = {
|
|
|
4303
4302
|
embedding_enabled: persona.embedding_enabled ?? false,
|
|
4304
4303
|
file_count: fileCount,
|
|
4305
4304
|
files: files.length > 0 ? files : fileUploadLog,
|
|
4305
|
+
pagination: filesResult.pagination,
|
|
4306
4306
|
use_chunking: fileUploadConfig?.useChunking ?? false,
|
|
4307
4307
|
workflow_id: persona.workflow_id,
|
|
4308
4308
|
actions: [
|
|
@@ -4366,215 +4366,6 @@ const toolHandlers = {
|
|
|
4366
4366
|
};
|
|
4367
4367
|
},
|
|
4368
4368
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4369
|
-
// Unified Workflow Handler
|
|
4370
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4371
|
-
workflow: async (args) => {
|
|
4372
|
-
const client = createClient(args.env);
|
|
4373
|
-
const personaId = args.persona_id ? String(args.persona_id) : undefined;
|
|
4374
|
-
const mode = args.mode ?? "generate";
|
|
4375
|
-
const useAutobuilder = args.use_autobuilder;
|
|
4376
|
-
const autoDeploy = Boolean(args.auto_deploy);
|
|
4377
|
-
const autoFix = args.auto_fix !== false; // Default true
|
|
4378
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4379
|
-
// MODE: IMPROVE - Improve existing workflow
|
|
4380
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4381
|
-
if (mode === "improve" && personaId) {
|
|
4382
|
-
const persona = await client.getPersonaById(personaId);
|
|
4383
|
-
if (!persona)
|
|
4384
|
-
throw new Error(`AI Employee not found: ${personaId}`);
|
|
4385
|
-
const currentWorkflow = persona.workflow_def;
|
|
4386
|
-
if (!currentWorkflow)
|
|
4387
|
-
throw new Error(`AI Employee "${persona.name}" has no workflow`);
|
|
4388
|
-
const issues = detectWorkflowIssues(currentWorkflow);
|
|
4389
|
-
if (issues.length === 0) {
|
|
4390
|
-
return {
|
|
4391
|
-
environment: client["env"].name,
|
|
4392
|
-
success: true,
|
|
4393
|
-
status: "no_issues",
|
|
4394
|
-
persona_id: personaId,
|
|
4395
|
-
persona_name: persona.name,
|
|
4396
|
-
message: "Workflow has no detected issues",
|
|
4397
|
-
};
|
|
4398
|
-
}
|
|
4399
|
-
// Try auto-fix first
|
|
4400
|
-
if (autoFix) {
|
|
4401
|
-
const fixResult = applyWorkflowFixes(currentWorkflow, issues, persona);
|
|
4402
|
-
if (fixResult.appliedFixes.some((f) => f.applied)) {
|
|
4403
|
-
const newIssues = detectWorkflowIssues(fixResult.fixedWorkflow);
|
|
4404
|
-
if (autoDeploy) {
|
|
4405
|
-
await client.updateAiEmployee({
|
|
4406
|
-
persona_id: personaId,
|
|
4407
|
-
proto_config: persona.proto_config ?? {},
|
|
4408
|
-
workflow: fixResult.fixedWorkflow,
|
|
4409
|
-
});
|
|
4410
|
-
}
|
|
4411
|
-
return {
|
|
4412
|
-
environment: client["env"].name,
|
|
4413
|
-
success: true,
|
|
4414
|
-
status: autoDeploy ? "deployed" : "improved",
|
|
4415
|
-
persona_id: personaId,
|
|
4416
|
-
persona_name: persona.name,
|
|
4417
|
-
fixes_applied: fixResult.appliedFixes.filter((f) => f.applied).map((f) => f.description),
|
|
4418
|
-
issues_before: issues.length,
|
|
4419
|
-
issues_after: newIssues.length,
|
|
4420
|
-
deployed: autoDeploy,
|
|
4421
|
-
workflow_def: autoDeploy ? undefined : fixResult.fixedWorkflow,
|
|
4422
|
-
};
|
|
4423
|
-
}
|
|
4424
|
-
}
|
|
4425
|
-
return {
|
|
4426
|
-
environment: client["env"].name,
|
|
4427
|
-
success: false,
|
|
4428
|
-
status: "needs_manual_fix",
|
|
4429
|
-
persona_id: personaId,
|
|
4430
|
-
issues,
|
|
4431
|
-
};
|
|
4432
|
-
}
|
|
4433
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4434
|
-
// MODE: ANALYZE - Analyze only (no generation)
|
|
4435
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4436
|
-
if (mode === "analyze" && personaId) {
|
|
4437
|
-
const persona = await client.getPersonaById(personaId);
|
|
4438
|
-
if (!persona)
|
|
4439
|
-
throw new Error(`AI Employee not found: ${personaId}`);
|
|
4440
|
-
const workflowDef = persona.workflow_def;
|
|
4441
|
-
if (!workflowDef) {
|
|
4442
|
-
return {
|
|
4443
|
-
environment: client["env"].name,
|
|
4444
|
-
success: true,
|
|
4445
|
-
status: "no_workflow",
|
|
4446
|
-
persona_id: personaId,
|
|
4447
|
-
persona_name: persona.name,
|
|
4448
|
-
};
|
|
4449
|
-
}
|
|
4450
|
-
const issues = detectWorkflowIssues(workflowDef);
|
|
4451
|
-
return {
|
|
4452
|
-
environment: client["env"].name,
|
|
4453
|
-
success: true,
|
|
4454
|
-
status: "analyzed",
|
|
4455
|
-
persona_id: personaId,
|
|
4456
|
-
persona_name: persona.name,
|
|
4457
|
-
issues,
|
|
4458
|
-
summary: {
|
|
4459
|
-
critical: issues.filter((i) => i.severity === "critical").length,
|
|
4460
|
-
warnings: issues.filter((i) => i.severity === "warning").length,
|
|
4461
|
-
},
|
|
4462
|
-
};
|
|
4463
|
-
}
|
|
4464
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4465
|
-
// MODE: GENERATE - Generate new workflow from input
|
|
4466
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4467
|
-
const input = args.input;
|
|
4468
|
-
if (!input && !personaId) {
|
|
4469
|
-
return {
|
|
4470
|
-
success: false,
|
|
4471
|
-
status: "missing_input",
|
|
4472
|
-
message: "Provide 'input' (description or spec) or 'persona_id' with mode='improve'",
|
|
4473
|
-
};
|
|
4474
|
-
}
|
|
4475
|
-
// Parse and normalize input
|
|
4476
|
-
const parseResult = parseInput(input);
|
|
4477
|
-
const { intent, input_type, validation } = parseResult;
|
|
4478
|
-
// Override persona_type if provided
|
|
4479
|
-
if (args.persona_type) {
|
|
4480
|
-
intent.persona_type = args.persona_type;
|
|
4481
|
-
}
|
|
4482
|
-
// If validation incomplete, return questions
|
|
4483
|
-
if (!validation.complete) {
|
|
4484
|
-
return {
|
|
4485
|
-
environment: client["env"].name,
|
|
4486
|
-
success: true,
|
|
4487
|
-
status: "needs_input",
|
|
4488
|
-
input_type,
|
|
4489
|
-
parsed_intent: intent,
|
|
4490
|
-
validation,
|
|
4491
|
-
message: "Need more information to generate workflow",
|
|
4492
|
-
questions: validation.questions,
|
|
4493
|
-
suggestions: validation.suggestions,
|
|
4494
|
-
};
|
|
4495
|
-
}
|
|
4496
|
-
// Decide: compile locally vs. use Auto Builder
|
|
4497
|
-
const isSimple = !intent.intents || intent.intents.length <= 2;
|
|
4498
|
-
const shouldUseAutobuilder = useAutobuilder ?? !isSimple;
|
|
4499
|
-
let workflowDef;
|
|
4500
|
-
let generationMethod;
|
|
4501
|
-
if (shouldUseAutobuilder) {
|
|
4502
|
-
// Use Auto Builder
|
|
4503
|
-
const prompt = generateAutobuilderPrompt(intent.description, intent.persona_type);
|
|
4504
|
-
const autobuilderId = await client.findAutobuilderPersona();
|
|
4505
|
-
const conv = await client.createAutobuilderConversation(autobuilderId);
|
|
4506
|
-
const result = await client.chatWithAutobuilder(conv.conversation_id, prompt);
|
|
4507
|
-
if (!result.workflow_def) {
|
|
4508
|
-
return {
|
|
4509
|
-
environment: client["env"].name,
|
|
4510
|
-
success: false,
|
|
4511
|
-
status: "generation_failed",
|
|
4512
|
-
message: "Auto Builder could not generate workflow. Try being more specific.",
|
|
4513
|
-
parsed_intent: intent,
|
|
4514
|
-
autobuilder_response: result.response,
|
|
4515
|
-
};
|
|
4516
|
-
}
|
|
4517
|
-
workflowDef = result.workflow_def;
|
|
4518
|
-
generationMethod = "autobuilder";
|
|
4519
|
-
}
|
|
4520
|
-
else {
|
|
4521
|
-
// Compile locally from intent
|
|
4522
|
-
const spec = intentToSpec(intent);
|
|
4523
|
-
const compiled = compileWorkflow(spec);
|
|
4524
|
-
workflowDef = compiled.workflow_def;
|
|
4525
|
-
generationMethod = "local_compile";
|
|
4526
|
-
}
|
|
4527
|
-
// Validate generated workflow
|
|
4528
|
-
const issues = detectWorkflowIssues(workflowDef);
|
|
4529
|
-
let fixesApplied = [];
|
|
4530
|
-
// Auto-fix if needed
|
|
4531
|
-
if (issues.length > 0 && autoFix) {
|
|
4532
|
-
const mockPersona = { id: personaId ?? "new", name: intent.name };
|
|
4533
|
-
const fixResult = applyWorkflowFixes(workflowDef, issues, mockPersona);
|
|
4534
|
-
if (fixResult.appliedFixes.some((f) => f.applied)) {
|
|
4535
|
-
workflowDef = fixResult.fixedWorkflow;
|
|
4536
|
-
fixesApplied = fixResult.appliedFixes.filter((f) => f.applied).map((f) => f.description);
|
|
4537
|
-
}
|
|
4538
|
-
}
|
|
4539
|
-
const finalIssues = detectWorkflowIssues(workflowDef);
|
|
4540
|
-
// Deploy if requested
|
|
4541
|
-
let deployed = false;
|
|
4542
|
-
if (personaId && autoDeploy) {
|
|
4543
|
-
const persona = await client.getPersonaById(personaId);
|
|
4544
|
-
if (persona) {
|
|
4545
|
-
await client.updateAiEmployee({
|
|
4546
|
-
persona_id: personaId,
|
|
4547
|
-
proto_config: persona.proto_config ?? {},
|
|
4548
|
-
workflow: workflowDef,
|
|
4549
|
-
});
|
|
4550
|
-
deployed = true;
|
|
4551
|
-
}
|
|
4552
|
-
}
|
|
4553
|
-
return {
|
|
4554
|
-
environment: client["env"].name,
|
|
4555
|
-
success: true,
|
|
4556
|
-
status: deployed ? "deployed" : "generated",
|
|
4557
|
-
input_type,
|
|
4558
|
-
generation_method: generationMethod,
|
|
4559
|
-
parsed_intent: intent,
|
|
4560
|
-
validation: {
|
|
4561
|
-
confidence: validation.confidence,
|
|
4562
|
-
suggestions: validation.suggestions,
|
|
4563
|
-
},
|
|
4564
|
-
issues_found: issues.length,
|
|
4565
|
-
auto_fixes: fixesApplied,
|
|
4566
|
-
remaining_issues: finalIssues.length,
|
|
4567
|
-
workflow_def: deployed ? undefined : workflowDef,
|
|
4568
|
-
deployed,
|
|
4569
|
-
persona_id: personaId,
|
|
4570
|
-
next_steps: deployed
|
|
4571
|
-
? [`Verify: get_persona("${personaId}")`]
|
|
4572
|
-
: personaId
|
|
4573
|
-
? [`Deploy: deploy_workflow("${personaId}", workflow_def)`]
|
|
4574
|
-
: ["Create AI Employee, then deploy workflow"],
|
|
4575
|
-
};
|
|
4576
|
-
},
|
|
4577
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
4578
4369
|
// Demo Data Management Handlers
|
|
4579
4370
|
// ─────────────────────────────────────────────────────────────────────────
|
|
4580
4371
|
consolidate_demo_data: async (args) => {
|
|
@@ -5049,8 +4840,11 @@ const toolHandlers = {
|
|
|
5049
4840
|
};
|
|
5050
4841
|
return handlePersona(args, client, (type) => DEFAULT_TEMPLATES[type], (env) => createClient(env), versionContext);
|
|
5051
4842
|
},
|
|
5052
|
-
//
|
|
5053
|
-
|
|
4843
|
+
// Consolidated workflow handler (replaces legacy inline handler)
|
|
4844
|
+
workflow: async (args) => {
|
|
4845
|
+
const client = createClient(args.env);
|
|
4846
|
+
return handleWorkflow(args, client);
|
|
4847
|
+
},
|
|
5054
4848
|
action: async (args) => {
|
|
5055
4849
|
const client = createClient(args.env);
|
|
5056
4850
|
return handleAction(args, client);
|
|
@@ -117,8 +117,13 @@ export function generateConsolidatedTools(envNames, defaultEnv) {
|
|
|
117
117
|
},
|
|
118
118
|
template_id: { type: "string", description: "Template ID (for create)" },
|
|
119
119
|
clone_from: { type: "string", description: "Clone from persona ID (for create)" },
|
|
120
|
+
clone_data: { type: "boolean", description: "Also clone knowledge base files when using clone_from (default: false)" },
|
|
120
121
|
// Update flags
|
|
121
122
|
enabled: { type: "boolean", description: "Enable/disable (for update)" },
|
|
123
|
+
proto_config: {
|
|
124
|
+
type: "object",
|
|
125
|
+
description: "Voice/chat settings (welcomeMessage, identityAndPurpose, etc.) for update"
|
|
126
|
+
},
|
|
122
127
|
// Compare flags
|
|
123
128
|
compare_to: { type: "string", description: "Second persona ID (for compare)" },
|
|
124
129
|
compare_env: { type: "string", description: "Environment of compare_to persona" },
|
|
@@ -135,88 +140,93 @@ export function generateConsolidatedTools(envNames, defaultEnv) {
|
|
|
135
140
|
}),
|
|
136
141
|
},
|
|
137
142
|
// ═══════════════════════════════════════════════════════════════════════
|
|
138
|
-
// 3. WORKFLOW - Generation, analysis,
|
|
143
|
+
// 3. WORKFLOW - Generation, analysis, extension, optimization
|
|
139
144
|
// ═══════════════════════════════════════════════════════════════════════
|
|
140
145
|
{
|
|
141
146
|
name: "workflow",
|
|
142
|
-
description: `Unified workflow
|
|
147
|
+
description: `Unified workflow operations. All modification modes default to preview=true for safety.
|
|
143
148
|
|
|
144
149
|
**Greenfield** (NEW workflow from scratch):
|
|
145
150
|
workflow(input="IT helpdesk with KB search")
|
|
146
151
|
workflow(mode="generate", input="customer support bot")
|
|
152
|
+
workflow(mode="generate", input="...", preview=false) # Generate AND deploy
|
|
153
|
+
|
|
154
|
+
**Extend** (MODIFY existing workflow - brownfield):
|
|
155
|
+
workflow(mode="extend", persona_id="abc", input="add caller_type categorizer")
|
|
156
|
+
workflow(mode="extend", persona_id="abc", input="add HITL before email, add compliance intent")
|
|
157
|
+
workflow(mode="extend", persona_id="abc", input="...", preview=false) # Extend AND deploy
|
|
147
158
|
|
|
148
|
-
**
|
|
149
|
-
workflow(
|
|
150
|
-
workflow(persona_id="abc",
|
|
159
|
+
**Optimize** (FIX issues in existing workflow):
|
|
160
|
+
workflow(mode="optimize", persona_id="abc") # Preview fixes
|
|
161
|
+
workflow(mode="optimize", persona_id="abc", preview=false) # Apply fixes
|
|
151
162
|
|
|
152
|
-
**Analyze** (inspect existing):
|
|
163
|
+
**Analyze** (inspect existing - always read-only):
|
|
153
164
|
workflow(persona_id="abc-123")
|
|
154
|
-
workflow(
|
|
155
|
-
workflow(workflow_def={...}
|
|
165
|
+
workflow(mode="analyze", persona_id="abc-123")
|
|
166
|
+
workflow(mode="analyze", workflow_def={...})
|
|
156
167
|
|
|
157
|
-
**
|
|
158
|
-
workflow(
|
|
159
|
-
workflow(persona_id="abc", mode="deploy", auto_fix=true)
|
|
168
|
+
**Compare** (diff two workflows - always read-only):
|
|
169
|
+
workflow(mode="compare", persona_id="abc", compare_to="def")
|
|
160
170
|
|
|
161
|
-
**
|
|
162
|
-
workflow(
|
|
163
|
-
workflow(persona_id="abc", mode="optimize", preview=true)
|
|
171
|
+
**Compile** (from explicit node spec - returns workflow_def):
|
|
172
|
+
workflow(mode="compile", name="...", description="...", nodes=[...])
|
|
164
173
|
|
|
165
|
-
|
|
166
|
-
workflow(persona_id="abc", mode="compare", compare_to="def")
|
|
174
|
+
## Key Concepts
|
|
167
175
|
|
|
168
|
-
**
|
|
169
|
-
|
|
176
|
+
- **preview=true** (default): Returns result without deploying. Safe for exploration.
|
|
177
|
+
- **preview=false**: Deploys the result. Server handles fetching proto_config, etc.
|
|
178
|
+
- **Auto-builder is abstracted**: Server decides when to use it internally.`,
|
|
170
179
|
inputSchema: withEnv({
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
// Mode - explicit operation
|
|
181
|
+
mode: {
|
|
182
|
+
type: "string",
|
|
183
|
+
enum: ["generate", "extend", "optimize", "analyze", "compare", "compile"],
|
|
184
|
+
description: "Operation: 'generate' (new), 'extend' (modify existing), 'optimize' (fix issues), 'analyze' (inspect), 'compare' (diff), 'compile' (from nodes). Default: inferred from args."
|
|
185
|
+
},
|
|
186
|
+
// Input (for generate/extend)
|
|
175
187
|
input: {
|
|
176
188
|
anyOf: [
|
|
177
189
|
{ type: "string", description: "Natural language description" },
|
|
178
190
|
{ type: "object", description: "Workflow intent/spec object" },
|
|
179
191
|
],
|
|
180
|
-
description: "Natural language
|
|
192
|
+
description: "Natural language requirements. Can include multiple changes: 'add X, add Y, add Z'",
|
|
181
193
|
},
|
|
194
|
+
// Target persona (for extend/optimize/analyze/compare)
|
|
182
195
|
persona_id: {
|
|
183
196
|
type: "string",
|
|
184
|
-
description: "Persona ID for existing workflow operations"
|
|
185
|
-
},
|
|
186
|
-
workflow_def: {
|
|
187
|
-
type: "object",
|
|
188
|
-
description: "Workflow JSON for analysis or deployment"
|
|
197
|
+
description: "Persona ID for existing workflow operations (extend/optimize/analyze/compare)"
|
|
189
198
|
},
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
type: "
|
|
193
|
-
|
|
194
|
-
description: "Operation mode. Default: 'generate' with input, 'analyze' with persona_id. Use 'optimize' for one-click fix & deploy."
|
|
199
|
+
// Preview vs Deploy (default: preview=true for safety)
|
|
200
|
+
preview: {
|
|
201
|
+
type: "boolean",
|
|
202
|
+
description: "Preview changes without deploying. Default: true. Set false to deploy."
|
|
195
203
|
},
|
|
196
|
-
//
|
|
197
|
-
preview: { type: "boolean", description: "Preview changes without deploying (for optimize mode)" },
|
|
198
|
-
// Generate flags
|
|
204
|
+
// Persona type (for generate)
|
|
199
205
|
type: {
|
|
200
206
|
type: "string",
|
|
201
207
|
enum: ["voice", "chat", "dashboard"],
|
|
202
|
-
description: "Persona type (default: chat)"
|
|
208
|
+
description: "Persona type for generate mode (default: chat)"
|
|
203
209
|
},
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
// Compare target
|
|
211
|
+
compare_to: { type: "string", description: "Second persona ID for compare mode" },
|
|
212
|
+
// Analyze options
|
|
206
213
|
include: {
|
|
207
214
|
type: "array",
|
|
208
215
|
items: { type: "string", enum: ["issues", "connections", "fixes", "metrics"] },
|
|
209
216
|
description: "What to include in analysis. Default: all.",
|
|
210
217
|
},
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
// Direct workflow input (for analyze without persona_id)
|
|
219
|
+
workflow_def: {
|
|
220
|
+
type: "object",
|
|
221
|
+
description: "Workflow JSON for analysis (alternative to persona_id)"
|
|
222
|
+
},
|
|
223
|
+
// Compile mode inputs
|
|
224
|
+
name: { type: "string", description: "Workflow name (for compile mode)" },
|
|
225
|
+
description: { type: "string", description: "Workflow description (for compile mode)" },
|
|
226
|
+
nodes: { type: "array", description: "Node definitions (for compile mode)" },
|
|
227
|
+
result_mappings: { type: "array", description: "Output mappings (for compile mode)" },
|
|
228
|
+
// Proto config override
|
|
229
|
+
proto_config: { type: "object", description: "Persona config override (voice settings, etc.)" },
|
|
220
230
|
}),
|
|
221
231
|
},
|
|
222
232
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -338,9 +348,12 @@ export function generateConsolidatedTools(envNames, defaultEnv) {
|
|
|
338
348
|
name: "knowledge",
|
|
339
349
|
description: `Manage AI Employee knowledge base (data sources & embedding).
|
|
340
350
|
|
|
341
|
-
**List files
|
|
351
|
+
**List files** (with pagination):
|
|
342
352
|
knowledge(persona_id="abc-123")
|
|
343
|
-
knowledge(persona_id="abc", mode="list")
|
|
353
|
+
knowledge(persona_id="abc", mode="list", limit=50, page=1)
|
|
354
|
+
|
|
355
|
+
**Get aggregates** (file counts by status):
|
|
356
|
+
knowledge(persona_id="abc", mode="aggregates")
|
|
344
357
|
|
|
345
358
|
**Upload file**:
|
|
346
359
|
knowledge(persona_id="abc", mode="upload", file="/path/to/doc.pdf")
|
|
@@ -352,14 +365,22 @@ export function generateConsolidatedTools(envNames, defaultEnv) {
|
|
|
352
365
|
knowledge(persona_id="abc", mode="status")
|
|
353
366
|
|
|
354
367
|
**Toggle embedding**:
|
|
355
|
-
knowledge(persona_id="abc", mode="toggle", enabled=true)
|
|
368
|
+
knowledge(persona_id="abc", mode="toggle", enabled=true)
|
|
369
|
+
|
|
370
|
+
**Attach data source to workflow node**:
|
|
371
|
+
knowledge(persona_id="abc", mode="attach", node_name="knowledge_search_1")
|
|
372
|
+
knowledge(persona_id="abc", mode="attach", node_name="knowledge_search_1", widget_name="fileUpload")`,
|
|
356
373
|
inputSchema: withEnv({
|
|
357
374
|
persona_id: { type: "string", description: "AI Employee ID (required)" },
|
|
358
375
|
mode: {
|
|
359
376
|
type: "string",
|
|
360
|
-
enum: ["list", "upload", "delete", "status", "toggle"],
|
|
377
|
+
enum: ["list", "aggregates", "upload", "delete", "status", "toggle", "attach"],
|
|
361
378
|
description: "Operation. Default: 'list'"
|
|
362
379
|
},
|
|
380
|
+
// List flags
|
|
381
|
+
page: { type: "number", description: "Page number (default: 1)" },
|
|
382
|
+
limit: { type: "number", description: "Items per page (default: 50)" },
|
|
383
|
+
widget_name: { type: "string", description: "Widget name (default: 'fileUpload')" },
|
|
363
384
|
// Upload flags
|
|
364
385
|
file: { type: "string", description: "File path for upload" },
|
|
365
386
|
tags: { type: "string", description: "Tags for uploaded file" },
|
|
@@ -367,6 +388,8 @@ export function generateConsolidatedTools(envNames, defaultEnv) {
|
|
|
367
388
|
file_id: { type: "string", description: "File ID to delete" },
|
|
368
389
|
// Toggle flags
|
|
369
390
|
enabled: { type: "boolean", description: "Enable/disable embedding" },
|
|
391
|
+
// Attach flags
|
|
392
|
+
node_name: { type: "string", description: "Workflow node name to attach data source to (e.g., 'knowledge_search_1')" },
|
|
370
393
|
}, ["persona_id"]),
|
|
371
394
|
},
|
|
372
395
|
// ═══════════════════════════════════════════════════════════════════════
|