snow-flow 2.6.9 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,7 +108,7 @@ class ServiceNowMachineLearningMCP {
108
108
  // Training tools
109
109
  {
110
110
  name: 'ml_train_incident_classifier',
111
- description: 'Train LSTM neural network on historical incident data. Works WITHOUT PA/PI plugins - only needs incident table access!',
111
+ description: 'Train LSTM neural network on historical incident data with INTELLIGENT data selection. Snow-Flow automatically selects balanced training data or accepts custom queries. Works WITHOUT PA/PI plugins - only needs incident table access!',
112
112
  inputSchema: {
113
113
  type: 'object',
114
114
  properties: {
@@ -126,6 +126,21 @@ class ServiceNowMachineLearningMCP {
126
126
  type: 'number',
127
127
  description: 'Validation data percentage',
128
128
  default: 0.2
129
+ },
130
+ query: {
131
+ type: 'string',
132
+ description: 'Custom ServiceNow query for selecting training data. If not provided, Snow-Flow will intelligently select data.',
133
+ default: ''
134
+ },
135
+ intelligent_selection: {
136
+ type: 'boolean',
137
+ description: 'Let Snow-Flow intelligently select balanced training data across categories, priorities, and time periods',
138
+ default: true
139
+ },
140
+ focus_categories: {
141
+ type: 'array',
142
+ items: { type: 'string' },
143
+ description: 'Specific categories to focus on for training (optional)'
129
144
  }
130
145
  }
131
146
  },
@@ -475,7 +490,7 @@ class ServiceNowMachineLearningMCP {
475
490
  * Uses PI if available, otherwise uses custom TensorFlow.js
476
491
  */
477
492
  async trainIncidentClassifier(args) {
478
- const { sample_size = 1000, epochs = 50, validation_split = 0.2 } = args;
493
+ const { sample_size = 1000, epochs = 50, validation_split = 0.2, query = '', intelligent_selection = true, focus_categories = [] } = args;
479
494
  try {
480
495
  // Wait for ML API check if not complete
481
496
  if (!this.mlAPICheckComplete) {
@@ -512,8 +527,12 @@ class ServiceNowMachineLearningMCP {
512
527
  }
513
528
  // Use custom TensorFlow.js neural network
514
529
  this.logger.info(`Training custom LSTM neural network for incident classification with ${sample_size} samples...`);
515
- // Fetch historical incidents
516
- const incidents = await this.fetchIncidentData(sample_size);
530
+ // Fetch historical incidents with intelligent selection
531
+ const incidents = await this.fetchIncidentData(sample_size, {
532
+ query,
533
+ intelligent_selection,
534
+ focus_categories
535
+ });
517
536
  this.logger.info(`Retrieved ${incidents.length} incidents from ServiceNow`);
518
537
  if (incidents.length < 100) {
519
538
  throw new Error(`Insufficient data for training (need at least 100 incidents, got ${incidents.length})`);
@@ -1001,17 +1020,62 @@ class ServiceNowMachineLearningMCP {
1001
1020
  };
1002
1021
  }
1003
1022
  // Helper methods
1004
- async fetchIncidentData(limit) {
1005
- // Fetch real incidents from ServiceNow - no ML API needed!
1006
- // Include both active and resolved incidents for better training data
1007
- // Order by sys_created_on DESC to get most recent incidents
1008
- const query = 'ORDERBYDESCsys_created_on'; // Get most recent incidents, both active and resolved
1023
+ async fetchIncidentData(limit, options = {}) {
1024
+ const { query = '', intelligent_selection = true, focus_categories = [] } = options;
1025
+ let finalQuery = query;
1026
+ // If intelligent selection is enabled and no custom query provided
1027
+ if (intelligent_selection && !query) {
1028
+ // Build an intelligent query that gets a balanced dataset
1029
+ const queries = [];
1030
+ // Get mix of recent and older incidents
1031
+ queries.push('sys_created_onONLast 6 months');
1032
+ // Get mix of priorities
1033
+ queries.push('(priority=1^ORpriority=2^ORpriority=3^ORpriority=4)');
1034
+ // Get mix of active and resolved
1035
+ queries.push('(active=true^ORactive=false)');
1036
+ // Focus on specific categories if provided
1037
+ if (focus_categories.length > 0) {
1038
+ const categoryQuery = focus_categories.map(cat => `category=${cat}`).join('^OR');
1039
+ queries.push(`(${categoryQuery})`);
1040
+ }
1041
+ else {
1042
+ // Get diverse categories
1043
+ queries.push('categoryISNOTEMPTY');
1044
+ }
1045
+ // Combine all queries
1046
+ finalQuery = queries.join('^');
1047
+ this.logger.info(`Using intelligent query selection: ${finalQuery}`);
1048
+ }
1049
+ else if (query) {
1050
+ this.logger.info(`Using custom query: ${query}`);
1051
+ }
1052
+ // Always order by sys_created_on DESC to get most recent first
1053
+ if (finalQuery && !finalQuery.includes('ORDERBY')) {
1054
+ finalQuery += '^ORDERBYDESCsys_created_on';
1055
+ }
1056
+ else if (!finalQuery) {
1057
+ finalQuery = 'ORDERBYDESCsys_created_on';
1058
+ }
1009
1059
  // Use searchRecords for proper authentication handling
1010
- const response = await this.client.searchRecords('incident', query, limit);
1060
+ const response = await this.client.searchRecords('incident', finalQuery, limit);
1011
1061
  if (!response.success || !response.data?.result) {
1012
1062
  throw new Error('Failed to fetch incident data. Ensure you have read access to the incident table.');
1013
1063
  }
1014
1064
  this.logger.info(`Fetched ${response.data.result.length} incidents for ML training (requested: ${limit})`);
1065
+ // If intelligent selection, ensure we have a balanced dataset
1066
+ if (intelligent_selection && response.data.result.length > 0) {
1067
+ const categoryDistribution = {};
1068
+ const priorityDistribution = {};
1069
+ response.data.result.forEach((inc) => {
1070
+ const category = inc.category || 'uncategorized';
1071
+ const priority = inc.priority || '3';
1072
+ categoryDistribution[category] = (categoryDistribution[category] || 0) + 1;
1073
+ priorityDistribution[priority] = (priorityDistribution[priority] || 0) + 1;
1074
+ });
1075
+ this.logger.info('Data distribution:');
1076
+ this.logger.info(`Categories: ${JSON.stringify(categoryDistribution)}`);
1077
+ this.logger.info(`Priorities: ${JSON.stringify(priorityDistribution)}`);
1078
+ }
1015
1079
  return response.data.result.map((inc) => ({
1016
1080
  short_description: inc.short_description || '',
1017
1081
  description: inc.description || '',
package/dist/version.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const VERSION_INFO: {
7
7
  name: string;
8
8
  description: string;
9
9
  features: {
10
+ '2.7.0': string[];
10
11
  '2.6.9': string[];
11
12
  '2.6.8': string[];
12
13
  '2.6.7': string[];
package/dist/version.js CHANGED
@@ -14,6 +14,15 @@ exports.VERSION_INFO = {
14
14
  name: 'Snow-Flow',
15
15
  description: 'ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development',
16
16
  features: {
17
+ '2.7.0': [
18
+ '🧠 INTELLIGENT ML DATA SELECTION: Snow-Flow now intelligently selects balanced training data',
19
+ '🎯 CUSTOM QUERIES: Added query parameter for full control over ML training data selection',
20
+ '⚖️ BALANCED DATASETS: Automatic balancing across categories, priorities, and time periods',
21
+ '🔍 FOCUS CATEGORIES: Can now focus ML training on specific incident categories',
22
+ '📊 DATA DISTRIBUTION: Shows category and priority distribution for transparency',
23
+ '🚀 DYNAMIC CONTROL: Snow-Flow has full freedom to optimize ML data selection',
24
+ '✨ SMART DEFAULTS: Intelligent query building when no custom query provided',
25
+ ],
17
26
  '2.6.9': [
18
27
  '🔍 ML QUERY FIX: Removed restrictive filters limiting training data to only resolved incidents',
19
28
  '📊 ALL INCIDENTS: ML training now includes both active AND resolved incidents',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "2.6.9",
3
+ "version": "2.7.0",
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",
@@ -294,9 +294,12 @@
294
294
  },
295
295
  "ml_train_incident_classifier": {
296
296
  "name": "Incident Classification Neural Network",
297
- "description": "Train LSTM neural networks on historical incident data. Use when: 1) PI not available, 2) Custom patterns needed, 3) Client-side predictions required. For standard incidents WITH PI license, use ml_predictive_intelligence instead for 95%+ accuracy.",
297
+ "description": "Train LSTM neural networks with INTELLIGENT data selection. Snow-Flow automatically balances training data across categories, priorities & time periods. Accepts custom queries for full control. Use when: 1) PI not available, 2) Custom patterns needed, 3) Client-side predictions required.",
298
298
  "category": "machine_learning",
299
299
  "features": [
300
+ "intelligent_data_selection",
301
+ "balanced_datasets",
302
+ "custom_queries",
300
303
  "lstm_networks",
301
304
  "text_embedding",
302
305
  "multi_class_prediction",