snow-flow 2.6.0 → 2.6.2

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.
@@ -47,6 +47,14 @@ export declare class AgentDetector {
47
47
  * Analyze task using MCP dynamic categorization or fallback to static patterns
48
48
  */
49
49
  static analyzeTaskDynamic(objective: string, userMaxAgents?: number): Promise<TaskAnalysis>;
50
+ /**
51
+ * Discover dynamic agents using MCP agent_discover
52
+ */
53
+ private static discoverDynamicAgents;
54
+ /**
55
+ * Extract required capabilities from intent analysis
56
+ */
57
+ private static extractCapabilitiesFromIntent;
50
58
  private static readonly AGENT_PATTERNS;
51
59
  private static readonly SERVICENOW_ARTIFACTS;
52
60
  static analyzeTask(objective: string, userMaxAgents?: number): TaskAnalysis;
@@ -35,12 +35,14 @@ class AgentDetector {
35
35
  });
36
36
  if (response && response.content && response.content[0]) {
37
37
  const result = JSON.parse(response.content[0].text);
38
- // Map MCP response to TaskAnalysis interface
38
+ // Now discover dynamic agents based on the task analysis
39
+ const agentDiscoveryResponse = await this.discoverDynamicAgents(result.categorization, result.intent_analysis);
40
+ // Map MCP response to TaskAnalysis interface with dynamic agents
39
41
  return {
40
- primaryAgent: result.categorization.primary_agent,
41
- supportingAgents: result.categorization.supporting_agents,
42
+ primaryAgent: agentDiscoveryResponse.primaryAgent || result.categorization.primary_agent,
43
+ supportingAgents: agentDiscoveryResponse.supportingAgents || result.categorization.supporting_agents,
42
44
  complexity: result.categorization.complexity,
43
- estimatedAgentCount: result.categorization.estimated_agent_count,
45
+ estimatedAgentCount: agentDiscoveryResponse.agentCount || result.categorization.estimated_agent_count,
44
46
  requiresUpdateSet: result.categorization.requires_update_set,
45
47
  requiresApplication: result.categorization.requires_application,
46
48
  taskType: result.categorization.task_type,
@@ -65,6 +67,102 @@ class AgentDetector {
65
67
  // Fallback to static analysis
66
68
  return this.analyzeTask(objective, userMaxAgents);
67
69
  }
70
+ /**
71
+ * Discover dynamic agents using MCP agent_discover
72
+ */
73
+ static async discoverDynamicAgents(categorization, intentAnalysis) {
74
+ if (!this.mcpClient) {
75
+ return {
76
+ primaryAgent: categorization.primary_agent,
77
+ supportingAgents: categorization.supporting_agents,
78
+ agentCount: categorization.estimated_agent_count,
79
+ };
80
+ }
81
+ try {
82
+ const response = await this.mcpClient.callTool({
83
+ name: 'agent_discover',
84
+ arguments: {
85
+ task_analysis: {
86
+ task_type: categorization.task_type,
87
+ complexity: categorization.complexity,
88
+ service_now_artifacts: categorization.service_now_artifacts,
89
+ },
90
+ required_capabilities: this.extractCapabilitiesFromIntent(intentAnalysis),
91
+ context: {
92
+ max_agents: categorization.estimated_agent_count || 8,
93
+ include_new_types: true,
94
+ learn_from_history: true,
95
+ },
96
+ },
97
+ });
98
+ if (response && response.content && response.content[0]) {
99
+ const result = JSON.parse(response.content[0].text);
100
+ // Map discovered agents to our format
101
+ const discoveredAgents = result.discovered_agents || [];
102
+ const primaryAgent = result.recommendations.primary_coordinator || categorization.primary_agent;
103
+ const supportingAgents = discoveredAgents
104
+ .filter((a) => a.type !== primaryAgent)
105
+ .map((a) => a.type);
106
+ return {
107
+ primaryAgent,
108
+ supportingAgents,
109
+ agentCount: discoveredAgents.length,
110
+ discoveredAgents,
111
+ executionBatches: result.execution_batches,
112
+ newAgentTypes: result.new_agent_types,
113
+ };
114
+ }
115
+ }
116
+ catch (error) {
117
+ console.warn('MCP agent_discover failed, using static agents:', error);
118
+ }
119
+ // Fallback to original agents
120
+ return {
121
+ primaryAgent: categorization.primary_agent,
122
+ supportingAgents: categorization.supporting_agents,
123
+ agentCount: categorization.estimated_agent_count,
124
+ };
125
+ }
126
+ /**
127
+ * Extract required capabilities from intent analysis
128
+ */
129
+ static extractCapabilitiesFromIntent(intentAnalysis) {
130
+ const capabilities = [];
131
+ // Extract from action verbs
132
+ const verbCapabilityMap = {
133
+ 'integrate': 'integration',
134
+ 'optimize': 'performance',
135
+ 'secure': 'security',
136
+ 'analyze': 'analytics',
137
+ 'visualize': 'visualization',
138
+ 'automate': 'automation',
139
+ 'deploy': 'devops',
140
+ 'test': 'testing',
141
+ 'document': 'documentation',
142
+ };
143
+ for (const verb of intentAnalysis.action_verbs || []) {
144
+ if (verbCapabilityMap[verb]) {
145
+ capabilities.push(verbCapabilityMap[verb]);
146
+ }
147
+ }
148
+ // Extract from target objects
149
+ const objectCapabilityMap = {
150
+ 'mobile': 'mobile',
151
+ 'chatbot': 'chatbot',
152
+ 'ml': 'ml',
153
+ 'ai': 'ml',
154
+ 'blockchain': 'blockchain',
155
+ 'iot': 'iot',
156
+ 'compliance': 'compliance',
157
+ 'accessibility': 'accessibility',
158
+ };
159
+ for (const obj of intentAnalysis.target_objects || []) {
160
+ if (objectCapabilityMap[obj]) {
161
+ capabilities.push(objectCapabilityMap[obj]);
162
+ }
163
+ }
164
+ return [...new Set(capabilities)]; // Remove duplicates
165
+ }
68
166
  static analyzeTask(objective, userMaxAgents) {
69
167
  const lowerObjective = objective.toLowerCase();
70
168
  const words = lowerObjective.split(/\s+/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "description": "Snow-Flow: ServiceNow Advanced Intelligence Platform - 100+ real MCP tools with AI-powered swarm orchestration and neural networks. Dynamic task categorization using AI. Machine learning for incident classification, change risk prediction, and anomaly detection. Zero Mock Data, 100% Real API Integration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",