snow-flow 2.9.8 → 2.9.9

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.
@@ -38,6 +38,12 @@ 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
42
+ // This fixes the "Cannot read properties of undefined (reading 'tick')" error
43
+ if (typeof global !== 'undefined' && !global.performance) {
44
+ const { performance } = require('perf_hooks');
45
+ global.performance = performance;
46
+ }
41
47
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
42
48
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
43
49
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
@@ -766,14 +772,22 @@ class ServiceNowMachineLearningMCP {
766
772
  metrics: ['accuracy']
767
773
  });
768
774
  this.logger.info('Training incident classifier...');
769
- // Train model
775
+ // Train model with improved error handling
770
776
  const history = await model.fit(features, labels, {
771
777
  epochs,
772
778
  validationSplit: validation_split,
773
779
  batchSize: 32,
774
780
  callbacks: {
775
781
  onEpochEnd: (epoch, logs) => {
776
- this.logger.info(`Epoch ${epoch + 1}: loss = ${logs?.loss?.toFixed(4)}, accuracy = ${logs?.acc?.toFixed(4)}`);
782
+ try {
783
+ const loss = logs?.loss ? logs.loss.toFixed(4) : 'N/A';
784
+ const accuracy = logs?.acc ? logs.acc.toFixed(4) : 'N/A';
785
+ this.logger.info(`Epoch ${epoch + 1}: loss = ${loss}, accuracy = ${accuracy}`);
786
+ }
787
+ catch (e) {
788
+ // Ignore callback errors to prevent training interruption
789
+ this.logger.warn(`Callback error in epoch ${epoch + 1}:`, e);
790
+ }
777
791
  }
778
792
  }
779
793
  });
@@ -849,15 +863,21 @@ class ServiceNowMachineLearningMCP {
849
863
  loss: 'categoricalCrossentropy',
850
864
  metrics: ['accuracy']
851
865
  });
852
- // Train
866
+ // Train with improved error handling
853
867
  const history = await model.fit(features, labels, {
854
868
  epochs: 100,
855
869
  validationSplit: 0.2,
856
870
  batchSize: 16,
857
871
  callbacks: {
858
872
  onEpochEnd: (epoch, logs) => {
859
- if (epoch % 10 === 0) {
860
- this.logger.info(`Epoch ${epoch}: accuracy = ${logs?.acc?.toFixed(4)}`);
873
+ try {
874
+ if (epoch % 10 === 0) {
875
+ const accuracy = logs?.acc ? logs.acc.toFixed(4) : 'N/A';
876
+ this.logger.info(`Epoch ${epoch}: accuracy = ${accuracy}`);
877
+ }
878
+ }
879
+ catch (e) {
880
+ this.logger.warn(`Callback error in epoch ${epoch}:`, e);
861
881
  }
862
882
  }
863
883
  }
@@ -948,15 +968,21 @@ class ServiceNowMachineLearningMCP {
948
968
  optimizer: tf.train.adam(0.001),
949
969
  loss: 'meanSquaredError'
950
970
  });
951
- // Train
971
+ // Train with improved error handling
952
972
  await autoencoder.fit(normalized, normalized, {
953
973
  epochs: 100,
954
974
  batchSize: 32,
955
975
  validationSplit: 0.1,
956
976
  callbacks: {
957
977
  onEpochEnd: (epoch, logs) => {
958
- if (epoch % 20 === 0) {
959
- this.logger.info(`Anomaly detector epoch ${epoch}: loss = ${logs?.loss?.toFixed(6)}`);
978
+ try {
979
+ if (epoch % 20 === 0) {
980
+ const loss = logs?.loss ? logs.loss.toFixed(6) : 'N/A';
981
+ this.logger.info(`Anomaly detector epoch ${epoch}: loss = ${loss}`);
982
+ }
983
+ }
984
+ catch (e) {
985
+ this.logger.warn(`Callback error in epoch ${epoch}:`, e);
960
986
  }
961
987
  }
962
988
  }
@@ -1769,15 +1795,21 @@ class ServiceNowMachineLearningMCP {
1769
1795
  batchIncidents.forEach(inc => allCategories.add(inc.category));
1770
1796
  // Process batch with feature hashing
1771
1797
  const { features, labels } = this.processBatchWithHashing(batchIncidents, Array.from(allCategories), featureHasher);
1772
- // Train on batch
1798
+ // Train on batch with improved error handling
1773
1799
  await model.fit(features, labels, {
1774
1800
  epochs: Math.ceil(epochs / totalBatches), // Distribute epochs across batches
1775
1801
  batchSize: 32,
1776
1802
  verbose: 0,
1777
1803
  callbacks: {
1778
1804
  onBatchEnd: async (batch, logs) => {
1779
- if (batch % 10 === 0) {
1780
- this.logger.info(`Batch ${batch}: loss=${logs?.loss?.toFixed(4)}`);
1805
+ try {
1806
+ if (batch % 10 === 0 && logs?.loss) {
1807
+ this.logger.info(`Batch ${batch}: loss=${logs.loss.toFixed(4)}`);
1808
+ }
1809
+ }
1810
+ catch (e) {
1811
+ // Ignore callback errors to prevent training interruption
1812
+ this.logger.warn(`Callback error in batch ${batch}:`, e);
1781
1813
  }
1782
1814
  }
1783
1815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "2.9.8",
3
+ "version": "2.9.9",
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",