snow-flow 1.1.74 → 1.1.76
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/.claude-flow/queen/queen-memory.db +0 -0
- package/.claude-flow/queen-test/test-memory.db +0 -0
- package/.claude-flow/queen-test/test-memory.db-agents +0 -0
- package/.claude-flow/queen-test/test-memory.db-import +0 -0
- package/.claude-flow/queen-test/test-memory.db-memory +0 -0
- package/.claude-flow/queen-test/test-memory.db-neural +0 -0
- package/CLAUDE.md +111 -8
- package/README.md +117 -50
- package/deploy.sh +366 -0
- package/dist/cli.js +226 -0
- package/dist/cli.js.map +1 -1
- package/dist/mcp/http-transport-wrapper.d.ts +29 -0
- package/dist/mcp/http-transport-wrapper.d.ts.map +1 -0
- package/dist/mcp/http-transport-wrapper.js +318 -0
- package/dist/mcp/http-transport-wrapper.js.map +1 -0
- package/dist/mcp/service-discovery-client.d.ts +83 -0
- package/dist/mcp/service-discovery-client.d.ts.map +1 -0
- package/dist/mcp/service-discovery-client.js +211 -0
- package/dist/mcp/service-discovery-client.js.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.js +262 -29
- package/dist/mcp/servicenow-deployment-mcp.js.map +1 -1
- package/dist/mcp/servicenow-intelligent-mcp.js +252 -18
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -1
- package/dist/mcp/servicenow-operations-mcp.js +274 -46
- package/dist/mcp/servicenow-operations-mcp.js.map +1 -1
- package/dist/orchestration/discovery/service-discovery.d.ts +81 -0
- package/dist/orchestration/discovery/service-discovery.d.ts.map +1 -0
- package/dist/orchestration/discovery/service-discovery.js +808 -0
- package/dist/orchestration/discovery/service-discovery.js.map +1 -0
- package/dist/orchestration/distributed-orchestrator.d.ts +131 -0
- package/dist/orchestration/distributed-orchestrator.d.ts.map +1 -0
- package/dist/orchestration/distributed-orchestrator.js +712 -0
- package/dist/orchestration/distributed-orchestrator.js.map +1 -0
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +53 -0
- package/dist/orchestration/distribution/task-distribution-engine.d.ts.map +1 -0
- package/dist/orchestration/distribution/task-distribution-engine.js +586 -0
- package/dist/orchestration/distribution/task-distribution-engine.js.map +1 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +606 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts.map +1 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +65 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js.map +1 -0
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +71 -0
- package/dist/orchestration/protocols/mcpx-protocol.d.ts.map +1 -0
- package/dist/orchestration/protocols/mcpx-protocol.js +668 -0
- package/dist/orchestration/protocols/mcpx-protocol.js.map +1 -0
- package/dist/orchestration/state/distributed-state-manager.d.ts +89 -0
- package/dist/orchestration/state/distributed-state-manager.d.ts.map +1 -0
- package/dist/orchestration/state/distributed-state-manager.js +716 -0
- package/dist/orchestration/state/distributed-state-manager.js.map +1 -0
- package/dist/queen/advanced-integration-test.d.ts +48 -0
- package/dist/queen/advanced-integration-test.d.ts.map +1 -0
- package/dist/queen/advanced-integration-test.js +474 -0
- package/dist/queen/advanced-integration-test.js.map +1 -0
- package/dist/queen/agent-factory.d.ts +40 -0
- package/dist/queen/agent-factory.d.ts.map +1 -0
- package/dist/queen/agent-factory.js +433 -0
- package/dist/queen/agent-factory.js.map +1 -0
- package/dist/queen/index.d.ts +58 -0
- package/dist/queen/index.d.ts.map +1 -0
- package/dist/queen/index.js +79 -0
- package/dist/queen/index.js.map +1 -0
- package/dist/queen/integration-example.d.ts +82 -0
- package/dist/queen/integration-example.d.ts.map +1 -0
- package/dist/queen/integration-example.js +220 -0
- package/dist/queen/integration-example.js.map +1 -0
- package/dist/queen/integration-test.d.ts +72 -0
- package/dist/queen/integration-test.d.ts.map +1 -0
- package/dist/queen/integration-test.js +564 -0
- package/dist/queen/integration-test.js.map +1 -0
- package/dist/queen/mock-mcp-client.d.ts +66 -0
- package/dist/queen/mock-mcp-client.d.ts.map +1 -0
- package/dist/queen/mock-mcp-client.js +297 -0
- package/dist/queen/mock-mcp-client.js.map +1 -0
- package/dist/queen/neural-learning.d.ts +28 -0
- package/dist/queen/neural-learning.d.ts.map +1 -0
- package/dist/queen/neural-learning.js +244 -0
- package/dist/queen/neural-learning.js.map +1 -0
- package/dist/queen/queen-memory.d.ts +25 -0
- package/dist/queen/queen-memory.d.ts.map +1 -0
- package/dist/queen/queen-memory.js +273 -0
- package/dist/queen/queen-memory.js.map +1 -0
- package/dist/queen/run-integration-tests.d.ts +9 -0
- package/dist/queen/run-integration-tests.d.ts.map +1 -0
- package/dist/queen/run-integration-tests.js +28 -0
- package/dist/queen/run-integration-tests.js.map +1 -0
- package/dist/queen/servicenow-queen.d.ts +56 -0
- package/dist/queen/servicenow-queen.d.ts.map +1 -0
- package/dist/queen/servicenow-queen.js +659 -0
- package/dist/queen/servicenow-queen.js.map +1 -0
- package/dist/queen/types.d.ts +58 -0
- package/dist/queen/types.d.ts.map +1 -0
- package/dist/queen/types.js +7 -0
- package/dist/queen/types.js.map +1 -0
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +27 -2
- package/dist/version.js.map +1 -1
- package/docker/base/Dockerfile.base +45 -0
- package/docker/generate-services.js +244 -0
- package/docker/nginx/Dockerfile +71 -0
- package/docker/nginx/consul-template.hcl +64 -0
- package/docker/nginx/healthcheck.sh +178 -0
- package/docker/nginx/nginx.conf +210 -0
- package/docker/nginx/supervisord.conf +57 -0
- package/docker/nginx/templates/upstreams.conf.tpl +48 -0
- package/docker/services/automation-mcp/Dockerfile +32 -0
- package/docker/services/automation-mcp/config/service.json +28 -0
- package/docker/services/automation-mcp/entrypoint.js +51 -0
- package/docker/services/deployment-mcp/Dockerfile +32 -0
- package/docker/services/deployment-mcp/entrypoint.js +51 -0
- package/docker/services/flow-composer-mcp/Dockerfile +32 -0
- package/docker/services/flow-composer-mcp/config/service.json +28 -0
- package/docker/services/flow-composer-mcp/entrypoint.js +51 -0
- package/docker/services/graph-memory-mcp/Dockerfile +32 -0
- package/docker/services/graph-memory-mcp/config/service.json +28 -0
- package/docker/services/graph-memory-mcp/entrypoint.js +51 -0
- package/docker/services/integration-mcp/Dockerfile +32 -0
- package/docker/services/integration-mcp/config/service.json +28 -0
- package/docker/services/integration-mcp/entrypoint.js +51 -0
- package/docker/services/intelligent-mcp/Dockerfile +32 -0
- package/docker/services/intelligent-mcp/config/service.json +28 -0
- package/docker/services/intelligent-mcp/entrypoint.js +51 -0
- package/docker/services/operations-mcp/Dockerfile +32 -0
- package/docker/services/operations-mcp/config/service.json +28 -0
- package/docker/services/operations-mcp/entrypoint.js +51 -0
- package/docker/services/platform-development-mcp/Dockerfile +32 -0
- package/docker/services/platform-development-mcp/config/service.json +28 -0
- package/docker/services/platform-development-mcp/entrypoint.js +51 -0
- package/docker/services/reporting-analytics-mcp/Dockerfile +32 -0
- package/docker/services/reporting-analytics-mcp/config/service.json +28 -0
- package/docker/services/reporting-analytics-mcp/entrypoint.js +51 -0
- package/docker/services/security-compliance-mcp/Dockerfile +32 -0
- package/docker/services/security-compliance-mcp/config/service.json +28 -0
- package/docker/services/security-compliance-mcp/entrypoint.js +51 -0
- package/docker/services/update-set-mcp/Dockerfile +32 -0
- package/docker/services/update-set-mcp/config/service.json +28 -0
- package/docker/services/update-set-mcp/entrypoint.js +51 -0
- package/docker-compose.override.yml +132 -0
- package/docker-compose.prod.yml +340 -0
- package/docker-compose.yml +579 -0
- package/k8s/automation-mcp.yaml +232 -0
- package/k8s/configmap.yaml +237 -0
- package/k8s/deployment-mcp.yaml +232 -0
- package/k8s/flow-composer-mcp.yaml +232 -0
- package/k8s/generate-k8s-manifests.js +453 -0
- package/k8s/graph-memory-mcp.yaml +232 -0
- package/k8s/infrastructure.yaml +456 -0
- package/k8s/ingress.yaml +361 -0
- package/k8s/integration-mcp.yaml +232 -0
- package/k8s/intelligent-mcp.yaml +232 -0
- package/k8s/kustomization.yaml +111 -0
- package/k8s/mcp-services.yaml +2552 -0
- package/k8s/monitoring.yaml +515 -0
- package/k8s/namespace.yaml +80 -0
- package/k8s/operations-mcp.yaml +232 -0
- package/k8s/platform-development-mcp.yaml +232 -0
- package/k8s/rbac.yaml +140 -0
- package/k8s/reporting-analytics-mcp.yaml +232 -0
- package/k8s/security-compliance-mcp.yaml +232 -0
- package/k8s/update-set-mcp.yaml +232 -0
- package/package.json +2 -2
|
@@ -1369,8 +1369,162 @@ class ServiceNowIntelligentMCP {
|
|
|
1369
1369
|
if (results.length === 0) {
|
|
1370
1370
|
throw new Error('No matching artifact found');
|
|
1371
1371
|
}
|
|
1372
|
-
// Return the best match
|
|
1373
|
-
return results
|
|
1372
|
+
// Return the best match based on relevance scoring
|
|
1373
|
+
return this.selectBestMatch(results, intent);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Select the best matching artifact based on relevance scoring
|
|
1377
|
+
*/
|
|
1378
|
+
selectBestMatch(results, intent) {
|
|
1379
|
+
if (results.length === 1) {
|
|
1380
|
+
return results[0];
|
|
1381
|
+
}
|
|
1382
|
+
// Score each result based on multiple factors
|
|
1383
|
+
const scoredResults = results.map(result => {
|
|
1384
|
+
let score = 0;
|
|
1385
|
+
// Name/title similarity
|
|
1386
|
+
const name = (result.name || result.title || '').toLowerCase();
|
|
1387
|
+
const identifier = intent.identifier.toLowerCase();
|
|
1388
|
+
if (name === identifier) {
|
|
1389
|
+
score += 100; // Exact match
|
|
1390
|
+
}
|
|
1391
|
+
else if (name.includes(identifier) || identifier.includes(name)) {
|
|
1392
|
+
score += 50; // Partial match
|
|
1393
|
+
}
|
|
1394
|
+
// Type match
|
|
1395
|
+
if (result.type === intent.artifactType) {
|
|
1396
|
+
score += 30;
|
|
1397
|
+
}
|
|
1398
|
+
// Recency (prefer more recently updated)
|
|
1399
|
+
if (result.sys_updated_on) {
|
|
1400
|
+
const daysSinceUpdate = (Date.now() - new Date(result.sys_updated_on).getTime()) / (1000 * 60 * 60 * 24);
|
|
1401
|
+
score += Math.max(0, 10 - daysSinceUpdate); // More points for recent updates
|
|
1402
|
+
}
|
|
1403
|
+
// Active/non-test artifacts preferred
|
|
1404
|
+
if (result.active !== false && !name.includes('test') && !name.includes('mock')) {
|
|
1405
|
+
score += 10;
|
|
1406
|
+
}
|
|
1407
|
+
return { result, score };
|
|
1408
|
+
});
|
|
1409
|
+
// Sort by score and return the best match
|
|
1410
|
+
scoredResults.sort((a, b) => b.score - a.score);
|
|
1411
|
+
this.logger.info('Selected best match', {
|
|
1412
|
+
selected: scoredResults[0].result.name,
|
|
1413
|
+
score: scoredResults[0].score,
|
|
1414
|
+
totalResults: results.length
|
|
1415
|
+
});
|
|
1416
|
+
return scoredResults[0].result;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Perform comprehensive flow analysis and testing
|
|
1420
|
+
*/
|
|
1421
|
+
async performFlowAnalysis(sysId, flowType, flowData) {
|
|
1422
|
+
const analysis = {
|
|
1423
|
+
structureValid: false,
|
|
1424
|
+
triggerAnalysis: null,
|
|
1425
|
+
recommendedTests: [],
|
|
1426
|
+
performanceScore: 0,
|
|
1427
|
+
securityIssues: [],
|
|
1428
|
+
integrationPoints: []
|
|
1429
|
+
};
|
|
1430
|
+
try {
|
|
1431
|
+
// Analyze flow structure
|
|
1432
|
+
if (flowType === 'flow_designer' && flowData.latest_snapshot) {
|
|
1433
|
+
const snapshot = JSON.parse(flowData.latest_snapshot);
|
|
1434
|
+
const activities = snapshot.activities || snapshot.steps || [];
|
|
1435
|
+
analysis.structureValid = activities.length > 0;
|
|
1436
|
+
analysis.performanceScore = this.calculateFlowPerformanceScore(activities);
|
|
1437
|
+
analysis.securityIssues = this.identifySecurityIssues(activities);
|
|
1438
|
+
analysis.integrationPoints = this.findIntegrationPoints(activities);
|
|
1439
|
+
}
|
|
1440
|
+
// Analyze trigger conditions
|
|
1441
|
+
if (flowData.table && flowData.condition) {
|
|
1442
|
+
analysis.triggerAnalysis = {
|
|
1443
|
+
table: flowData.table,
|
|
1444
|
+
condition: flowData.condition,
|
|
1445
|
+
active: flowData.active,
|
|
1446
|
+
validTrigger: true
|
|
1447
|
+
};
|
|
1448
|
+
// Recommend specific tests based on trigger
|
|
1449
|
+
analysis.recommendedTests = this.generateFlowTestRecommendations(flowData);
|
|
1450
|
+
}
|
|
1451
|
+
return analysis;
|
|
1452
|
+
}
|
|
1453
|
+
catch (error) {
|
|
1454
|
+
this.logger.error('Flow analysis failed', { sysId, error: error.message });
|
|
1455
|
+
return {
|
|
1456
|
+
...analysis,
|
|
1457
|
+
error: error.message,
|
|
1458
|
+
recommendation: 'Use snow_test_flow_with_mock() for safer testing'
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
calculateFlowPerformanceScore(activities) {
|
|
1463
|
+
let score = 100;
|
|
1464
|
+
// Deduct points for potential performance issues
|
|
1465
|
+
activities.forEach(activity => {
|
|
1466
|
+
if (activity.type?.includes('wait') || activity.type?.includes('timer')) {
|
|
1467
|
+
score -= 5; // Wait activities can slow flows
|
|
1468
|
+
}
|
|
1469
|
+
if (activity.script && activity.script.length > 1000) {
|
|
1470
|
+
score -= 10; // Large scripts may impact performance
|
|
1471
|
+
}
|
|
1472
|
+
if (activity.type?.includes('loop')) {
|
|
1473
|
+
score -= 15; // Loops can be performance bottlenecks
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
return Math.max(0, score);
|
|
1477
|
+
}
|
|
1478
|
+
identifySecurityIssues(activities) {
|
|
1479
|
+
const issues = [];
|
|
1480
|
+
activities.forEach((activity, index) => {
|
|
1481
|
+
if (activity.script) {
|
|
1482
|
+
// Check for potential security issues
|
|
1483
|
+
if (activity.script.includes('eval(')) {
|
|
1484
|
+
issues.push(`Activity ${index + 1}: Uses eval() which is a security risk`);
|
|
1485
|
+
}
|
|
1486
|
+
if (activity.script.includes('gs.getUser().getUserID()') && !activity.script.includes('canRead')) {
|
|
1487
|
+
issues.push(`Activity ${index + 1}: May have access control issues`);
|
|
1488
|
+
}
|
|
1489
|
+
if (activity.script.includes('XMLHttpRequest')) {
|
|
1490
|
+
issues.push(`Activity ${index + 1}: External HTTP calls may pose security risks`);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
return issues;
|
|
1495
|
+
}
|
|
1496
|
+
findIntegrationPoints(activities) {
|
|
1497
|
+
const integrations = [];
|
|
1498
|
+
activities.forEach((activity, index) => {
|
|
1499
|
+
if (activity.type?.includes('rest') || activity.type?.includes('soap')) {
|
|
1500
|
+
integrations.push(`Activity ${index + 1}: External API integration (${activity.type})`);
|
|
1501
|
+
}
|
|
1502
|
+
if (activity.script && activity.script.includes('RESTMessage')) {
|
|
1503
|
+
integrations.push(`Activity ${index + 1}: REST Message integration`);
|
|
1504
|
+
}
|
|
1505
|
+
if (activity.script && activity.script.includes('SOAPMessage')) {
|
|
1506
|
+
integrations.push(`Activity ${index + 1}: SOAP Message integration`);
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
return integrations;
|
|
1510
|
+
}
|
|
1511
|
+
generateFlowTestRecommendations(flowData) {
|
|
1512
|
+
const recommendations = [];
|
|
1513
|
+
if (flowData.table) {
|
|
1514
|
+
recommendations.push(`Create test record in ${flowData.table} table`);
|
|
1515
|
+
}
|
|
1516
|
+
if (flowData.condition) {
|
|
1517
|
+
recommendations.push(`Test with records that match condition: ${flowData.condition}`);
|
|
1518
|
+
recommendations.push(`Test with records that don't match condition (negative test)`);
|
|
1519
|
+
}
|
|
1520
|
+
if (flowData.trigger_type === 'record_updated') {
|
|
1521
|
+
recommendations.push('Test by updating existing records');
|
|
1522
|
+
}
|
|
1523
|
+
else if (flowData.trigger_type === 'record_created') {
|
|
1524
|
+
recommendations.push('Test by creating new records');
|
|
1525
|
+
}
|
|
1526
|
+
recommendations.push('Use snow_test_flow_with_mock() for isolated testing');
|
|
1527
|
+
return recommendations;
|
|
1374
1528
|
}
|
|
1375
1529
|
async analyzeModification(intent, artifact) {
|
|
1376
1530
|
// Analyze what modification is needed
|
|
@@ -1638,14 +1792,16 @@ class ServiceNowIntelligentMCP {
|
|
|
1638
1792
|
async refreshCache(table) {
|
|
1639
1793
|
const results = [];
|
|
1640
1794
|
if (table) {
|
|
1641
|
-
//
|
|
1642
|
-
|
|
1643
|
-
|
|
1795
|
+
// Clear any cached data for specific table
|
|
1796
|
+
this.memoryIndex.clear(); // Clear in-memory cache
|
|
1797
|
+
results.push(`Cache cleared for table: ${table}`);
|
|
1798
|
+
results.push(`Note: This MCP uses real-time queries, no persistent cache to refresh`);
|
|
1644
1799
|
}
|
|
1645
1800
|
else {
|
|
1646
|
-
//
|
|
1647
|
-
|
|
1648
|
-
|
|
1801
|
+
// Clear all in-memory data
|
|
1802
|
+
this.memoryIndex.clear();
|
|
1803
|
+
results.push('All internal caches cleared');
|
|
1804
|
+
results.push(`Note: This MCP uses real-time ServiceNow queries for accuracy`);
|
|
1649
1805
|
}
|
|
1650
1806
|
return results;
|
|
1651
1807
|
}
|
|
@@ -1655,7 +1811,7 @@ class ServiceNowIntelligentMCP {
|
|
|
1655
1811
|
// Validate specific sys_id
|
|
1656
1812
|
try {
|
|
1657
1813
|
const record = await this.client.getRecord(table, sys_id);
|
|
1658
|
-
if (record) {
|
|
1814
|
+
if (record && record.success && record.data) {
|
|
1659
1815
|
results.push(`✅ sys_id ${sys_id} validated in table ${table}`);
|
|
1660
1816
|
}
|
|
1661
1817
|
else {
|
|
@@ -1667,24 +1823,102 @@ class ServiceNowIntelligentMCP {
|
|
|
1667
1823
|
}
|
|
1668
1824
|
}
|
|
1669
1825
|
else {
|
|
1670
|
-
// Validate all known sys_ids in memory
|
|
1671
|
-
|
|
1672
|
-
|
|
1826
|
+
// Validate all known sys_ids in memory index
|
|
1827
|
+
const memoryEntries = Array.from(this.memoryIndex.entries());
|
|
1828
|
+
if (memoryEntries.length === 0) {
|
|
1829
|
+
results.push('📝 No sys_ids found in memory index to validate');
|
|
1830
|
+
return results;
|
|
1831
|
+
}
|
|
1832
|
+
results.push(`🔍 Validating ${memoryEntries.length} sys_ids from memory index...`);
|
|
1833
|
+
let validCount = 0;
|
|
1834
|
+
let invalidCount = 0;
|
|
1835
|
+
for (const [key, data] of memoryEntries) {
|
|
1836
|
+
// Extract sys_id and table from memory data if available
|
|
1837
|
+
try {
|
|
1838
|
+
if (data.sys_id && data.table) {
|
|
1839
|
+
const record = await this.client.getRecord(data.table, data.sys_id);
|
|
1840
|
+
if (record && record.success && record.data) {
|
|
1841
|
+
validCount++;
|
|
1842
|
+
}
|
|
1843
|
+
else {
|
|
1844
|
+
invalidCount++;
|
|
1845
|
+
results.push(`❌ Invalid: ${data.sys_id} in ${data.table}`);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
catch (error) {
|
|
1850
|
+
invalidCount++;
|
|
1851
|
+
results.push(`❌ Validation error for ${key}: ${error}`);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
results.push(`✅ Validation complete: ${validCount} valid, ${invalidCount} invalid`);
|
|
1673
1855
|
}
|
|
1674
1856
|
return results;
|
|
1675
1857
|
}
|
|
1676
1858
|
async reindexArtifacts(table) {
|
|
1677
1859
|
const results = [];
|
|
1678
1860
|
if (table) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1861
|
+
// Re-index artifacts from specific table
|
|
1862
|
+
try {
|
|
1863
|
+
// Query the table to get current artifacts
|
|
1864
|
+
const searchResults = await this.client.searchRecords(table, 'sys_idISNOTEMPTY', 100);
|
|
1865
|
+
if (searchResults.success && searchResults.data) {
|
|
1866
|
+
const artifacts = Array.isArray(searchResults.data) ? searchResults.data : [searchResults.data];
|
|
1867
|
+
// Clear existing entries for this table
|
|
1868
|
+
for (const [key, data] of this.memoryIndex.entries()) {
|
|
1869
|
+
if (data.table === table) {
|
|
1870
|
+
this.memoryIndex.delete(key);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
// Re-index with fresh data
|
|
1874
|
+
let indexedCount = 0;
|
|
1875
|
+
for (const artifact of artifacts) {
|
|
1876
|
+
if (artifact.sys_id && artifact.name) {
|
|
1877
|
+
const indexKey = `${table}_${artifact.name.replace(/\s+/g, '_')}`;
|
|
1878
|
+
this.memoryIndex.set(indexKey, {
|
|
1879
|
+
sys_id: artifact.sys_id,
|
|
1880
|
+
table: table,
|
|
1881
|
+
name: artifact.name,
|
|
1882
|
+
type: this.getArtifactTypeFromTable(table),
|
|
1883
|
+
indexed_at: new Date().toISOString()
|
|
1884
|
+
});
|
|
1885
|
+
indexedCount++;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
results.push(`✅ Re-indexed ${indexedCount} artifacts from table: ${table}`);
|
|
1889
|
+
}
|
|
1890
|
+
else {
|
|
1891
|
+
results.push(`⚠️ Could not fetch artifacts from table: ${table}`);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
catch (error) {
|
|
1895
|
+
results.push(`❌ Re-indexing failed for table ${table}: ${error}`);
|
|
1896
|
+
}
|
|
1681
1897
|
}
|
|
1682
1898
|
else {
|
|
1683
|
-
|
|
1684
|
-
|
|
1899
|
+
// Re-index all known artifact tables
|
|
1900
|
+
const artifactTables = ['sp_widget', 'wf_workflow', 'sys_script_include', 'sys_script'];
|
|
1901
|
+
results.push(`🔍 Re-indexing artifacts from ${artifactTables.length} tables...`);
|
|
1902
|
+
let totalIndexed = 0;
|
|
1903
|
+
for (const tableName of artifactTables) {
|
|
1904
|
+
const tableResults = await this.reindexArtifacts(tableName);
|
|
1905
|
+
totalIndexed += tableResults.filter(r => r.includes('✅')).length;
|
|
1906
|
+
}
|
|
1907
|
+
results.push(`✅ Global re-indexing complete: ${totalIndexed} artifacts indexed`);
|
|
1908
|
+
results.push(`💾 Memory index size: ${this.memoryIndex.size} entries`);
|
|
1685
1909
|
}
|
|
1686
1910
|
return results;
|
|
1687
1911
|
}
|
|
1912
|
+
getArtifactTypeFromTable(table) {
|
|
1913
|
+
const tableTypeMap = {
|
|
1914
|
+
'sp_widget': 'widget',
|
|
1915
|
+
'wf_workflow': 'flow',
|
|
1916
|
+
'sys_script_include': 'script',
|
|
1917
|
+
'sys_script': 'business_rule',
|
|
1918
|
+
'sys_db_object': 'table'
|
|
1919
|
+
};
|
|
1920
|
+
return tableTypeMap[table] || 'unknown';
|
|
1921
|
+
}
|
|
1688
1922
|
async performFullSync() {
|
|
1689
1923
|
const results = [];
|
|
1690
1924
|
// Combine all sync operations
|
|
@@ -1864,8 +2098,8 @@ class ServiceNowIntelligentMCP {
|
|
|
1864
2098
|
// For flows that can be triggered programmatically
|
|
1865
2099
|
const startTime = Date.now();
|
|
1866
2100
|
try {
|
|
1867
|
-
// Attempt to
|
|
1868
|
-
|
|
2101
|
+
// Attempt to analyze and test the flow based on its type and trigger conditions
|
|
2102
|
+
const testResult = await this.performFlowAnalysis(sys_id, flowType, flowDetails.result);
|
|
1869
2103
|
let flowActivities;
|
|
1870
2104
|
if (flowType === 'flow_designer') {
|
|
1871
2105
|
// For modern flows, get activities from flow definition
|