snow-flow 3.0.23 → 3.0.25
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/dist/cli.js +1 -1
- package/dist/mcp/servicenow-machine-learning-mcp.js +178 -52
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3945,7 +3945,7 @@ async function createMCPConfig(targetDir, force = false) {
|
|
|
3945
3945
|
"MCP_TOOL_TIMEOUT": "0",
|
|
3946
3946
|
"DISABLE_COST_WARNINGS": "1",
|
|
3947
3947
|
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "0",
|
|
3948
|
-
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "
|
|
3948
|
+
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000",
|
|
3949
3949
|
"CLAUDE_CODE_TIMEOUT": "0",
|
|
3950
3950
|
"CLAUDE_CODE_SESSION_TIMEOUT": "0",
|
|
3951
3951
|
"CLAUDE_CODE_EXECUTION_TIMEOUT": "0"
|
|
@@ -38,11 +38,36 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
})();
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.ServiceNowMachineLearningMCP = void 0;
|
|
41
|
-
// CRITICAL FIX: Add performance polyfill for TensorFlow.js in Node.js environment
|
|
41
|
+
// CRITICAL FIX: Add comprehensive performance polyfill for TensorFlow.js in Node.js environment
|
|
42
42
|
// This fixes the "Cannot read properties of undefined (reading 'tick')" error
|
|
43
|
-
if (typeof global !== 'undefined'
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (typeof global !== 'undefined') {
|
|
44
|
+
// Import perf_hooks
|
|
45
|
+
const { performance: perfHooksPerformance } = require('perf_hooks');
|
|
46
|
+
// Create comprehensive performance object with type casting
|
|
47
|
+
if (!global.performance || !global.performance.now) {
|
|
48
|
+
global.performance = {
|
|
49
|
+
now: perfHooksPerformance.now.bind(perfHooksPerformance),
|
|
50
|
+
mark: perfHooksPerformance.mark ? perfHooksPerformance.mark.bind(perfHooksPerformance) : () => { },
|
|
51
|
+
measure: perfHooksPerformance.measure ? perfHooksPerformance.measure.bind(perfHooksPerformance) : () => { },
|
|
52
|
+
getEntriesByName: perfHooksPerformance.getEntriesByName ? perfHooksPerformance.getEntriesByName.bind(perfHooksPerformance) : () => [],
|
|
53
|
+
getEntriesByType: perfHooksPerformance.getEntriesByType ? perfHooksPerformance.getEntriesByType.bind(perfHooksPerformance) : () => [],
|
|
54
|
+
clearMarks: perfHooksPerformance.clearMarks ? perfHooksPerformance.clearMarks.bind(perfHooksPerformance) : () => { },
|
|
55
|
+
clearMeasures: perfHooksPerformance.clearMeasures ? perfHooksPerformance.clearMeasures.bind(perfHooksPerformance) : () => { },
|
|
56
|
+
// Add tick method that TensorFlow.js might be looking for
|
|
57
|
+
tick: perfHooksPerformance.now ? perfHooksPerformance.now.bind(perfHooksPerformance) : () => Date.now(),
|
|
58
|
+
timeOrigin: perfHooksPerformance.timeOrigin || Date.now()
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Additional Node.js specific fixes for TensorFlow.js
|
|
62
|
+
if (typeof global.window === 'undefined') {
|
|
63
|
+
// Mock minimal window object for TensorFlow.js
|
|
64
|
+
global.window = global;
|
|
65
|
+
}
|
|
66
|
+
// Ensure process.hrtime is available for high-resolution timing
|
|
67
|
+
if (!global.process || !global.process.hrtime) {
|
|
68
|
+
global.process = global.process || {};
|
|
69
|
+
global.process.hrtime = process.hrtime;
|
|
70
|
+
}
|
|
46
71
|
}
|
|
47
72
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
48
73
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
@@ -737,60 +762,161 @@ class ServiceNowMachineLearningMCP {
|
|
|
737
762
|
}
|
|
738
763
|
this.logger.info(`Creating model with vocabulary size: ${vocabularySize}, categories: ${categories.length}`);
|
|
739
764
|
// Create neural network model with VALIDATED vocabulary size
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
765
|
+
let model;
|
|
766
|
+
try {
|
|
767
|
+
this.logger.info('Creating TensorFlow.js model...');
|
|
768
|
+
// Additional validation before model creation
|
|
769
|
+
if (typeof tf === 'undefined' || !tf.sequential) {
|
|
770
|
+
throw new Error('TensorFlow.js not properly loaded');
|
|
771
|
+
}
|
|
772
|
+
if (!global.performance || typeof global.performance.tick !== 'function') {
|
|
773
|
+
throw new Error('Performance API not available - TensorFlow.js requires timing functions');
|
|
774
|
+
}
|
|
775
|
+
model = tf.sequential({
|
|
776
|
+
layers: [
|
|
777
|
+
// Embedding layer for text - inputDim MUST match the vocabulary size used in data preparation
|
|
778
|
+
tf.layers.embedding({
|
|
779
|
+
inputDim: vocabularySize, // Use the EXACT vocabulary size from data preparation
|
|
780
|
+
outputDim: 128,
|
|
781
|
+
inputLength: 100 // Max sequence length
|
|
782
|
+
}),
|
|
783
|
+
// LSTM for sequence processing
|
|
784
|
+
tf.layers.lstm({
|
|
785
|
+
units: 64,
|
|
786
|
+
returnSequences: false,
|
|
787
|
+
dropout: 0.2,
|
|
788
|
+
recurrentDropout: 0.2
|
|
789
|
+
}),
|
|
790
|
+
// Dense layers
|
|
791
|
+
tf.layers.dense({
|
|
792
|
+
units: 32,
|
|
793
|
+
activation: 'relu'
|
|
794
|
+
}),
|
|
795
|
+
tf.layers.dropout({ rate: 0.3 }),
|
|
796
|
+
// Output layer
|
|
797
|
+
tf.layers.dense({
|
|
798
|
+
units: categories.length,
|
|
799
|
+
activation: 'softmax'
|
|
800
|
+
})
|
|
801
|
+
]
|
|
802
|
+
});
|
|
803
|
+
this.logger.info('✅ Model created successfully');
|
|
804
|
+
}
|
|
805
|
+
catch (modelError) {
|
|
806
|
+
this.logger.error('Failed to create TensorFlow.js model:', modelError);
|
|
807
|
+
return {
|
|
808
|
+
content: [{
|
|
809
|
+
type: 'text',
|
|
810
|
+
text: JSON.stringify({
|
|
811
|
+
status: 'error',
|
|
812
|
+
error: 'Failed to create neural network model',
|
|
813
|
+
details: modelError.message,
|
|
814
|
+
troubleshooting: [
|
|
815
|
+
'1. TensorFlow.js initialization issue detected',
|
|
816
|
+
'2. Try restarting the MCP server',
|
|
817
|
+
'3. Check Node.js version compatibility',
|
|
818
|
+
'4. Performance API polyfill may need adjustment'
|
|
819
|
+
],
|
|
820
|
+
technical_details: {
|
|
821
|
+
vocabulary_size: vocabularySize,
|
|
822
|
+
categories_count: categories.length,
|
|
823
|
+
tensorflow_available: typeof tf !== 'undefined',
|
|
824
|
+
performance_available: typeof global.performance !== 'undefined',
|
|
825
|
+
tick_available: typeof global.performance?.tick === 'function'
|
|
826
|
+
}
|
|
827
|
+
}, null, 2)
|
|
828
|
+
}]
|
|
829
|
+
};
|
|
830
|
+
}
|
|
768
831
|
// Compile model
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
832
|
+
try {
|
|
833
|
+
this.logger.info('Compiling TensorFlow.js model...');
|
|
834
|
+
model.compile({
|
|
835
|
+
optimizer: tf.train.adam(0.001),
|
|
836
|
+
loss: 'categoricalCrossentropy',
|
|
837
|
+
metrics: ['accuracy']
|
|
838
|
+
});
|
|
839
|
+
this.logger.info('✅ Model compiled successfully');
|
|
840
|
+
}
|
|
841
|
+
catch (compileError) {
|
|
842
|
+
this.logger.error('Failed to compile TensorFlow.js model:', compileError);
|
|
843
|
+
return {
|
|
844
|
+
content: [{
|
|
845
|
+
type: 'text',
|
|
846
|
+
text: JSON.stringify({
|
|
847
|
+
status: 'error',
|
|
848
|
+
error: 'Failed to compile neural network model',
|
|
849
|
+
details: compileError.message,
|
|
850
|
+
troubleshooting: [
|
|
851
|
+
'1. Model architecture validation failed',
|
|
852
|
+
'2. Check TensorFlow.js optimizer availability',
|
|
853
|
+
'3. Verify model layers are compatible',
|
|
854
|
+
'4. Try with simpler model configuration'
|
|
855
|
+
]
|
|
856
|
+
}, null, 2)
|
|
857
|
+
}]
|
|
858
|
+
};
|
|
859
|
+
}
|
|
774
860
|
this.logger.info('Training incident classifier...');
|
|
775
861
|
// Train model with improved error handling
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
862
|
+
let history;
|
|
863
|
+
try {
|
|
864
|
+
this.logger.info(`Starting training with ${epochs} epochs, batch size 32...`);
|
|
865
|
+
history = await model.fit(features, labels, {
|
|
866
|
+
epochs,
|
|
867
|
+
validationSplit: validation_split,
|
|
868
|
+
batchSize: 32,
|
|
869
|
+
callbacks: {
|
|
870
|
+
onEpochEnd: (epoch, logs) => {
|
|
871
|
+
try {
|
|
872
|
+
const loss = logs?.loss ? logs.loss.toFixed(4) : 'N/A';
|
|
873
|
+
const accuracy = logs?.acc ? logs.acc.toFixed(4) : 'N/A';
|
|
874
|
+
this.logger.info(`Epoch ${epoch + 1}: loss = ${loss}, accuracy = ${accuracy}`);
|
|
875
|
+
}
|
|
876
|
+
catch (e) {
|
|
877
|
+
// Ignore callback errors to prevent training interruption
|
|
878
|
+
this.logger.warn(`Callback error in epoch ${epoch + 1}:`, e);
|
|
879
|
+
}
|
|
790
880
|
}
|
|
791
881
|
}
|
|
882
|
+
});
|
|
883
|
+
this.logger.info('✅ Training completed successfully');
|
|
884
|
+
}
|
|
885
|
+
catch (trainingError) {
|
|
886
|
+
this.logger.error('Model training failed:', trainingError);
|
|
887
|
+
// Clean up tensors before returning error
|
|
888
|
+
try {
|
|
889
|
+
features.dispose();
|
|
890
|
+
labels.dispose();
|
|
891
|
+
model.dispose();
|
|
792
892
|
}
|
|
793
|
-
|
|
893
|
+
catch (cleanupError) {
|
|
894
|
+
this.logger.warn('Cleanup error:', cleanupError);
|
|
895
|
+
}
|
|
896
|
+
return {
|
|
897
|
+
content: [{
|
|
898
|
+
type: 'text',
|
|
899
|
+
text: JSON.stringify({
|
|
900
|
+
status: 'error',
|
|
901
|
+
error: 'Neural network training failed',
|
|
902
|
+
details: trainingError.message,
|
|
903
|
+
troubleshooting: [
|
|
904
|
+
'1. TensorFlow.js training process encountered an error',
|
|
905
|
+
'2. Try reducing epochs or batch_size',
|
|
906
|
+
'3. Check data quality and size',
|
|
907
|
+
'4. Restart MCP server if persistent',
|
|
908
|
+
'5. Verify sufficient system memory'
|
|
909
|
+
],
|
|
910
|
+
training_parameters: {
|
|
911
|
+
epochs,
|
|
912
|
+
validation_split,
|
|
913
|
+
batch_size: 32,
|
|
914
|
+
samples: incidents.length
|
|
915
|
+
}
|
|
916
|
+
}, null, 2)
|
|
917
|
+
}]
|
|
918
|
+
};
|
|
919
|
+
}
|
|
794
920
|
// Save model
|
|
795
921
|
this.incidentClassifier = {
|
|
796
922
|
model,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
4
4
|
"description": "Snow-Flow v3.0.18: DIRECT API VERIFICATION! 🚀 Replaced unreliable searchRecords with direct API calls (snow_query_table style) for widget verification. All null/403 error recovery now uses GET /api/now/table/sp_widget with precise queries. NO MORE FALSE NEGATIVES - verification works consistently every time!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|