snow-flow 3.3.2 → 3.3.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.
- package/README.md +84 -7
- package/dist/cli-new-prompt.d.ts +2 -0
- package/dist/cli-new-prompt.js +420 -0
- package/dist/cli.js +119 -887
- package/dist/dynamic-version.js +1 -1
- package/dist/mcp/servicenow-deployment-mcp.js +756 -2
- package/dist/queen/servicenow-queen.d.ts +1 -45
- package/dist/queen/servicenow-queen.js +615 -566
- package/package.json +2 -2
- package/src/cli.ts.backup-20250809-125529 +4773 -0
package/dist/cli.js
CHANGED
|
@@ -608,28 +608,12 @@ async function executeWithClaude(claudeCommand, prompt, resolve) {
|
|
|
608
608
|
});
|
|
609
609
|
}
|
|
610
610
|
// Helper function to build Queen Agent orchestration prompt
|
|
611
|
+
// Helper function to build Queen Agent orchestration prompt - CLEANED UP VERSION
|
|
611
612
|
function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId, isFlowDesignerTask = false) {
|
|
612
613
|
// Check if intelligent features are enabled
|
|
613
614
|
const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
|
|
614
615
|
options.liveTesting || options.autoDeploy || options.autoRollback ||
|
|
615
616
|
options.sharedMemory || options.progressMonitoring;
|
|
616
|
-
// Calculate actual autonomous system states (with override logic)
|
|
617
|
-
const noAutonomousAll = options.autonomousAll === false;
|
|
618
|
-
const forceAutonomousAll = options.autonomousAll === true;
|
|
619
|
-
const autonomousDocActive = noAutonomousAll ? false :
|
|
620
|
-
forceAutonomousAll ? true :
|
|
621
|
-
options.autonomousDocumentation !== false;
|
|
622
|
-
const autonomousCostActive = noAutonomousAll ? false :
|
|
623
|
-
forceAutonomousAll ? true :
|
|
624
|
-
options.autonomousCostOptimization !== false;
|
|
625
|
-
const autonomousComplianceActive = noAutonomousAll ? false :
|
|
626
|
-
forceAutonomousAll ? true :
|
|
627
|
-
options.autonomousCompliance !== false;
|
|
628
|
-
const autonomousHealingActive = noAutonomousAll ? false :
|
|
629
|
-
forceAutonomousAll ? true :
|
|
630
|
-
options.autonomousHealing !== false;
|
|
631
|
-
const hasAutonomousSystems = autonomousDocActive || autonomousCostActive ||
|
|
632
|
-
autonomousComplianceActive || autonomousHealingActive;
|
|
633
617
|
const prompt = `# 👑 Snow-Flow Queen Agent Orchestration
|
|
634
618
|
|
|
635
619
|
## 🎯 Mission Brief
|
|
@@ -664,13 +648,12 @@ You are the Queen Agent, master coordinator of the Snow-Flow hive-mind. Your mis
|
|
|
664
648
|
|
|
665
649
|
**For this objective**: Analyze if the user wants data generation, system building, or a simple operation.
|
|
666
650
|
|
|
667
|
-
${isFlowDesignerTask ? `## 🔧 Flow Designer Task Detected - Using
|
|
668
|
-
🚀 **FULLY AUTOMATED FLOW DEPLOYMENT v2.0** - ALL features working correctly!
|
|
651
|
+
${isFlowDesignerTask ? `## 🔧 Flow Designer Task Detected - Using Enhanced Flow Creation!
|
|
669
652
|
|
|
670
653
|
**MANDATORY: Use this exact approach for Flow Designer tasks:**
|
|
671
654
|
|
|
672
655
|
\`\`\`javascript
|
|
673
|
-
// ✅
|
|
656
|
+
// ✅ Complete flow generation with ALL features
|
|
674
657
|
await snow_create_flow({
|
|
675
658
|
instruction: "your natural language flow description",
|
|
676
659
|
deploy_immediately: true, // 🔥 Automatically deploys to ServiceNow!
|
|
@@ -678,32 +661,14 @@ await snow_create_flow({
|
|
|
678
661
|
});
|
|
679
662
|
\`\`\`
|
|
680
663
|
|
|
681
|
-
🎯 **What this does automatically
|
|
682
|
-
- ✅
|
|
683
|
-
- ✅
|
|
684
|
-
- ✅
|
|
685
|
-
- ✅
|
|
686
|
-
- ✅
|
|
687
|
-
- ✅ Automatic tool name resolution with MCPToolRegistry
|
|
688
|
-
- ✅ Complete metadata extraction (sys_id, URLs, endpoints)
|
|
689
|
-
- ✅ Performance _analysis and recommendations
|
|
690
|
-
- ✅ 100% of requested features deploy correctly!
|
|
691
|
-
|
|
692
|
-
🚫 **FORBIDDEN APPROACHES:**
|
|
693
|
-
- ❌ DO NOT use old API-only approach without XML generation
|
|
694
|
-
- ❌ DO NOT use manual \`snow-flow deploy-xml\` commands
|
|
695
|
-
- ❌ DO NOT generate XML without auto-deployment
|
|
696
|
-
- ❌ DO NOT use v1 tables (they create empty flows!)
|
|
697
|
-
|
|
698
|
-
💡 **Why Enhanced XML-First v2.0?**
|
|
699
|
-
- Fixes ALL critical issues from beta testing
|
|
700
|
-
- Flows deploy with 100% of requested features working
|
|
701
|
-
- Complete metadata always returned (no more null sys_id)
|
|
702
|
-
- Tool names resolve correctly across all MCP providers
|
|
703
|
-
- Zero chance of empty flows or missing features!
|
|
664
|
+
🎯 **What this does automatically:**
|
|
665
|
+
- ✅ Generates proper flow structure with all components
|
|
666
|
+
- ✅ Uses correct ServiceNow tables and relationships
|
|
667
|
+
- ✅ Deploys directly to your ServiceNow instance
|
|
668
|
+
- ✅ Returns complete metadata (sys_id, URLs, endpoints)
|
|
669
|
+
- ✅ Includes all requested features and logic
|
|
704
670
|
|
|
705
671
|
` : ''}
|
|
706
|
-
- **Recommended Team**: ${getTeamRecommendation(taskAnalysis.taskType)}
|
|
707
672
|
|
|
708
673
|
## 📊 Table Discovery Intelligence
|
|
709
674
|
|
|
@@ -745,165 +710,53 @@ for (let i = 0; i < 5000; i += 100) {
|
|
|
745
710
|
}
|
|
746
711
|
\`\`\`
|
|
747
712
|
|
|
748
|
-
### 1.
|
|
749
|
-
**THIS MUST BE YOUR VERY FIRST ACTION
|
|
713
|
+
### 1. Initialize Memory & Session (Required First Step)
|
|
714
|
+
**THIS MUST BE YOUR VERY FIRST ACTION:**
|
|
750
715
|
\`\`\`javascript
|
|
751
|
-
//
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
parallel_execution: ${options.parallel ? 'true' : 'false'},
|
|
765
|
-
monitoring_enabled: ${options.monitor ? 'true' : 'false'},
|
|
766
|
-
auth_required: ${!isAuthenticated}
|
|
767
|
-
}
|
|
768
|
-
}),
|
|
769
|
-
namespace: "swarm_${sessionId}"
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
// Agent coordination namespace handled automatically by ServiceNow memory system
|
|
716
|
+
// Initialize swarm memory session
|
|
717
|
+
Memory.store("swarm_session_${sessionId}", JSON.stringify({
|
|
718
|
+
objective: "${objective}",
|
|
719
|
+
status: "initializing",
|
|
720
|
+
started_at: new Date().toISOString(),
|
|
721
|
+
task_analysis: ${JSON.stringify(taskAnalysis, null, 2)},
|
|
722
|
+
configuration: {
|
|
723
|
+
strategy: "${options.strategy}",
|
|
724
|
+
mode: "${options.mode}",
|
|
725
|
+
max_agents: ${parseInt(options.maxAgents)},
|
|
726
|
+
authenticated: ${isAuthenticated}
|
|
727
|
+
}
|
|
728
|
+
}));
|
|
773
729
|
\`\`\`
|
|
774
730
|
|
|
775
|
-
### 2.
|
|
776
|
-
**Execute these steps IN ORDER
|
|
731
|
+
### 2. Validate ServiceNow Connection
|
|
732
|
+
**Execute these steps IN ORDER:**
|
|
777
733
|
|
|
778
734
|
\`\`\`javascript
|
|
779
|
-
// Step 2.1:
|
|
780
|
-
const authCheck = await
|
|
781
|
-
|
|
782
|
-
include_performance: false
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
if (!authCheck.connection_status === "success") {
|
|
735
|
+
// Step 2.1: Test ServiceNow authentication
|
|
736
|
+
const authCheck = await snow_auth_diagnostics();
|
|
737
|
+
if (!authCheck.success) {
|
|
786
738
|
throw new Error("Authentication failed! Run: snow-flow auth login");
|
|
787
739
|
}
|
|
788
740
|
|
|
789
|
-
// Step 2.2:
|
|
790
|
-
const existingArtifacts = await mcp__servicenow-intelligent__snow_comprehensive_search({
|
|
791
|
-
query: "${objective}",
|
|
792
|
-
include_inactive: false
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
// Store discovery results in memory for agents
|
|
796
|
-
await mcp__snow-flow__memory_usage({
|
|
797
|
-
key: "existing_artifacts_${sessionId}",
|
|
798
|
-
value: JSON.stringify(existingArtifacts),
|
|
799
|
-
namespace: "swarm_${sessionId}"
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
// Step 2.3: Create isolated Update Set for this objective
|
|
741
|
+
// Step 2.2: Create Update Set for tracking changes
|
|
803
742
|
const updateSetName = "Snow-Flow: ${objective.substring(0, 50)}... - ${new Date().toISOString().split('T')[0]}";
|
|
804
|
-
const updateSet = await
|
|
743
|
+
const updateSet = await snow_update_set_create({
|
|
805
744
|
name: updateSetName,
|
|
806
745
|
description: "Automated creation for: ${objective}\\n\\nSession: ${sessionId}",
|
|
807
746
|
auto_switch: true
|
|
808
747
|
});
|
|
809
748
|
|
|
810
749
|
// Store Update Set info in memory
|
|
811
|
-
|
|
812
|
-
key: "update_set_${sessionId}",
|
|
813
|
-
value: JSON.stringify(updateSet),
|
|
814
|
-
namespace: "swarm_${sessionId}"
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
// Step 2.4: Discover tables mentioned in objective
|
|
818
|
-
// Extract potential table names from the objective
|
|
819
|
-
const tablePatterns = [
|
|
820
|
-
/\b(incident|problem|change_request|sc_request|sc_req_item|task|cmdb_ci|sys_user|sys_user_group)\b/gi,
|
|
821
|
-
/\b(u_\w+)\b/g, // Custom tables starting with u_
|
|
822
|
-
/\b(\w+_table)\b/gi, // Tables ending with _table
|
|
823
|
-
/\bfrom\s+(\w+)\b/gi, // SQL-like "from table_name"
|
|
824
|
-
/\btable[:\s]+(\w+)\b/gi, // "table: xyz" or "table xyz"
|
|
825
|
-
/\b(\w+)\s+records?\b/gi, // "xyz records"
|
|
826
|
-
];
|
|
827
|
-
|
|
828
|
-
const detectedTables = new Set();
|
|
829
|
-
// Always include common tables for context
|
|
830
|
-
['incident', 'sc_request', 'sys_user'].forEach(t => detectedTables.add(t));
|
|
831
|
-
|
|
832
|
-
// Search for tables in objective
|
|
833
|
-
for (const pattern of tablePatterns) {
|
|
834
|
-
const matches = "${objective}".matchAll(pattern);
|
|
835
|
-
for (const match of matches) {
|
|
836
|
-
if (match[1]) {
|
|
837
|
-
detectedTables.add(match[1].toLowerCase());
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// Also check for common data needs based on objective type
|
|
843
|
-
if ("${objective}".toLowerCase().includes('catalog')) {
|
|
844
|
-
detectedTables.add('sc_cat_item');
|
|
845
|
-
detectedTables.add('sc_category');
|
|
846
|
-
}
|
|
847
|
-
if ("${objective}".toLowerCase().includes('user')) {
|
|
848
|
-
detectedTables.add('sys_user');
|
|
849
|
-
detectedTables.add('sys_user_group');
|
|
850
|
-
}
|
|
851
|
-
if ("${objective}".toLowerCase().includes('cmdb') || "${objective}".toLowerCase().includes('asset')) {
|
|
852
|
-
detectedTables.add('cmdb_ci');
|
|
853
|
-
}
|
|
854
|
-
if ("${objective}".toLowerCase().includes('knowledge')) {
|
|
855
|
-
detectedTables.add('kb_knowledge');
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
cliLogger.info(\`🔍 Detected tables to discover: \${Array.from(detectedTables).join(', ')}\`);
|
|
859
|
-
|
|
860
|
-
// Discover schemas for all detected tables
|
|
861
|
-
const tableSchemas = {};
|
|
862
|
-
for (const tableName of detectedTables) {
|
|
863
|
-
try {
|
|
864
|
-
const schema = await mcp__servicenow-platform-development__snow_table_schema_discovery({
|
|
865
|
-
tableName: tableName,
|
|
866
|
-
includeRelated: true,
|
|
867
|
-
includeIndexes: false,
|
|
868
|
-
maxDepth: 1 // Don't go too deep to avoid timeout
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
if (schema && schema.fields) {
|
|
872
|
-
tableSchemas[tableName] = {
|
|
873
|
-
name: tableName,
|
|
874
|
-
label: schema.label || tableName,
|
|
875
|
-
fields: schema.fields,
|
|
876
|
-
field_count: schema.fields.length,
|
|
877
|
-
key_fields: schema.fields.filter(f => f.primary || f.reference).map(f => f.name)
|
|
878
|
-
};
|
|
879
|
-
cliLogger.info(\`✅ Discovered table '\${tableName}' with \${schema.fields.length} fields\`);
|
|
880
|
-
}
|
|
881
|
-
} catch (e) {
|
|
882
|
-
cliLogger.warn(\`⚠️ Table '\${tableName}' not found or inaccessible\`);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
// Store discovered table schemas in memory
|
|
887
|
-
await mcp__snow-flow__memory_usage({
|
|
888
|
-
action: "store",
|
|
889
|
-
key: "table_schemas_${sessionId}",
|
|
890
|
-
value: JSON.stringify({
|
|
891
|
-
discovered_at: new Date().toISOString(),
|
|
892
|
-
objective: "${objective}",
|
|
893
|
-
tables: tableSchemas,
|
|
894
|
-
table_names: Object.keys(tableSchemas)
|
|
895
|
-
}),
|
|
896
|
-
namespace: "swarm_${sessionId}"
|
|
897
|
-
});
|
|
750
|
+
Memory.store("update_set_${sessionId}", JSON.stringify(updateSet));
|
|
898
751
|
\`\`\`
|
|
899
752
|
|
|
900
753
|
### 3. Create Master Task List
|
|
901
|
-
After completing
|
|
754
|
+
After completing setup steps, create task breakdown:
|
|
902
755
|
\`\`\`javascript
|
|
903
756
|
TodoWrite([
|
|
904
757
|
{
|
|
905
|
-
id: "
|
|
906
|
-
content: "✅
|
|
758
|
+
id: "setup_complete",
|
|
759
|
+
content: "✅ Setup: Auth, Update Set, Memory initialized",
|
|
907
760
|
status: "completed",
|
|
908
761
|
priority: "high"
|
|
909
762
|
},
|
|
@@ -934,39 +787,38 @@ TodoWrite([
|
|
|
934
787
|
]);
|
|
935
788
|
\`\`\`
|
|
936
789
|
|
|
937
|
-
### 4.
|
|
938
|
-
|
|
939
|
-
⚡ **CRITICAL: Spawn agents in SMART BATCHES based on dependencies!**
|
|
940
|
-
|
|
941
|
-
Based on the task analysis, we need to spawn ${taskAnalysis.estimatedAgentCount} agents.
|
|
790
|
+
### 4. Agent Spawning Strategy
|
|
791
|
+
Based on the task analysis, spawn ${taskAnalysis.estimatedAgentCount} agents in smart batches:
|
|
942
792
|
|
|
943
|
-
|
|
793
|
+
**Agent Spawn Order:**
|
|
794
|
+
1. **Primary Agent**: Spawn ${taskAnalysis.primaryAgent} first
|
|
795
|
+
2. **Supporting Agents**: Spawn ${taskAnalysis.supportingAgents.join(', ')} after primary is established
|
|
796
|
+
3. **Use Task tool**: \`Task("agent description", "agent prompt")\` for each agent
|
|
944
797
|
|
|
945
798
|
### 5. Memory Coordination Pattern
|
|
946
|
-
All agents MUST use this memory coordination
|
|
799
|
+
All agents MUST use this simple memory coordination:
|
|
947
800
|
|
|
948
801
|
\`\`\`javascript
|
|
949
802
|
// Agent initialization
|
|
950
|
-
const session = Memory.get("swarm_session_${sessionId}");
|
|
951
803
|
const agentId = \`agent_\${agentType}_${sessionId}\`;
|
|
952
804
|
|
|
953
805
|
// Agent stores progress
|
|
954
|
-
Memory.store(\`\${agentId}_progress\`, {
|
|
806
|
+
Memory.store(\`\${agentId}_progress\`, JSON.stringify({
|
|
955
807
|
status: "working",
|
|
956
808
|
current_task: "description of current work",
|
|
957
809
|
completion_percentage: 45,
|
|
958
810
|
last_update: new Date().toISOString()
|
|
959
|
-
});
|
|
811
|
+
}));
|
|
960
812
|
|
|
961
|
-
// Agent reads other agent's work
|
|
813
|
+
// Agent reads other agent's work when needed
|
|
962
814
|
const primaryWork = Memory.get("agent_${taskAnalysis.primaryAgent}_output");
|
|
963
815
|
|
|
964
816
|
// Agent signals completion
|
|
965
|
-
Memory.store(\`\${agentId}_complete\`, {
|
|
817
|
+
Memory.store(\`\${agentId}_complete\`, JSON.stringify({
|
|
966
818
|
completed_at: new Date().toISOString(),
|
|
967
819
|
outputs: { /* agent deliverables */ },
|
|
968
820
|
artifacts_created: [ /* list of created artifacts */ ]
|
|
969
|
-
});
|
|
821
|
+
}));
|
|
970
822
|
\`\`\`
|
|
971
823
|
|
|
972
824
|
## 🧠 Intelligent Features Configuration
|
|
@@ -986,386 +838,75 @@ ${hasIntelligentFeatures ? `✅ **INTELLIGENT MODE ACTIVE** - The following feat
|
|
|
986
838
|
|
|
987
839
|
**CRITICAL RULE**: All agents MUST attempt to use ServiceNow MCP tools first, regardless of authentication status.
|
|
988
840
|
|
|
989
|
-
|
|
990
|
-
Use the unified orchestration tool for complete automation:
|
|
991
|
-
|
|
992
|
-
\`\`\`javascript
|
|
993
|
-
// Queen Agent uses this for intelligent orchestration
|
|
994
|
-
snow_orchestrate_development({
|
|
995
|
-
objective: "${objective}",
|
|
996
|
-
auto_permissions: ${options.autoPermissions},
|
|
997
|
-
smart_discovery: ${options.smartDiscovery},
|
|
998
|
-
live_testing: ${options.liveTesting},
|
|
999
|
-
auto_deploy: ${options.autoDeploy},
|
|
1000
|
-
auto_rollback: ${options.autoRollback},
|
|
1001
|
-
shared_memory: ${options.sharedMemory},
|
|
1002
|
-
progress_monitoring: ${options.progressMonitoring}
|
|
1003
|
-
});
|
|
1004
|
-
\`\`\`
|
|
1005
|
-
|
|
1006
|
-
## 🧠 REVOLUTIONARY: Intelligent Gap Analysis Engine (v1.1.88)
|
|
1007
|
-
**AUTOMATIC BEYOND-MCP CONFIGURATION DETECTION**
|
|
1008
|
-
|
|
1009
|
-
The Queen Agent now includes the revolutionary **Intelligent Gap Analysis Engine** that automatically detects and resolves ALL ServiceNow configurations needed beyond standard MCP tools.
|
|
1010
|
-
|
|
1011
|
-
**What Gap Analysis Does:**
|
|
1012
|
-
- **🔍 Analyzes Requirements**: AI-powered parsing of objectives to identify 60+ types of ServiceNow configurations
|
|
1013
|
-
- **📊 MCP Coverage Analysis**: Maps what current MCP tools can handle vs manual setup requirements
|
|
1014
|
-
- **🤖 Auto-Resolution Engine**: Attempts automatic configuration via ServiceNow APIs for safe operations
|
|
1015
|
-
- **📚 Manual Guide Generation**: Creates detailed step-by-step guides with role requirements and risk assessment
|
|
1016
|
-
- **🛡️ Risk Assessment**: Evaluates complexity and safety of each configuration
|
|
1017
|
-
- **🌍 Environment Awareness**: Provides dev/test/prod specific guidance and warnings
|
|
1018
|
-
|
|
1019
|
-
**60+ Configuration Types Covered:**
|
|
1020
|
-
- **🔐 Authentication**: LDAP, SAML, OAuth providers, SSO, MFA configurations
|
|
1021
|
-
- **🗄️ Database**: Indexes, views, partitioning, performance analytics, system properties
|
|
1022
|
-
- **🧭 Navigation**: Application menus, modules, form layouts, UI actions, policies
|
|
1023
|
-
- **📧 Integration**: Email templates, web services, import sets, transform maps
|
|
1024
|
-
- **🔄 Workflow**: Activities, transitions, SLA definitions, escalation rules
|
|
1025
|
-
- **🛡️ Security**: ACL rules, data policies, audit rules, compliance configurations
|
|
1026
|
-
- **📊 Reporting**: Custom reports, dashboards, KPIs, performance analytics
|
|
1027
|
-
|
|
1028
|
-
**Example Output:**
|
|
1029
|
-
\`\`\`
|
|
1030
|
-
🧠 Step 4: Running Intelligent Gap Analysis...
|
|
1031
|
-
📊 Gap Analysis Complete:
|
|
1032
|
-
• Total Requirements: 12
|
|
1033
|
-
• MCP Coverage: 67%
|
|
1034
|
-
• Automated: 6 configurations
|
|
1035
|
-
• Manual Work: 4 items
|
|
1036
|
-
|
|
1037
|
-
✅ Automatically Configured:
|
|
1038
|
-
• System property: glide.ui.incident_management created
|
|
1039
|
-
• Navigation module: Incident Management added to Service Desk
|
|
1040
|
-
• Email template: incident_notification configured
|
|
1041
|
-
• Database index: incident.priority_state for performance
|
|
1042
|
-
|
|
1043
|
-
📋 Manual Configuration Required:
|
|
1044
|
-
• LDAP authentication setup (high-risk operation)
|
|
1045
|
-
• SSO configuration with Active Directory
|
|
1046
|
-
|
|
1047
|
-
📚 Detailed Manual Guides Available:
|
|
1048
|
-
📖 Configure LDAP Authentication - 25 minutes
|
|
1049
|
-
Risk: high | Roles: security_admin, admin
|
|
1050
|
-
\`\`\`
|
|
1051
|
-
|
|
1052
|
-
**The Gap Analysis Engine automatically runs as part of Queen Agent execution - no additional commands needed!**
|
|
1053
|
-
|
|
1054
|
-
` : ''}
|
|
1055
|
-
|
|
1056
|
-
#### ServiceNow MCP Tools (ALWAYS TRY THESE FIRST!)
|
|
841
|
+
#### Current MCP Tools Available (Snow-Flow v3.3.4)
|
|
1057
842
|
${isAuthenticated ? '✅ Authentication detected - full deployment capabilities' : '⚠️ No authentication detected - MCP tools will provide specific instructions if auth needed'}
|
|
1058
843
|
|
|
1059
844
|
Your agents MUST use these MCP tools IN THIS ORDER:
|
|
1060
845
|
|
|
1061
846
|
🔍 **PRE-FLIGHT CHECKS** (Always do first!):
|
|
1062
|
-
1. \`
|
|
847
|
+
1. \`snow_auth_diagnostics\` - Test authentication and permissions
|
|
1063
848
|
2. If auth fails, the tool provides specific instructions
|
|
1064
849
|
3. Continue with appropriate strategy based on auth status
|
|
1065
850
|
|
|
1066
|
-
🎯 **
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
- **Full content**: \`{table: "change_request", include_content: true}\` → When all data needed
|
|
1072
|
-
- Works with ANY table: incident, sc_request, problem, cmdb_ci, even u_custom_tables!
|
|
1073
|
-
|
|
1074
|
-
📦 **CORE DEVELOPMENT TOOLS**:
|
|
1075
|
-
1. **Deployment Tools** (servicenow-deployment-mcp)
|
|
1076
|
-
- \`snow_deploy\` - Unified deployment for all artifact types
|
|
1077
|
-
- \`snow_preview_widget\` - Preview widgets before deployment
|
|
1078
|
-
- \`snow_widget_test\` - Test widget functionality
|
|
1079
|
-
|
|
1080
|
-
2. **Discovery Tools** (servicenow-intelligent-mcp)
|
|
1081
|
-
- \`snow_find_artifact\` - Natural language artifact search
|
|
1082
|
-
- \`snow_catalog_item_search\` - Find catalog items with fuzzy matching
|
|
1083
|
-
- \`snow_get_by_sysid\` - Direct sys_id lookup
|
|
1084
|
-
|
|
1085
|
-
3. **Update Set Management** (servicenow-update-set-mcp)
|
|
1086
|
-
- \`snow_update_set_create\` - Create new update sets
|
|
1087
|
-
- \`snow_update_set_add_artifact\` - Track artifacts
|
|
1088
|
-
- \`snow_update_set_complete\` - Complete update sets
|
|
1089
|
-
|
|
1090
|
-
🚀 **14 ADVANCED SERVICENOW INTELLIGENCE TOOLS** - NEW v1.4.9!
|
|
1091
|
-
|
|
1092
|
-
**Performance & Optimization (Features 1-4)**:
|
|
1093
|
-
4. **Smart Batch API Operations** (\`snow_batch_api\`)
|
|
1094
|
-
- 80% API call reduction through intelligent batching
|
|
1095
|
-
- Parallel execution with transaction support
|
|
1096
|
-
- Query optimization and result caching
|
|
1097
|
-
- Real-time performance monitoring
|
|
1098
|
-
|
|
1099
|
-
5. **Table Relationship Mapping** (\`snow_get_table_relationships\`)
|
|
1100
|
-
- Deep relationship discovery across table hierarchies
|
|
1101
|
-
- Visual relationship diagrams (Mermaid format)
|
|
1102
|
-
- Impact analysis for schema changes
|
|
1103
|
-
- Performance optimization recommendations
|
|
1104
|
-
|
|
1105
|
-
6. **Query Performance Analyzer** (\`snow_analyze_query\`)
|
|
1106
|
-
- Query execution analysis with bottleneck detection
|
|
1107
|
-
- Index recommendations for performance optimization
|
|
1108
|
-
- Alternative query suggestions with risk assessment
|
|
1109
|
-
- Execution time prediction
|
|
1110
|
-
|
|
1111
|
-
7. **Field Usage Intelligence** (\`snow_analyze_field_usage\`)
|
|
1112
|
-
- Comprehensive field usage analysis across all ServiceNow components
|
|
1113
|
-
- Unused field detection with deprecation recommendations
|
|
1114
|
-
- Technical debt scoring and optimization opportunities
|
|
1115
|
-
- Cross-component impact analysis
|
|
1116
|
-
|
|
1117
|
-
**Migration & Architecture (Features 5-7)**:
|
|
1118
|
-
8. **Migration Helper** (\`snow_create_migration_plan\`)
|
|
1119
|
-
- Automated migration planning with risk assessment
|
|
1120
|
-
- Data transformation scripts generation
|
|
1121
|
-
- Performance impact estimation and rollback strategy creation
|
|
1122
|
-
|
|
1123
|
-
9. **Deep Table Analysis** (\`snow_analyze_table_deep\`)
|
|
1124
|
-
- Multi-dimensional table analysis (structure, data quality, performance)
|
|
1125
|
-
- Security and compliance assessment
|
|
1126
|
-
- Usage pattern analysis and optimization recommendations
|
|
1127
|
-
|
|
1128
|
-
10. **Code Pattern Detector** (\`snow_detect_code_patterns\`)
|
|
1129
|
-
- Advanced pattern recognition across all script types
|
|
1130
|
-
- Performance anti-pattern detection and security vulnerability scanning
|
|
1131
|
-
- Maintainability scoring with refactoring suggestions
|
|
1132
|
-
|
|
1133
|
-
**AI-Powered Intelligence (Features 8-10)**:
|
|
1134
|
-
11. **Predictive Impact Analysis** (\`snow_predict_change_impact\`)
|
|
1135
|
-
- AI-powered change impact prediction with confidence scoring
|
|
1136
|
-
- Risk assessment and dependency chain analysis
|
|
1137
|
-
- Rollback requirement prediction
|
|
1138
|
-
|
|
1139
|
-
12. **Auto Documentation Generator** (\`snow_generate_documentation\`)
|
|
1140
|
-
- Intelligent documentation generation from code and configuration
|
|
1141
|
-
- Multiple output formats (Markdown, HTML, PDF)
|
|
1142
|
-
- Relationship diagrams and architecture documentation
|
|
1143
|
-
|
|
1144
|
-
13. **Intelligent Refactoring** (\`snow_refactor_code\`)
|
|
1145
|
-
- AI-driven code refactoring with performance optimization
|
|
1146
|
-
- Modern JavaScript patterns and best practices
|
|
1147
|
-
- Security hardening and error handling improvements
|
|
1148
|
-
|
|
1149
|
-
**Process Mining & Workflow (Features 11-14)**:
|
|
1150
|
-
14. **Process Mining Engine** (\`snow_discover_process\`)
|
|
1151
|
-
- Real process discovery from ServiceNow event logs
|
|
1152
|
-
- Process variant analysis and bottleneck identification
|
|
1153
|
-
- Compliance checking with ROI calculation
|
|
1154
|
-
|
|
1155
|
-
15. **Workflow Reality Analyzer** (\`snow_analyze_workflow_execution\`)
|
|
1156
|
-
- Real workflow execution analysis vs. designed processes
|
|
1157
|
-
- Performance bottleneck identification and SLA compliance monitoring
|
|
1158
|
-
|
|
1159
|
-
16. **Cross Table Process Discovery** (\`snow_discover_cross_table_process\`)
|
|
1160
|
-
- Multi-table process flow discovery
|
|
1161
|
-
- Data lineage and transformation tracking
|
|
1162
|
-
- Integration point analysis
|
|
1163
|
-
|
|
1164
|
-
17. **Real Time Process Monitoring** (\`snow_monitor_process\`)
|
|
1165
|
-
- Live process monitoring with real-time alerts
|
|
1166
|
-
- Anomaly detection using machine learning
|
|
1167
|
-
- Performance trend analysis and predictive failure detection
|
|
1168
|
-
|
|
1169
|
-
🧠 **MACHINE LEARNING & NEURAL NETWORKS (Features 18-25)**:
|
|
1170
|
-
18. **Incident Classification Neural Network** (\`ml_train_incident_classifier\`)
|
|
1171
|
-
- Train LSTM neural networks on historical incident data
|
|
1172
|
-
- 95%+ accuracy for category, priority, and assignment prediction
|
|
1173
|
-
- Text embedding and multi-class classification
|
|
1174
|
-
|
|
1175
|
-
19. **Incident Classification** (\`ml_classify_incident\`)
|
|
1176
|
-
- Use trained neural network to classify incidents
|
|
1177
|
-
- Real-time predictions with confidence scores
|
|
1178
|
-
- Top-3 category recommendations
|
|
1179
|
-
|
|
1180
|
-
20. **Change Risk Prediction** (\`ml_train_change_risk\`)
|
|
1181
|
-
- Train neural networks for change risk assessment
|
|
1182
|
-
- Analyze historical success/failure patterns
|
|
1183
|
-
- Feature importance analysis
|
|
1184
|
-
|
|
1185
|
-
21. **Risk Prediction** (\`ml_predict_change_risk\`)
|
|
1186
|
-
- Predict implementation risk for changes
|
|
1187
|
-
- Confidence scoring and recommendations
|
|
1188
|
-
- Identify high-risk changes before deployment
|
|
1189
|
-
|
|
1190
|
-
22. **Incident Volume Forecasting** (\`ml_forecast_incidents\`)
|
|
1191
|
-
- LSTM time series forecasting
|
|
1192
|
-
- Predict daily/weekly incident volumes
|
|
1193
|
-
- Category-specific predictions
|
|
1194
|
-
|
|
1195
|
-
23. **Anomaly Detection** (\`ml_train_anomaly_detector\`)
|
|
1196
|
-
- Autoencoder neural networks for anomaly detection
|
|
1197
|
-
- Detect unusual patterns in metrics
|
|
1198
|
-
- 95th percentile threshold calculation
|
|
1199
|
-
|
|
1200
|
-
24. **Detect Anomalies** (\`ml_detect_anomalies\`)
|
|
1201
|
-
- Real-time anomaly detection
|
|
1202
|
-
- Pattern deviation analysis
|
|
1203
|
-
- Alert on potential issues
|
|
1204
|
-
|
|
1205
|
-
25. **ML Model Status** (\`ml_model_status\`)
|
|
1206
|
-
- Check trained model availability
|
|
1207
|
-
- Model performance metrics
|
|
1208
|
-
- TensorFlow.js backend info
|
|
1209
|
-
|
|
1210
|
-
⚠️ **ML LICENSING REQUIREMENTS**:
|
|
1211
|
-
- **Performance Analytics (PA)**: Required for KPI forecasting and analytics
|
|
1212
|
-
- **Predictive Intelligence (PI)**: Required for clustering and similarity
|
|
1213
|
-
- **Custom Neural Networks**: Always available via TensorFlow.js
|
|
1214
|
-
- **No Mock Data**: Real errors when licenses unavailable
|
|
1215
|
-
|
|
1216
|
-
🎯 **WHEN TO USE WHICH ML APPROACH**:
|
|
1217
|
-
|
|
1218
|
-
**PREFERRED: ServiceNow Native ML (BEST RESULTS but requires licenses):**
|
|
1219
|
-
- 🏆 **Predictive Intelligence (PI)**:
|
|
1220
|
-
- Incident classification & categorization
|
|
1221
|
-
- Similar incident matching
|
|
1222
|
-
- Change risk prediction
|
|
1223
|
-
- Solution recommendations
|
|
1224
|
-
- Knowledge article suggestions
|
|
1225
|
-
- 🏆 **Performance Analytics (PA)**:
|
|
1226
|
-
- KPI forecasting
|
|
1227
|
-
- Trend analysis
|
|
1228
|
-
- Anomaly detection in metrics
|
|
1229
|
-
- 🏆 **Agent Intelligence**:
|
|
1230
|
-
- Intelligent work assignment
|
|
1231
|
-
- Workload balancing
|
|
1232
|
-
|
|
1233
|
-
**FALLBACK: TensorFlow.js Neural Networks (NO LICENSE REQUIRED):**
|
|
1234
|
-
- ✅ Use when PI/PA not available
|
|
1235
|
-
- ✅ Custom pattern recognition
|
|
1236
|
-
- ✅ Time series forecasting (if PA not available)
|
|
1237
|
-
- ✅ Basic incident classification (if PI not available)
|
|
1238
|
-
- ✅ Change risk prediction (if PI not available)
|
|
1239
|
-
- ✅ Anomaly detection (if PA not available)
|
|
1240
|
-
|
|
1241
|
-
**BEST PRACTICE - Try in this order:**
|
|
1242
|
-
1. **First**: Check if PI/PA available with ml_performance_analytics or ml_predictive_intelligence
|
|
1243
|
-
2. **If available**: Use native ML for superior results (95%+ accuracy)
|
|
1244
|
-
3. **If not available**: Fall back to TensorFlow.js (80-85% accuracy)
|
|
1245
|
-
4. **Optimal**: Use ml_hybrid_recommendation to combine both when possible
|
|
1246
|
-
|
|
1247
|
-
**AGENT INSTRUCTIONS**: Always check for PI/PA first - they give MUCH better results for ServiceNow data!
|
|
1248
|
-
|
|
1249
|
-
📋 **ML DECISION TREE - WHICH TOOL TO USE**:
|
|
1250
|
-
\`\`\`
|
|
1251
|
-
Is it a standard ServiceNow object? (incident/change/problem/request)
|
|
1252
|
-
└─ YES → Do you have PI/PA license?
|
|
1253
|
-
└─ YES → Use Native ML (best choice: 95%+ accuracy)
|
|
1254
|
-
└─ NO → Use TensorFlow.js (fallback: 80-85% accuracy)
|
|
1255
|
-
└─ NO → Is it custom data/table (u_*)?
|
|
1256
|
-
└─ YES → ONLY TensorFlow.js works!
|
|
1257
|
-
|
|
1258
|
-
Does it need to run in browser? (real-time, instant feedback)
|
|
1259
|
-
└─ YES → ONLY TensorFlow.js works! (client-side ML)
|
|
1260
|
-
|
|
1261
|
-
Is it privacy-sensitive data? (HR, salary, personal)
|
|
1262
|
-
└─ YES → TensorFlow.js (keeps data local)
|
|
1263
|
-
|
|
1264
|
-
Must work offline? (mobile, disconnected)
|
|
1265
|
-
└─ YES → TensorFlow.js with local model storage
|
|
1266
|
-
|
|
1267
|
-
Need custom patterns not in ServiceNow ML?
|
|
1268
|
-
└─ YES → TensorFlow.js for custom neural networks
|
|
1269
|
-
\`\`\`
|
|
1270
|
-
|
|
1271
|
-
**UNIQUE TENSORFLOW.JS USE CASES**:
|
|
1272
|
-
- 🌐 Client-side predictions in Service Portal widgets
|
|
1273
|
-
- 🏢 ML for custom tables (u_employee_performance, u_vendor_rating, etc.)
|
|
1274
|
-
- ⚡ Real-time form validation and anomaly detection
|
|
1275
|
-
- 📵 Offline mobile app predictions
|
|
1276
|
-
- 🔒 Privacy-sensitive calculations that stay in browser
|
|
1277
|
-
- 🎯 Custom pattern recognition beyond standard ServiceNow objects
|
|
1278
|
-
|
|
1279
|
-
💯 **ZERO MOCK DATA GUARANTEE**: All tools use 100% real ServiceNow APIs - no fake data, ever!
|
|
1280
|
-
|
|
1281
|
-
📊 **PERFORMANCE METRICS & BENEFITS**:
|
|
1282
|
-
- **80% API Call Reduction** through intelligent batching and optimization
|
|
1283
|
-
- **60% Faster Analysis** with parallel processing and caching
|
|
1284
|
-
- **90% Task Automation** of manual ServiceNow analysis workflows
|
|
1285
|
-
- **100% Real Data** accuracy - no mocks, placeholders, or demo data
|
|
1286
|
-
- **Zero Configuration** - works with any ServiceNow instance
|
|
1287
|
-
|
|
1288
|
-
🎯 **USAGE EXAMPLES FOR AGENTS**:
|
|
1289
|
-
|
|
1290
|
-
**Performance Analysis:**
|
|
1291
|
-
\`\`\`javascript
|
|
1292
|
-
// Analyze incident table performance issues
|
|
1293
|
-
await snow_analyze_table_deep({
|
|
1294
|
-
table_name: "incident",
|
|
1295
|
-
analysis_scope: ["structure", "data_quality", "performance"],
|
|
1296
|
-
generate_recommendations: true
|
|
1297
|
-
});
|
|
1298
|
-
|
|
1299
|
-
// Optimize frequently used queries
|
|
1300
|
-
await snow_analyze_query({
|
|
1301
|
-
query: "state=1^priority<=2",
|
|
1302
|
-
table: "incident",
|
|
1303
|
-
analyze_indexes: true,
|
|
1304
|
-
suggest_optimizations: true
|
|
1305
|
-
});
|
|
1306
|
-
\`\`\`
|
|
851
|
+
🎯 **Core Development Tools**:
|
|
852
|
+
1. **Universal Query Tool**: \`snow_query_table\` - Works with ALL ServiceNow tables
|
|
853
|
+
- Count-only: \`{table: "incident", query: "state!=7"}\` → Memory efficient
|
|
854
|
+
- Specific fields: \`{table: "sc_request", fields: ["number", "state"]}\` → Only needed data
|
|
855
|
+
- Full content: \`{table: "change_request", include_content: true}\` → When all data needed
|
|
1307
856
|
|
|
1308
|
-
**
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
await snow_batch_api({
|
|
1312
|
-
operations: [
|
|
1313
|
-
{operation: "query", table: "incident", query: "state=1"},
|
|
1314
|
-
{operation: "update", table: "incident", sys_id: "xxx", data: {urgency: "1"}}
|
|
1315
|
-
],
|
|
1316
|
-
parallel: true,
|
|
1317
|
-
transactional: true
|
|
1318
|
-
});
|
|
1319
|
-
\`\`\`
|
|
857
|
+
2. **Deployment Tools**:
|
|
858
|
+
- \`snow_deploy\` - Universal deployment for NEW artifacts (16+ types supported!)
|
|
859
|
+
- \`snow_update\` - Update EXISTING artifacts by name or sys_id
|
|
1320
860
|
|
|
1321
|
-
**
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
await snow_discover_process({
|
|
1325
|
-
process_type: "incident_management",
|
|
1326
|
-
analysis_period: "30d",
|
|
1327
|
-
include_variants: true
|
|
1328
|
-
});
|
|
861
|
+
3. **Discovery Tools**:
|
|
862
|
+
- \`snow_discover_table_fields\` - Get exact field names and types
|
|
863
|
+
- \`snow_table_schema_discovery\` - Complete table structure
|
|
1329
864
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
865
|
+
4. **Update Set Management**:
|
|
866
|
+
- \`snow_update_set_create\` - Create new update sets
|
|
867
|
+
- \`snow_update_set_add_comment\` - Track progress
|
|
868
|
+
- \`snow_update_set_retrieve\` - Get update set XML
|
|
869
|
+
|
|
870
|
+
## 🔧 NEW: Expanded Artifact Support (v3.3.4)
|
|
871
|
+
|
|
872
|
+
Snow-Flow now supports **16+ different ServiceNow artifact types**:
|
|
873
|
+
|
|
874
|
+
| Type | Table | Deploy | Update | Natural Language |
|
|
875
|
+
|------|-------|--------|---------|------------------|
|
|
876
|
+
| widget | sp_widget | ✅ | ✅ | ✅ |
|
|
877
|
+
| business_rule | sys_script | ✅ | ✅ | ✅ |
|
|
878
|
+
| script_include | sys_script_include | ✅ | ✅ | ✅ |
|
|
879
|
+
| ui_page | sys_ui_page | ✅ | ✅ | ✅ |
|
|
880
|
+
| client_script | sys_script_client | ✅ | ✅ | ✅ |
|
|
881
|
+
| ui_action | sys_ui_action | ✅ | ✅ | ✅ |
|
|
882
|
+
| ui_policy | sys_ui_policy | ✅ | ✅ | ✅ |
|
|
883
|
+
| acl | sys_security_acl | ✅ | ✅ | ✅ |
|
|
884
|
+
| table | sys_db_object | ✅ | ✅ | ✅ |
|
|
885
|
+
| field | sys_dictionary | ✅ | ✅ | ✅ |
|
|
886
|
+
| workflow | wf_workflow | ✅ | ✅ | ✅ |
|
|
887
|
+
| flow | sys_hub_flow | ✅ | ✅ | ✅ |
|
|
888
|
+
| notification | sysevent_email_action | ✅ | ✅ | ✅ |
|
|
889
|
+
| scheduled_job | sysauto_script | ✅ | ✅ | ✅ |
|
|
890
|
+
|
|
891
|
+
**Usage Examples:**
|
|
1339
892
|
\`\`\`javascript
|
|
1340
|
-
//
|
|
1341
|
-
await
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
893
|
+
// Deploy NEW artifacts
|
|
894
|
+
await snow_deploy({
|
|
895
|
+
type: 'business_rule',
|
|
896
|
+
name: 'Auto Assignment Rule',
|
|
897
|
+
table: 'incident',
|
|
898
|
+
when: 'before',
|
|
899
|
+
script: 'if (current.priority == "1") current.assigned_to = "admin";'
|
|
1346
900
|
});
|
|
1347
901
|
|
|
1348
|
-
//
|
|
1349
|
-
await
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
902
|
+
// Update EXISTING artifacts (natural language supported!)
|
|
903
|
+
await snow_update({
|
|
904
|
+
type: 'ui_action',
|
|
905
|
+
identifier: 'close_incident',
|
|
906
|
+
instruction: 'Change label to "Close with Resolution" and add validation'
|
|
1353
907
|
});
|
|
1354
908
|
\`\`\`
|
|
1355
909
|
|
|
1356
|
-
🚨 **ERROR RECOVERY PATTERNS**:
|
|
1357
|
-
- Auth Error → Document complete solution → Store in Memory → Guide user
|
|
1358
|
-
- Permission Error → Try global scope → Document if fails
|
|
1359
|
-
- Not Found → Create new → Track in Update Set
|
|
1360
|
-
- Any Error → Provide SPECIFIC next steps, not generic messages
|
|
1361
|
-
|
|
1362
|
-
⚠️ **403 DEPLOYMENT VERIFICATION BUG**:
|
|
1363
|
-
- **IMPORTANT**: 403 errors during deployment verification are often FALSE POSITIVES
|
|
1364
|
-
- Widget/artifact deployment usually SUCCEEDS even when verification API returns 403
|
|
1365
|
-
- **ALWAYS** check the ServiceNow instance directly before assuming failure
|
|
1366
|
-
- If you get 403 on verification, provide the sys_id and direct link to the artifact
|
|
1367
|
-
- Tell user: "Deployment likely succeeded despite 403 verification error. Check here: [direct link]"
|
|
1368
|
-
|
|
1369
910
|
${options.autoDeploy ? `
|
|
1370
911
|
#### ⚠️ AUTO-DEPLOYMENT ACTIVE ⚠️
|
|
1371
912
|
- Real artifacts will be created in ServiceNow
|
|
@@ -1377,6 +918,7 @@ ${options.autoDeploy ? `
|
|
|
1377
918
|
- Analysis and recommendations only
|
|
1378
919
|
- Use --auto-deploy to enable deployment
|
|
1379
920
|
`}
|
|
921
|
+
|
|
1380
922
|
${!isAuthenticated ? `### ❌ ServiceNow Integration Disabled
|
|
1381
923
|
|
|
1382
924
|
#### Planning Mode (Auth Required)
|
|
@@ -1391,109 +933,19 @@ Agents must ALWAYS try MCP tools first!` : ''}
|
|
|
1391
933
|
|
|
1392
934
|
## 👑 Queen Agent Coordination Instructions
|
|
1393
935
|
|
|
1394
|
-
###
|
|
1395
|
-
Implement continuous memory synchronization for real-time coordination:
|
|
1396
|
-
|
|
1397
|
-
\`\`\`javascript
|
|
1398
|
-
// Initialize coordination heartbeat (Snow-Flow pattern)
|
|
1399
|
-
const coordinationInterval = setInterval(async () => {
|
|
1400
|
-
// Sync agent states across namespace
|
|
1401
|
-
const agentStates = await mcp__snow-flow__memory_search({
|
|
1402
|
-
pattern: "agent_*_progress",
|
|
1403
|
-
namespace: "agents_${sessionId}",
|
|
1404
|
-
limit: 50
|
|
1405
|
-
});
|
|
1406
|
-
|
|
1407
|
-
// Update swarm coordination state with TTL for freshness
|
|
1408
|
-
await mcp__snow-flow__memory_usage({
|
|
1409
|
-
key: "swarm_coordination_${sessionId}",
|
|
1410
|
-
value: JSON.stringify({
|
|
1411
|
-
timestamp: new Date().toISOString(),
|
|
1412
|
-
active_agents: agentStates.length,
|
|
1413
|
-
completion_status: TodoRead().filter(t => t.status === 'completed').length,
|
|
1414
|
-
memory_sync: true,
|
|
1415
|
-
discovered_artifacts: agentStates.filter(s => s.includes("deployed")).length
|
|
1416
|
-
}),
|
|
1417
|
-
namespace: "swarm_${sessionId}",
|
|
1418
|
-
ttl: 300 // 5 minute TTL for coordination data
|
|
1419
|
-
});
|
|
1420
|
-
|
|
1421
|
-
// Detect and resolve conflicts between agents
|
|
1422
|
-
if (agentStates.some(s => s.includes("conflict") || s.includes("duplicate"))) {
|
|
1423
|
-
await mcp__snow-flow__memory_usage({
|
|
1424
|
-
key: "conflict_resolution_needed",
|
|
1425
|
-
value: JSON.stringify({
|
|
1426
|
-
agents: agentStates.filter(s => s.includes("conflict")),
|
|
1427
|
-
timestamp: new Date().toISOString()
|
|
1428
|
-
}),
|
|
1429
|
-
namespace: "swarm_${sessionId}"
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
// Track deployed artifacts in Update Set automatically
|
|
1434
|
-
const deployedArtifacts = [];
|
|
1435
|
-
for (const state of agentStates) {
|
|
1436
|
-
if (state.includes("deployed") && state.includes("sys_id")) {
|
|
1437
|
-
try {
|
|
1438
|
-
const artifact = JSON.parse(state);
|
|
1439
|
-
if (artifact.sys_id && !artifact.tracked_in_update_set) {
|
|
1440
|
-
deployedArtifacts.push(artifact);
|
|
1441
|
-
}
|
|
1442
|
-
} catch (e) {
|
|
1443
|
-
// Not valid JSON, skip
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
// Add all deployed artifacts to Update Set
|
|
1449
|
-
for (const artifact of deployedArtifacts) {
|
|
1450
|
-
await mcp__servicenow-update-set__snow_update_set_add_artifact({
|
|
1451
|
-
type: artifact.type,
|
|
1452
|
-
sys_id: artifact.sys_id,
|
|
1453
|
-
name: artifact.name
|
|
1454
|
-
});
|
|
1455
|
-
|
|
1456
|
-
// Mark as tracked
|
|
1457
|
-
artifact.tracked_in_update_set = true;
|
|
1458
|
-
await mcp__snow-flow__memory_usage({
|
|
1459
|
-
key: \`agent_\${artifact.agent}_deployed_\${artifact.sys_id}\`,
|
|
1460
|
-
value: JSON.stringify(artifact),
|
|
1461
|
-
namespace: "agents_${sessionId}"
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// Monitor individual agent progress
|
|
1466
|
-
const agents = [${[taskAnalysis.primaryAgent, ...taskAnalysis.supportingAgents].map(a => `"${a}"`).join(', ')}];
|
|
1467
|
-
for (const agent of agents) {
|
|
1468
|
-
const progress = agentStates.find(s => s.includes(\`agent_\${agent}_progress\`));
|
|
1469
|
-
cliLogger.info(\`Agent \${agent}: \${progress ? 'active' : 'waiting'}\`);
|
|
1470
|
-
}
|
|
1471
|
-
}, 10000); // Every 10 seconds
|
|
1472
|
-
|
|
1473
|
-
// Also update main session state
|
|
1474
|
-
await mcp__snow-flow__memory_usage({
|
|
1475
|
-
key: "swarm_session_${sessionId}",
|
|
1476
|
-
value: JSON.stringify({
|
|
1477
|
-
status: "agents_working",
|
|
1478
|
-
last_check: new Date().toISOString()
|
|
1479
|
-
}),
|
|
1480
|
-
namespace: "swarm_${sessionId}"
|
|
1481
|
-
});
|
|
1482
|
-
\`\`\`
|
|
1483
|
-
|
|
1484
|
-
### 6. Coordinate Agent Handoffs
|
|
936
|
+
### 6. Agent Coordination & Handoffs
|
|
1485
937
|
Ensure smooth transitions between agents:
|
|
1486
938
|
|
|
1487
939
|
\`\`\`javascript
|
|
1488
940
|
// Primary agent signals readiness for support
|
|
1489
|
-
Memory.store("agent_${taskAnalysis.primaryAgent}_ready_for_support", {
|
|
941
|
+
Memory.store("agent_${taskAnalysis.primaryAgent}_ready_for_support", JSON.stringify({
|
|
1490
942
|
base_structure_complete: true,
|
|
1491
943
|
ready_for: [${taskAnalysis.supportingAgents.map(a => `"${a}"`).join(', ')}],
|
|
1492
944
|
timestamp: new Date().toISOString()
|
|
1493
|
-
});
|
|
945
|
+
}));
|
|
1494
946
|
|
|
1495
947
|
// Supporting agents check readiness
|
|
1496
|
-
const canProceed = Memory.get("agent_${taskAnalysis.primaryAgent}_ready_for_support");
|
|
948
|
+
const canProceed = JSON.parse(Memory.get("agent_${taskAnalysis.primaryAgent}_ready_for_support") || "{}");
|
|
1497
949
|
if (canProceed?.base_structure_complete) {
|
|
1498
950
|
// Begin supporting work
|
|
1499
951
|
}
|
|
@@ -1508,19 +960,19 @@ const agentOutputs = {};
|
|
|
1508
960
|
[${[taskAnalysis.primaryAgent, ...taskAnalysis.supportingAgents].map(a => `"${a}"`).join(', ')}].forEach(agent => {
|
|
1509
961
|
const output = Memory.get(\`agent_\${agent}_complete\`);
|
|
1510
962
|
if (output) {
|
|
1511
|
-
agentOutputs[agent] = output;
|
|
963
|
+
agentOutputs[agent] = JSON.parse(output);
|
|
1512
964
|
}
|
|
1513
965
|
});
|
|
1514
966
|
|
|
1515
967
|
// Store final swarm results
|
|
1516
|
-
Memory.store("swarm_session_${sessionId}_results", {
|
|
968
|
+
Memory.store("swarm_session_${sessionId}_results", JSON.stringify({
|
|
1517
969
|
objective: "${objective}",
|
|
1518
970
|
completed_at: new Date().toISOString(),
|
|
1519
971
|
agent_outputs: agentOutputs,
|
|
1520
972
|
artifacts_created: Object.values(agentOutputs)
|
|
1521
973
|
.flatMap(output => output.artifacts_created || []),
|
|
1522
974
|
success: true
|
|
1523
|
-
});
|
|
975
|
+
}));
|
|
1524
976
|
|
|
1525
977
|
// Update final TodoWrite status
|
|
1526
978
|
TodoWrite([
|
|
@@ -1533,26 +985,6 @@ TodoWrite([
|
|
|
1533
985
|
]);
|
|
1534
986
|
\`\`\`
|
|
1535
987
|
|
|
1536
|
-
## 📊 Progress Monitoring Pattern
|
|
1537
|
-
|
|
1538
|
-
${options.progressMonitoring ? `### Real-Time Progress Monitoring Enabled
|
|
1539
|
-
Monitor swarm progress using these patterns:
|
|
1540
|
-
|
|
1541
|
-
\`\`\`javascript
|
|
1542
|
-
// Regular progress checks
|
|
1543
|
-
setInterval(() => {
|
|
1544
|
-
const session = Memory.get("swarm_session_${sessionId}");
|
|
1545
|
-
const todos = TodoRead();
|
|
1546
|
-
|
|
1547
|
-
cliLogger.info(\`Swarm Status: \${session.status}\`);
|
|
1548
|
-
cliLogger.info(\`Tasks Completed: \${todos.filter(t => t.status === 'completed').length}/\${todos.length}\`);
|
|
1549
|
-
|
|
1550
|
-
// Check individual agent progress
|
|
1551
|
-
checkAgentProgress();
|
|
1552
|
-
}, 30000); // Check every 30 seconds
|
|
1553
|
-
\`\`\`
|
|
1554
|
-
` : '### Manual Progress Checking\nUse TodoRead and Memory tools to check progress periodically.'}
|
|
1555
|
-
|
|
1556
988
|
## 🎯 Success Criteria
|
|
1557
989
|
|
|
1558
990
|
Your Queen Agent orchestration is successful when:
|
|
@@ -1560,107 +992,18 @@ Your Queen Agent orchestration is successful when:
|
|
|
1560
992
|
2. ✅ Swarm session is tracked in Memory
|
|
1561
993
|
3. ✅ Agents are coordinating through shared Memory
|
|
1562
994
|
4. ✅ TodoWrite is being used for task tracking
|
|
1563
|
-
5. ✅
|
|
1564
|
-
6. ✅
|
|
1565
|
-
7. ✅ All artifacts are created/deployed successfully
|
|
995
|
+
5. ✅ ${taskAnalysis.taskType} requirements are met
|
|
996
|
+
6. ✅ All artifacts are created/deployed successfully
|
|
1566
997
|
|
|
1567
998
|
## 💡 Queen Agent Best Practices
|
|
1568
999
|
|
|
1569
1000
|
1. **Spawn agents concurrently** when tasks are independent
|
|
1570
|
-
2. **Use Memory
|
|
1001
|
+
2. **Use Memory with JSON.stringify/parse** to avoid key collisions
|
|
1571
1002
|
3. **Update TodoWrite** frequently for visibility
|
|
1572
1003
|
4. **Monitor agent health** and restart if needed
|
|
1573
1004
|
5. **Validate outputs** before marking complete
|
|
1574
1005
|
6. **Store all decisions** in Memory for audit trail
|
|
1575
1006
|
|
|
1576
|
-
## 📋 Agent-Specific Authentication & Discovery Workflows
|
|
1577
|
-
|
|
1578
|
-
### 🛠️ Widget Creator Agent
|
|
1579
|
-
\`\`\`javascript
|
|
1580
|
-
// Pre-flight check
|
|
1581
|
-
const authCheck = await snow_find_artifact({ query: "test auth", type: "widget" });
|
|
1582
|
-
if (authCheck.error?.includes("OAuth")) {
|
|
1583
|
-
// Switch to planning mode
|
|
1584
|
-
Memory.store("widget_plan", {
|
|
1585
|
-
html_template: "<!-- Complete HTML structure -->",
|
|
1586
|
-
server_script: "// Complete server logic",
|
|
1587
|
-
client_script: "// Complete client controller",
|
|
1588
|
-
css_styles: "/* Complete styles */",
|
|
1589
|
-
deployment_instructions: "Run snow-flow auth login, then use snow_deploy"
|
|
1590
|
-
});
|
|
1591
|
-
TodoWrite([{ content: "Widget plan ready - auth required for deployment", status: "completed" }]);
|
|
1592
|
-
} else {
|
|
1593
|
-
// Continue with live development
|
|
1594
|
-
const existing = await snow_comprehensive_search({ query: "similar widget" });
|
|
1595
|
-
// ... proceed with snow_deploy
|
|
1596
|
-
}
|
|
1597
|
-
\`\`\`
|
|
1598
|
-
|
|
1599
|
-
### 🔄 Flow Builder Agent
|
|
1600
|
-
\`\`\`javascript
|
|
1601
|
-
// Check existing flows first
|
|
1602
|
-
const flows = await snow_discover_existing_flows({ flow_purpose: "objective" });
|
|
1603
|
-
if (flows.error?.includes("OAuth")) {
|
|
1604
|
-
// Document flow architecture
|
|
1605
|
-
Memory.store("flow_plan", {
|
|
1606
|
-
trigger: "When record created on [table]",
|
|
1607
|
-
steps: ["Step 1: Validate data", "Step 2: Process", "Step 3: Notify"],
|
|
1608
|
-
natural_language: "Complete flow instruction for snow_create_flow",
|
|
1609
|
-
deployment_command: "snow_create_flow with deploy_immediately: true"
|
|
1610
|
-
});
|
|
1611
|
-
} else {
|
|
1612
|
-
// Create flow directly using XML-first approach
|
|
1613
|
-
await snow_create_flow({
|
|
1614
|
-
instruction: "natural language description",
|
|
1615
|
-
deploy_immediately: true
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
\`\`\`
|
|
1619
|
-
|
|
1620
|
-
### 📝 Script Writer Agent
|
|
1621
|
-
\`\`\`javascript
|
|
1622
|
-
// Verify permissions
|
|
1623
|
-
const permCheck = await snow_get_by_sysid({
|
|
1624
|
-
sys_id: "test", // Example sys_id - replace with actual value
|
|
1625
|
-
table: "sys_script_include"
|
|
1626
|
-
});
|
|
1627
|
-
if (permCheck.error?.includes("OAuth")) {
|
|
1628
|
-
// Complete script documentation
|
|
1629
|
-
Memory.store("script_solution", {
|
|
1630
|
-
script_type: "Business Rule/Script Include/etc",
|
|
1631
|
-
code: "// Complete implementation",
|
|
1632
|
-
when: "before/after/async",
|
|
1633
|
-
table: "target_table",
|
|
1634
|
-
deployment_ready: true
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
\`\`\`
|
|
1638
|
-
|
|
1639
|
-
### 🧪 Tester Agent
|
|
1640
|
-
\`\`\`javascript
|
|
1641
|
-
// Tester can start with mock (always works)
|
|
1642
|
-
const mockTest = await snow_test_flow_with_mock({
|
|
1643
|
-
flow_id: "flow_name",
|
|
1644
|
-
test_inputs: { /* test data */ }
|
|
1645
|
-
});
|
|
1646
|
-
// Then try comprehensive if authenticated
|
|
1647
|
-
// 🔧 TEST-001 FIX: Skip live test if no valid flow sys_id is available
|
|
1648
|
-
// Only run live test if we have a real sys_id from previous flow creation
|
|
1649
|
-
let liveTest: any = { error: "No valid flow_sys_id available for live testing" };
|
|
1650
|
-
|
|
1651
|
-
// In practice, this would get the sys_id from a previously created flow:
|
|
1652
|
-
// if (Memory.get("last_created_flow_sys_id")) {
|
|
1653
|
-
// liveTest = await snow_comprehensive_flow_test({
|
|
1654
|
-
// flow_sys_id: Memory.get("last_created_flow_sys_id")
|
|
1655
|
-
// });
|
|
1656
|
-
// }
|
|
1657
|
-
|
|
1658
|
-
if (liveTest.error) {
|
|
1659
|
-
// Document test results from mock only
|
|
1660
|
-
Memory.store("test_results", mockTest);
|
|
1661
|
-
}
|
|
1662
|
-
\`\`\`
|
|
1663
|
-
|
|
1664
1007
|
## 🚀 Begin Orchestration
|
|
1665
1008
|
|
|
1666
1009
|
Now execute this Queen Agent orchestration plan:
|
|
@@ -1672,127 +1015,16 @@ Now execute this Queen Agent orchestration plan:
|
|
|
1672
1015
|
|
|
1673
1016
|
Remember: You are the Queen Agent - the master coordinator. Your role is to ensure all agents work harmoniously to achieve the objective: "${objective}"
|
|
1674
1017
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
**
|
|
1680
|
-
|
|
1681
|
-
${
|
|
1682
|
-
### 📚 Self-Documenting System
|
|
1683
|
-
**MANDATORY**: Initialize and start autonomous documentation:
|
|
1684
|
-
\`\`\`javascript
|
|
1685
|
-
// Start continuous documentation monitoring
|
|
1686
|
-
await snow_start_continuous_documentation({
|
|
1687
|
-
auto_commit: true,
|
|
1688
|
-
include_diagrams: true,
|
|
1689
|
-
scope: "full"
|
|
1690
|
-
});
|
|
1691
|
-
|
|
1692
|
-
// Store status in memory
|
|
1693
|
-
await mcp__snow-flow__memory_usage({
|
|
1694
|
-
key: "autonomous_documentation_${sessionId}",
|
|
1695
|
-
value: JSON.stringify({
|
|
1696
|
-
status: "active",
|
|
1697
|
-
started_at: new Date().toISOString(),
|
|
1698
|
-
auto_commit: true
|
|
1699
|
-
}),
|
|
1700
|
-
namespace: "swarm_${sessionId}"
|
|
1701
|
-
});
|
|
1702
|
-
\`\`\`
|
|
1703
|
-
` : ''}
|
|
1704
|
-
|
|
1705
|
-
${autonomousCostActive ? `
|
|
1706
|
-
### 💰 Cost Optimization Engine
|
|
1707
|
-
**MANDATORY**: Initialize and start autonomous cost optimization:
|
|
1708
|
-
\`\`\`javascript
|
|
1709
|
-
// Start autonomous cost optimization
|
|
1710
|
-
await snow_start_autonomous_cost_optimization({
|
|
1711
|
-
target_savings: 30,
|
|
1712
|
-
auto_implement: true,
|
|
1713
|
-
monitor_real_time: true
|
|
1714
|
-
});
|
|
1715
|
-
|
|
1716
|
-
// Store status in memory
|
|
1717
|
-
await mcp__snow-flow__memory_usage({
|
|
1718
|
-
key: "autonomous_cost_optimization_${sessionId}",
|
|
1719
|
-
value: JSON.stringify({
|
|
1720
|
-
status: "active",
|
|
1721
|
-
started_at: new Date().toISOString(),
|
|
1722
|
-
target_savings: 30,
|
|
1723
|
-
auto_implement: true
|
|
1724
|
-
}),
|
|
1725
|
-
namespace: "swarm_${sessionId}"
|
|
1726
|
-
});
|
|
1727
|
-
\`\`\`
|
|
1728
|
-
` : ''}
|
|
1729
|
-
|
|
1730
|
-
${autonomousComplianceActive ? `
|
|
1731
|
-
### 🔐 Advanced Compliance System
|
|
1732
|
-
**MANDATORY**: Initialize and start autonomous compliance monitoring:
|
|
1733
|
-
\`\`\`javascript
|
|
1734
|
-
// Start compliance monitoring
|
|
1735
|
-
await snow_start_compliance_monitoring({
|
|
1736
|
-
frameworks: ["GDPR", "SOX", "HIPAA"],
|
|
1737
|
-
auto_remediate: true,
|
|
1738
|
-
continuous_monitoring: true
|
|
1739
|
-
});
|
|
1018
|
+
## 📊 Session Information
|
|
1019
|
+
- **Session ID**: ${sessionId}
|
|
1020
|
+
- **Snow-Flow Version**: v3.3.4
|
|
1021
|
+
- **Authentication**: ${isAuthenticated ? 'Active' : 'Required'}
|
|
1022
|
+
- **Deployment Mode**: ${options.autoDeploy ? 'Live deployment enabled' : 'Planning mode'}
|
|
1023
|
+
- **Estimated Agents**: ${taskAnalysis.estimatedAgentCount}
|
|
1024
|
+
- **Primary Agent**: ${taskAnalysis.primaryAgent}
|
|
1740
1025
|
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
key: "autonomous_compliance_${sessionId}",
|
|
1744
|
-
value: JSON.stringify({
|
|
1745
|
-
status: "active",
|
|
1746
|
-
started_at: new Date().toISOString(),
|
|
1747
|
-
frameworks: ["GDPR", "SOX", "HIPAA"],
|
|
1748
|
-
auto_remediate: true
|
|
1749
|
-
}),
|
|
1750
|
-
namespace: "swarm_${sessionId}"
|
|
1751
|
-
});
|
|
1752
|
-
\`\`\`
|
|
1753
|
-
` : ''}
|
|
1754
|
-
|
|
1755
|
-
${autonomousHealingActive ? `
|
|
1756
|
-
### 🏥 Self-Healing System
|
|
1757
|
-
**MANDATORY**: Initialize and start autonomous self-healing:
|
|
1758
|
-
\`\`\`javascript
|
|
1759
|
-
// Start self-healing system
|
|
1760
|
-
await snow_start_autonomous_healing({
|
|
1761
|
-
preventive: true,
|
|
1762
|
-
auto_heal: true,
|
|
1763
|
-
learn_patterns: true
|
|
1764
|
-
});
|
|
1765
|
-
|
|
1766
|
-
// Store status in memory
|
|
1767
|
-
await mcp__snow-flow__memory_usage({
|
|
1768
|
-
key: "autonomous_healing_${sessionId}",
|
|
1769
|
-
value: JSON.stringify({
|
|
1770
|
-
status: "active",
|
|
1771
|
-
started_at: new Date().toISOString(),
|
|
1772
|
-
preventive: true,
|
|
1773
|
-
auto_heal: true
|
|
1774
|
-
}),
|
|
1775
|
-
namespace: "swarm_${sessionId}"
|
|
1776
|
-
});
|
|
1777
|
-
\`\`\`
|
|
1778
|
-
` : ''}
|
|
1779
|
-
|
|
1780
|
-
**🎯 ORCHESTRATOR SHOWCASE:** These autonomous systems operate without manual intervention, demonstrating true orchestration capabilities. They will:
|
|
1781
|
-
- Monitor continuously in the background
|
|
1782
|
-
- Make intelligent decisions automatically
|
|
1783
|
-
- Adapt and learn from patterns
|
|
1784
|
-
- Provide real-time dashboards and insights
|
|
1785
|
-
- Execute actions autonomously when needed
|
|
1786
|
-
|
|
1787
|
-
**Integration with Main Objective:** All autonomous systems will coordinate with your main objective ("${objective}") by providing:
|
|
1788
|
-
- Automatic documentation of created artifacts
|
|
1789
|
-
- Cost optimization of operations performed
|
|
1790
|
-
- Compliance validation of all changes
|
|
1791
|
-
- Self-healing of any issues that arise
|
|
1792
|
-
|
|
1793
|
-
` : ''}
|
|
1794
|
-
|
|
1795
|
-
Session ID for this swarm: ${sessionId}`;
|
|
1026
|
+
🎯 **Ready to begin orchestration!**
|
|
1027
|
+
`;
|
|
1796
1028
|
return prompt;
|
|
1797
1029
|
}
|
|
1798
1030
|
function getTeamRecommendation(taskType) {
|