snow-flow 3.0.22 → 3.0.24
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.
|
@@ -3427,14 +3427,38 @@ Use ServiceNow's official deployment process:
|
|
|
3427
3427
|
artifact_tracker_js_1.artifactTracker.trackArtifact(args.sys_id, args.table, args.name, args.type, 'update' // Assume existing artifact
|
|
3428
3428
|
);
|
|
3429
3429
|
}
|
|
3430
|
-
//
|
|
3431
|
-
|
|
3432
|
-
// Get the artifact details if valid
|
|
3430
|
+
// Use direct API query (snow_query_table approach) for validation
|
|
3431
|
+
let isValid = false;
|
|
3433
3432
|
let artifactDetails = null;
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3433
|
+
try {
|
|
3434
|
+
// Direct API call using query parameter with sys_id
|
|
3435
|
+
const apiResponse = await this.client.get(`/api/now/table/${args.table}`, {
|
|
3436
|
+
sysparm_query: `sys_id=${args.sys_id}`,
|
|
3437
|
+
sysparm_limit: 1,
|
|
3438
|
+
sysparm_fields: 'sys_id,name,title,active,sys_created_on,sys_updated_on,sys_created_by,sys_updated_by'
|
|
3439
|
+
});
|
|
3440
|
+
if (apiResponse?.result && apiResponse.result.length > 0) {
|
|
3441
|
+
isValid = true;
|
|
3442
|
+
artifactDetails = apiResponse.result[0];
|
|
3443
|
+
this.logger.info(`✅ Artifact found via direct API: ${artifactDetails.sys_id}`);
|
|
3444
|
+
}
|
|
3445
|
+
else {
|
|
3446
|
+
this.logger.info(`❌ Artifact not found: ${args.sys_id} in table ${args.table}`);
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
catch (error) {
|
|
3450
|
+
this.logger.warn(`Failed to query artifact: ${error}`);
|
|
3451
|
+
// Try alternative method as fallback
|
|
3452
|
+
try {
|
|
3453
|
+
const response = await this.client.getRecord(args.table, args.sys_id);
|
|
3454
|
+
if (response.success && response.data) {
|
|
3455
|
+
isValid = true;
|
|
3456
|
+
artifactDetails = response.data;
|
|
3457
|
+
this.logger.info(`✅ Artifact found via getRecord fallback: ${args.sys_id}`);
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
catch (fallbackError) {
|
|
3461
|
+
this.logger.error(`Both validation methods failed: ${fallbackError}`);
|
|
3438
3462
|
}
|
|
3439
3463
|
}
|
|
3440
3464
|
// Check for inconsistencies
|
|
@@ -3452,14 +3476,16 @@ Use ServiceNow's official deployment process:
|
|
|
3452
3476
|
- Expected Name: ${args.name || 'Not specified'}
|
|
3453
3477
|
- Expected Type: ${args.type || 'Not specified'}
|
|
3454
3478
|
|
|
3455
|
-
**Validation Status:** ${isValid ? '✅ Valid' : '❌
|
|
3479
|
+
**Validation Status:** ${isValid ? '✅ Valid - Artifact exists' : '❌ Not Found - Artifact does not exist in this table'}
|
|
3456
3480
|
|
|
3457
3481
|
${artifactDetails ? `**Actual Artifact Details:**
|
|
3458
3482
|
- Name: ${artifactDetails.name || artifactDetails.title || 'Unknown'}
|
|
3459
|
-
- Active: ${artifactDetails.active}
|
|
3460
|
-
- Created: ${artifactDetails.sys_created_on}
|
|
3461
|
-
- Updated: ${artifactDetails.sys_updated_on}
|
|
3462
|
-
|
|
3483
|
+
- Active: ${artifactDetails.active !== undefined ? artifactDetails.active : 'N/A'}
|
|
3484
|
+
- Created: ${artifactDetails.sys_created_on || 'N/A'}
|
|
3485
|
+
- Updated: ${artifactDetails.sys_updated_on || 'N/A'}
|
|
3486
|
+
- Created By: ${artifactDetails.sys_created_by || 'N/A'}
|
|
3487
|
+
- Updated By: ${artifactDetails.sys_updated_by || 'N/A'}
|
|
3488
|
+
` : '**Artifact not found in ServiceNow**'}
|
|
3463
3489
|
|
|
3464
3490
|
${trackedArtifact ? `**Tracking Info:**
|
|
3465
3491
|
- Status: ${trackedArtifact.status}
|
|
@@ -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.24",
|
|
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",
|