snow-flow 3.0.8 → 3.0.10

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.
Files changed (295) hide show
  1. package/claude-flow.bat +0 -0
  2. package/claude-flow.ps1 +0 -0
  3. package/dist/mcp/servicenow-automation-mcp.js +0 -0
  4. package/dist/mcp/servicenow-deployment-mcp.js +0 -0
  5. package/dist/mcp/servicenow-integration-mcp.js +0 -0
  6. package/dist/mcp/servicenow-mcp-server.js +0 -0
  7. package/dist/mcp/servicenow-operations-mcp.js +0 -0
  8. package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
  9. package/dist/mcp/servicenow-progressive-indexer.js +0 -0
  10. package/dist/mcp/servicenow-reporting-analytics-mcp.js +133 -19
  11. package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
  12. package/dist/mcp/servicenow-update-set-mcp.js +0 -0
  13. package/dist/mcp/start-all-mcp-servers.js +0 -0
  14. package/dist/mcp/start-servicenow-mcp.js +0 -0
  15. package/dist/utils/snow-oauth.js +53 -16
  16. package/memory/agents/README.md +1 -1
  17. package/memory/claude-flow-data.json +1 -1
  18. package/memory/sessions/README.md +1 -1
  19. package/package.json +2 -2
  20. package/.mcp.json +0 -22
  21. package/claude-flow.config.json +0 -20
  22. package/dist/agents/app-creator.agent.d.ts +0 -55
  23. package/dist/agents/app-creator.agent.js +0 -1292
  24. package/dist/agents/base/base-snow-agent.d.ts +0 -75
  25. package/dist/agents/base/base-snow-agent.js +0 -169
  26. package/dist/agents/base-snow-agent.d.ts +0 -63
  27. package/dist/agents/base-snow-agent.js +0 -296
  28. package/dist/agents/coordinator.d.ts +0 -200
  29. package/dist/agents/coordinator.js +0 -777
  30. package/dist/agents/flow-builder-agent.d.ts +0 -18
  31. package/dist/agents/flow-builder-agent.js +0 -197
  32. package/dist/agents/queen-403-handler.d.ts +0 -47
  33. package/dist/agents/queen-403-handler.js +0 -175
  34. package/dist/agents/queen-agent-example.d.ts +0 -23
  35. package/dist/agents/queen-agent-example.js +0 -240
  36. package/dist/agents/queen-agent.test.d.ts +0 -6
  37. package/dist/agents/script-generator.agent.d.ts +0 -32
  38. package/dist/agents/script-generator.agent.js +0 -772
  39. package/dist/agents/script-writer-agent.d.ts +0 -22
  40. package/dist/agents/script-writer-agent.js +0 -695
  41. package/dist/agents/security-agent.d.ts +0 -23
  42. package/dist/agents/security-agent.js +0 -619
  43. package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
  44. package/dist/agents/specialists/automation-specialist.agent.js +0 -204
  45. package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
  46. package/dist/agents/specialists/data-specialist.agent.js +0 -484
  47. package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
  48. package/dist/agents/specialists/integration-specialist.agent.js +0 -725
  49. package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
  50. package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
  51. package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
  52. package/dist/agents/specialists/security-specialist.agent.js +0 -309
  53. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
  54. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
  55. package/dist/agents/teams/base-team.d.ts +0 -72
  56. package/dist/agents/teams/base-team.js +0 -253
  57. package/dist/agents/teams/team-types.d.ts +0 -265
  58. package/dist/agents/teams/team-types.js +0 -3
  59. package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
  60. package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
  61. package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
  62. package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
  63. package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
  64. package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
  65. package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
  66. package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
  67. package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
  68. package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
  69. package/dist/agents/test-agent.d.ts +0 -26
  70. package/dist/agents/test-agent.js +0 -734
  71. package/dist/agents/test-agents.d.ts +0 -7
  72. package/dist/agents/test-agents.js +0 -64
  73. package/dist/agents/ui-builder.agent.d.ts +0 -50
  74. package/dist/agents/ui-builder.agent.js +0 -1539
  75. package/dist/agents/widget-builder.agent.d.ts +0 -32
  76. package/dist/agents/widget-builder.agent.js +0 -439
  77. package/dist/agents/widget-creator-agent.d.ts +0 -18
  78. package/dist/agents/widget-creator-agent.js +0 -498
  79. package/dist/agents/workflow-designer.agent.d.ts +0 -31
  80. package/dist/agents/workflow-designer.agent.js +0 -583
  81. package/dist/api/error-handling.d.ts +0 -325
  82. package/dist/api/error-handling.js +0 -1488
  83. package/dist/api/flow-designer-api.d.ts +0 -167
  84. package/dist/api/flow-designer-api.js +0 -554
  85. package/dist/api/natural-language-mapper.d.ts +0 -124
  86. package/dist/api/natural-language-mapper.js +0 -501
  87. package/dist/api/performance-optimizer.d.ts +0 -240
  88. package/dist/api/performance-optimizer.js +0 -706
  89. package/dist/api/transaction-manager.d.ts +0 -189
  90. package/dist/api/transaction-manager.js +0 -576
  91. package/dist/assembly/team-assembler.d.ts +0 -140
  92. package/dist/assembly/team-assembler.js +0 -502
  93. package/dist/benchmark-performance.d.ts +0 -41
  94. package/dist/benchmark-performance.js +0 -230
  95. package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
  96. package/dist/cli/snow-flow-cli-integration.js +0 -396
  97. package/dist/coordination/coordination-engine.d.ts +0 -41
  98. package/dist/coordination/coordination-engine.js +0 -324
  99. package/dist/coordination/coordination.test.d.ts +0 -6
  100. package/dist/coordination/example.d.ts +0 -31
  101. package/dist/coordination/example.js +0 -394
  102. package/dist/coordination/execution-patterns.d.ts +0 -43
  103. package/dist/coordination/execution-patterns.js +0 -507
  104. package/dist/coordination/factory.d.ts +0 -94
  105. package/dist/coordination/factory.js +0 -433
  106. package/dist/coordination/index.d.ts +0 -71
  107. package/dist/coordination/index.js +0 -135
  108. package/dist/coordination/progress-monitor.d.ts +0 -71
  109. package/dist/coordination/progress-monitor.js +0 -505
  110. package/dist/coordination/quality-gates.d.ts +0 -124
  111. package/dist/coordination/quality-gates.js +0 -577
  112. package/dist/coordination/shared-memory.d.ts +0 -39
  113. package/dist/coordination/shared-memory.js +0 -289
  114. package/dist/coordination/task-dependencies.d.ts +0 -50
  115. package/dist/coordination/task-dependencies.js +0 -407
  116. package/dist/coordination/team-coordinator.d.ts +0 -59
  117. package/dist/coordination/team-coordinator.js +0 -550
  118. package/dist/coordination/types.d.ts +0 -152
  119. package/dist/coordination/types.js +0 -3
  120. package/dist/mcp/mcp-wrapper.d.ts +0 -8
  121. package/dist/mcp/mcp-wrapper.js +0 -77
  122. package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
  123. package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
  124. package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
  125. package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
  126. package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
  127. package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
  128. package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
  129. package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
  130. package/dist/mcp/singleton-check.js +0 -31
  131. package/dist/mcp/test-simple-mcp.d.ts +0 -6
  132. package/dist/mcp/test-simple-mcp.js +0 -63
  133. package/dist/memory/hierarchical-memory-system.d.ts +0 -90
  134. package/dist/memory/hierarchical-memory-system.js +0 -400
  135. package/dist/memory/index.d.ts +0 -9
  136. package/dist/memory/index.js +0 -20
  137. package/dist/memory/mcp-integration-example.d.ts +0 -6
  138. package/dist/memory/mcp-integration-example.js +0 -281
  139. package/dist/memory/memory-client.d.ts +0 -199
  140. package/dist/memory/memory-client.js +0 -364
  141. package/dist/memory/memory-manager.d.ts +0 -29
  142. package/dist/memory/memory-manager.js +0 -280
  143. package/dist/memory/memory-operations.d.ts +0 -179
  144. package/dist/memory/memory-operations.js +0 -691
  145. package/dist/memory/memory-system.d.ts +0 -153
  146. package/dist/memory/memory-system.js +0 -651
  147. package/dist/memory/memory-test.d.ts +0 -6
  148. package/dist/memory/memory-test.js +0 -161
  149. package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
  150. package/dist/memory/snow-flow-memory-patterns.js +0 -200
  151. package/dist/memory/snow-memory.d.ts +0 -54
  152. package/dist/memory/snow-memory.js +0 -301
  153. package/dist/memory/swarm-memory.d.ts +0 -135
  154. package/dist/memory/swarm-memory.js +0 -378
  155. package/dist/optimization/flow-performance-optimizer.js +0 -723
  156. package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
  157. package/dist/orchestration/discovery/service-discovery.js +0 -808
  158. package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
  159. package/dist/orchestration/distributed-orchestrator.js +0 -712
  160. package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
  161. package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
  162. package/dist/orchestration/flow-update-orchestrator.js +0 -648
  163. package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
  164. package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
  165. package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
  166. package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
  167. package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
  168. package/dist/orchestration/state/distributed-state-manager.js +0 -716
  169. package/dist/orchestrator/flow-composer.d.ts +0 -105
  170. package/dist/orchestrator/flow-composer.js +0 -404
  171. package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
  172. package/dist/orchestrator/flow-pattern-templates.js +0 -908
  173. package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
  174. package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
  175. package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
  176. package/dist/orchestrator/flow-validation-engine.js +0 -913
  177. package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
  178. package/dist/orchestrator/snow-orchestrator.js +0 -235
  179. package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
  180. package/dist/orchestrator/subflow-creation-handler.js +0 -791
  181. package/dist/patterns/adaptive-patterns.d.ts +0 -140
  182. package/dist/patterns/adaptive-patterns.js +0 -549
  183. package/dist/queen/advanced-integration-test.d.ts +0 -48
  184. package/dist/queen/advanced-integration-test.js +0 -473
  185. package/dist/queen/integration-example.d.ts +0 -82
  186. package/dist/queen/integration-example.js +0 -219
  187. package/dist/queen/integration-test.d.ts +0 -72
  188. package/dist/queen/integration-test.js +0 -563
  189. package/dist/queen/mock-mcp-client.d.ts +0 -71
  190. package/dist/queen/mock-mcp-client.js +0 -317
  191. package/dist/queen/run-integration-tests.d.ts +0 -9
  192. package/dist/queen/run-integration-tests.js +0 -27
  193. package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
  194. package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
  195. package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
  196. package/dist/sparc/coordinators/team-coordinator.js +0 -402
  197. package/dist/sparc/modes/team-modes.d.ts +0 -33
  198. package/dist/sparc/modes/team-modes.js +0 -399
  199. package/dist/sparc/teams/application-team.d.ts +0 -73
  200. package/dist/sparc/teams/application-team.js +0 -463
  201. package/dist/sparc/teams/flow-team.d.ts +0 -67
  202. package/dist/sparc/teams/flow-team.js +0 -373
  203. package/dist/sparc/teams/widget-team.d.ts +0 -61
  204. package/dist/sparc/teams/widget-team.js +0 -280
  205. package/dist/specialists/app-specialists.d.ts +0 -93
  206. package/dist/specialists/app-specialists.js +0 -1639
  207. package/dist/specialists/base-specialist.d.ts +0 -19
  208. package/dist/specialists/base-specialist.js +0 -54
  209. package/dist/specialists/flow-specialists.d.ts +0 -113
  210. package/dist/specialists/flow-specialists.js +0 -1787
  211. package/dist/specialists/individual-specialists.d.ts +0 -67
  212. package/dist/specialists/individual-specialists.js +0 -632
  213. package/dist/specialists/widget-specialists.d.ts +0 -70
  214. package/dist/specialists/widget-specialists.js +0 -1264
  215. package/dist/src/utils/agent-detector.js +0 -655
  216. package/dist/teams/adaptive-team.d.ts +0 -81
  217. package/dist/teams/adaptive-team.js +0 -1153
  218. package/dist/teams/application-team.d.ts +0 -30
  219. package/dist/teams/application-team.js +0 -547
  220. package/dist/teams/base-team.d.ts +0 -55
  221. package/dist/teams/base-team.js +0 -243
  222. package/dist/teams/flow-team.d.ts +0 -28
  223. package/dist/teams/flow-team.js +0 -525
  224. package/dist/teams/widget-team.d.ts +0 -26
  225. package/dist/teams/widget-team.js +0 -459
  226. package/dist/templates/flow-template-system.js +0 -625
  227. package/dist/test-fetch-incidents.d.ts +0 -2
  228. package/dist/test-fetch-incidents.js +0 -84
  229. package/dist/test-incident-access.d.ts +0 -2
  230. package/dist/test-incident-access.js +0 -72
  231. package/dist/test-iphone-flow.js +0 -189
  232. package/dist/test-limit-problem.d.ts +0 -2
  233. package/dist/test-limit-problem.js +0 -60
  234. package/dist/test-ml-batch-fix.d.ts +0 -2
  235. package/dist/test-ml-batch-fix.js +0 -104
  236. package/dist/test-ml-batch.d.ts +0 -2
  237. package/dist/test-ml-batch.js +0 -87
  238. package/dist/test-ml-query.d.ts +0 -2
  239. package/dist/test-ml-query.js +0 -100
  240. package/dist/test-ml-training-fix.d.ts +0 -12
  241. package/dist/test-ml-training-fix.js +0 -113
  242. package/dist/test-ml-training.d.ts +0 -2
  243. package/dist/test-ml-training.js +0 -32
  244. package/dist/test-operations-query.d.ts +0 -2
  245. package/dist/test-operations-query.js +0 -84
  246. package/dist/test-performance-query.d.ts +0 -2
  247. package/dist/test-performance-query.js +0 -52
  248. package/dist/test-singleton-protection.d.ts +0 -8
  249. package/dist/test-singleton-protection.js +0 -110
  250. package/dist/test-smart-limits.d.ts +0 -13
  251. package/dist/test-smart-limits.js +0 -100
  252. package/dist/test-snow-query-incidents.d.ts +0 -2
  253. package/dist/test-snow-query-incidents.js +0 -66
  254. package/dist/test-universal-query.d.ts +0 -2
  255. package/dist/test-universal-query.js +0 -106
  256. package/dist/testing/flow-testing-automation.js +0 -641
  257. package/dist/utils/complete-flow-xml-generator.js +0 -1285
  258. package/dist/utils/file-storage-fallback.d.ts +0 -62
  259. package/dist/utils/file-storage-fallback.js +0 -289
  260. package/dist/utils/flow-api-discovery.d.ts +0 -151
  261. package/dist/utils/flow-api-discovery.js +0 -439
  262. package/dist/utils/flow-examples.js +0 -720
  263. package/dist/utils/flow-structure-builder.js +0 -677
  264. package/dist/utils/flow-xml-generator.d.ts +0 -41
  265. package/dist/utils/flow-xml-generator.js +0 -258
  266. package/dist/utils/improved-flow-xml-generator.js +0 -820
  267. package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
  268. package/dist/utils/mcp-process-manager.backup.js +0 -220
  269. package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
  270. package/dist/utils/mcp-singleton-enforcer.js +0 -201
  271. package/dist/utils/mcp-timeout-fix.d.ts +0 -53
  272. package/dist/utils/mcp-timeout-fix.js +0 -221
  273. package/dist/utils/migrate-claude-flow.d.ts +0 -22
  274. package/dist/utils/migrate-claude-flow.js +0 -120
  275. package/dist/utils/scope-utils.d.ts +0 -72
  276. package/dist/utils/scope-utils.js +0 -386
  277. package/dist/utils/snow-oauth-old.d.ts +0 -65
  278. package/dist/utils/snow-oauth-old.js +0 -345
  279. package/dist/utils/xml-first-flow-generator.js +0 -513
  280. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
  281. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
  282. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
  283. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
  284. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
  285. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
  286. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
  287. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
  288. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
  289. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
  290. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
  291. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
  292. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
  293. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
  294. package/reports/swarm-auto-centralized-1752649029776.json +0 -13
  295. package/src/memory/README.md +0 -240
@@ -1,723 +0,0 @@
1
- "use strict";
2
- /**
3
- * 🚀 Flow Performance Optimization Engine
4
- *
5
- * Advanced performance optimization system that analyzes ServiceNow flows,
6
- * identifies bottlenecks, and applies intelligent optimizations to improve
7
- * execution speed, reduce resource usage, and enhance scalability.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.FlowPerformanceOptimizer = void 0;
11
- const logger_js_1 = require("../utils/logger.js");
12
- class FlowPerformanceOptimizer {
13
- constructor(client, memory) {
14
- this.profiles = new Map();
15
- this.executions = new Map();
16
- this.benchmarks = new Map();
17
- this.logger = new logger_js_1.Logger('FlowPerformanceOptimizer');
18
- this.client = client;
19
- this.memory = memory;
20
- // Initialize performance benchmarks
21
- this.initializeBenchmarks();
22
- }
23
- /**
24
- * Analyze flow performance and identify optimization opportunities
25
- */
26
- async analyzeFlowPerformance(flowDefinition, options = {}) {
27
- this.logger.info('🔍 Analyzing flow performance', {
28
- flowName: flowDefinition.name,
29
- options
30
- });
31
- const profileId = `perf_${Date.now()}_${Math.random().toString(36).substr(2, 8)}`;
32
- try {
33
- // Collect performance metrics
34
- const metrics = await this.collectPerformanceMetrics(flowDefinition, options);
35
- // Identify bottlenecks
36
- const bottlenecks = await this.identifyBottlenecks(flowDefinition, metrics);
37
- // Generate optimization recommendations
38
- const optimizations = await this.generateOptimizationRecommendations(flowDefinition, metrics, bottlenecks);
39
- // Assess risks
40
- const riskAssessment = this.assessOptimizationRisks(optimizations);
41
- // Load benchmarks
42
- const benchmarks = this.benchmarks.get(flowDefinition.table || 'generic') || [];
43
- const profile = {
44
- flowId: profileId,
45
- flowName: flowDefinition.name,
46
- analysisDate: new Date().toISOString(),
47
- version: '1.0.0',
48
- metrics,
49
- bottlenecks,
50
- optimizations,
51
- riskAssessment,
52
- benchmarks
53
- };
54
- // Store profile
55
- this.profiles.set(profileId, profile);
56
- await this.memory.store(`perf_profile_${profileId}`, profile, 604800000); // 7 days
57
- this.logger.info('✅ Performance analysis completed', {
58
- profileId,
59
- bottlenecksFound: bottlenecks.length,
60
- optimizationsRecommended: optimizations.length,
61
- riskLevel: riskAssessment.overall
62
- });
63
- return profile;
64
- }
65
- catch (error) {
66
- this.logger.error('❌ Performance analysis failed', error);
67
- throw error;
68
- }
69
- }
70
- /**
71
- * Execute optimization recommendations
72
- */
73
- async executeOptimizations(profileId, recommendationIds, options = {}) {
74
- this.logger.info('🚀 Executing performance optimizations', {
75
- profileId,
76
- recommendationIds,
77
- options
78
- });
79
- const profile = this.profiles.get(profileId);
80
- if (!profile) {
81
- throw new Error(`Performance profile not found: ${profileId}`);
82
- }
83
- const executionId = `exec_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`;
84
- const execution = {
85
- id: executionId,
86
- profileId,
87
- recommendationIds,
88
- startTime: new Date().toISOString(),
89
- status: 'planning',
90
- progress: 0,
91
- results: [],
92
- issues: []
93
- };
94
- this.executions.set(executionId, execution);
95
- try {
96
- execution.status = 'executing';
97
- // Filter and sort recommendations by priority
98
- const recommendations = profile.optimizations
99
- .filter(opt => recommendationIds.includes(opt.id))
100
- .sort((a, b) => this.getPriorityWeight(b.priority) - this.getPriorityWeight(a.priority));
101
- const totalRecommendations = recommendations.length;
102
- // Execute recommendations
103
- if (options.parallel && !options.stopOnFailure) {
104
- // Parallel execution
105
- const promises = recommendations.map((rec, index) => this.executeOptimizationRecommendation(rec, options.dryRun || false, execution)
106
- .then(result => {
107
- execution.results.push(result);
108
- execution.progress = ((index + 1) / totalRecommendations) * 100;
109
- }));
110
- await Promise.allSettled(promises);
111
- }
112
- else {
113
- // Sequential execution
114
- for (let i = 0; i < recommendations.length; i++) {
115
- const recommendation = recommendations[i];
116
- execution.progress = ((i + 1) / totalRecommendations) * 100;
117
- try {
118
- const result = await this.executeOptimizationRecommendation(recommendation, options.dryRun || false, execution);
119
- execution.results.push(result);
120
- if (result.status === 'failed' && options.stopOnFailure) {
121
- this.logger.warn('Stopping optimization execution due to failure', {
122
- failedRecommendation: recommendation.id
123
- });
124
- break;
125
- }
126
- }
127
- catch (error) {
128
- execution.issues.push({
129
- severity: 'high',
130
- type: 'implementation_error',
131
- description: `Failed to execute recommendation: ${recommendation.title}`,
132
- recommendationId: recommendation.id,
133
- autoResolved: false
134
- });
135
- if (options.stopOnFailure) {
136
- throw error;
137
- }
138
- }
139
- }
140
- }
141
- // Validate results
142
- execution.status = 'testing';
143
- await this.validateOptimizationResults(execution, options.validationLevel || 'comprehensive');
144
- // Complete execution
145
- execution.status = 'completed';
146
- execution.endTime = new Date().toISOString();
147
- execution.progress = 100;
148
- this.logger.info('✅ Optimization execution completed', {
149
- executionId,
150
- successfulOptimizations: execution.results.filter(r => r.status === 'success').length,
151
- failedOptimizations: execution.results.filter(r => r.status === 'failed').length,
152
- issues: execution.issues.length
153
- });
154
- return execution;
155
- }
156
- catch (error) {
157
- execution.status = 'failed';
158
- execution.endTime = new Date().toISOString();
159
- this.logger.error('❌ Optimization execution failed', error);
160
- throw error;
161
- }
162
- finally {
163
- // Store execution results
164
- await this.memory.store(`opt_execution_${executionId}`, execution, 604800000); // 7 days
165
- }
166
- }
167
- /**
168
- * Get performance profiles with filtering
169
- */
170
- getPerformanceProfiles(filter) {
171
- let profiles = Array.from(this.profiles.values());
172
- if (filter) {
173
- if (filter.flowName) {
174
- profiles = profiles.filter(p => p.flowName.toLowerCase().includes(filter.flowName.toLowerCase()));
175
- }
176
- if (filter.minBottlenecks) {
177
- profiles = profiles.filter(p => p.bottlenecks.length >= filter.minBottlenecks);
178
- }
179
- if (filter.riskLevel) {
180
- profiles = profiles.filter(p => p.riskAssessment.overall === filter.riskLevel);
181
- }
182
- if (filter.dateRange) {
183
- const fromDate = new Date(filter.dateRange.from);
184
- const toDate = new Date(filter.dateRange.to);
185
- profiles = profiles.filter(p => {
186
- const profileDate = new Date(p.analysisDate);
187
- return profileDate >= fromDate && profileDate <= toDate;
188
- });
189
- }
190
- }
191
- return profiles.sort((a, b) => new Date(b.analysisDate).getTime() - new Date(a.analysisDate).getTime());
192
- }
193
- /**
194
- * Get optimization executions
195
- */
196
- getOptimizationExecutions() {
197
- return Array.from(this.executions.values())
198
- .sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
199
- }
200
- /**
201
- * Generate performance report
202
- */
203
- async generatePerformanceReport(profileId, format = 'detailed') {
204
- const profile = this.profiles.get(profileId);
205
- if (!profile) {
206
- throw new Error(`Performance profile not found: ${profileId}`);
207
- }
208
- // Generate different report formats
209
- switch (format) {
210
- case 'summary':
211
- return this.generateSummaryReport(profile);
212
- case 'detailed':
213
- return this.generateDetailedReport(profile);
214
- case 'executive':
215
- return this.generateExecutiveReport(profile);
216
- default:
217
- return this.generateDetailedReport(profile);
218
- }
219
- }
220
- /**
221
- * Private helper methods
222
- */
223
- async collectPerformanceMetrics(flowDefinition, options) {
224
- // Simulate performance metrics collection
225
- return {
226
- executionTime: {
227
- average: 1500,
228
- median: 1200,
229
- p95: 2800,
230
- p99: 4500,
231
- min: 800,
232
- max: 8000
233
- },
234
- resourceUsage: {
235
- memory: {
236
- peak: 50 * 1024 * 1024, // 50MB
237
- average: 25 * 1024 * 1024, // 25MB
238
- leaks: false
239
- },
240
- cpu: {
241
- average: 15,
242
- peak: 45,
243
- efficiency: 0.75
244
- },
245
- database: {
246
- queries: 12,
247
- slowQueries: 2,
248
- averageQueryTime: 150
249
- },
250
- api: {
251
- calls: 8,
252
- averageResponseTime: 300,
253
- timeouts: 0
254
- }
255
- },
256
- throughput: {
257
- recordsPerSecond: 25,
258
- requestsPerMinute: 120,
259
- concurrentExecutions: 5
260
- },
261
- reliability: {
262
- successRate: 98.5,
263
- errorRate: 1.5,
264
- retryRate: 0.8,
265
- timeoutRate: 0.2
266
- }
267
- };
268
- }
269
- async identifyBottlenecks(flowDefinition, metrics) {
270
- const bottlenecks = [];
271
- // Database bottleneck detection
272
- if (metrics.resourceUsage.database.slowQueries > 0) {
273
- bottlenecks.push({
274
- id: 'db_slow_queries',
275
- type: 'database',
276
- severity: 'high',
277
- location: 'Database queries',
278
- description: `${metrics.resourceUsage.database.slowQueries} slow database queries detected`,
279
- impact: {
280
- performanceDegradation: 35,
281
- resourceOverhead: 20,
282
- scalabilityLimit: 50,
283
- financialCost: 150,
284
- userExperience: 'significant'
285
- },
286
- rootCause: 'Missing database indexes or inefficient query patterns',
287
- measurementData: {
288
- samples: 100,
289
- averageValue: metrics.resourceUsage.database.averageQueryTime,
290
- standardDeviation: 45,
291
- trend: 'stable',
292
- confidence: 0.9
293
- },
294
- detectionMethod: 'Query performance analysis'
295
- });
296
- }
297
- // Memory bottleneck detection
298
- if (metrics.resourceUsage.memory.peak > 40 * 1024 * 1024) { // 40MB threshold
299
- bottlenecks.push({
300
- id: 'memory_usage',
301
- type: 'memory',
302
- severity: 'medium',
303
- location: 'Flow execution',
304
- description: 'High memory usage detected during flow execution',
305
- impact: {
306
- performanceDegradation: 15,
307
- resourceOverhead: 30,
308
- scalabilityLimit: 75,
309
- financialCost: 50,
310
- userExperience: 'moderate'
311
- },
312
- rootCause: 'Large data processing without proper memory management',
313
- measurementData: {
314
- samples: 50,
315
- averageValue: metrics.resourceUsage.memory.average,
316
- standardDeviation: 5 * 1024 * 1024,
317
- trend: 'stable',
318
- confidence: 0.85
319
- },
320
- detectionMethod: 'Memory profiling'
321
- });
322
- }
323
- return bottlenecks;
324
- }
325
- async generateOptimizationRecommendations(flowDefinition, metrics, bottlenecks) {
326
- const recommendations = [];
327
- // Database optimization recommendations
328
- const dbBottlenecks = bottlenecks.filter(b => b.type === 'database');
329
- if (dbBottlenecks.length > 0) {
330
- recommendations.push({
331
- id: 'db_index_optimization',
332
- type: 'indexing',
333
- priority: 'high',
334
- title: 'Optimize Database Indexes',
335
- description: 'Add strategic database indexes to improve query performance',
336
- implementation: {
337
- method: 'automatic',
338
- steps: [
339
- {
340
- order: 1,
341
- action: 'analyze_query_patterns',
342
- description: 'Analyze slow query patterns to identify optimal indexes',
343
- parameters: { analysis_period: '7d' },
344
- validation: 'Query analysis completed successfully'
345
- },
346
- {
347
- order: 2,
348
- action: 'create_indexes',
349
- description: 'Create recommended database indexes',
350
- parameters: { index_strategy: 'composite' },
351
- validation: 'Indexes created and operational'
352
- }
353
- ],
354
- estimatedTime: 30,
355
- rollbackPlan: 'Drop created indexes if performance degrades',
356
- prerequisites: ['Database admin privileges'],
357
- testingRequired: true
358
- },
359
- expectedImpact: {
360
- performanceImprovement: {
361
- executionTime: 40,
362
- throughput: 60,
363
- resourceUsage: 25
364
- },
365
- reliability: {
366
- errorReduction: 15,
367
- availabilityImprovement: 5
368
- },
369
- scalability: {
370
- capacityIncrease: 100,
371
- concurrencyImprovement: 150
372
- },
373
- cost: {
374
- resourceSavings: 20,
375
- maintenanceReduction: 10
376
- },
377
- confidence: 0.85
378
- },
379
- riskLevel: 'low',
380
- effort: 'moderate',
381
- dependencies: [],
382
- validationStrategy: {
383
- preValidation: [
384
- {
385
- name: 'Database Health Check',
386
- type: 'performance',
387
- script: 'SELECT COUNT(*) FROM sys_db_object WHERE name = ?',
388
- expectedResult: { count: '>0' },
389
- timeout: 10000,
390
- critical: true
391
- }
392
- ],
393
- postValidation: [
394
- {
395
- name: 'Query Performance Validation',
396
- type: 'performance',
397
- script: 'EXPLAIN SELECT * FROM table WHERE indexed_column = ?',
398
- expectedResult: { index_used: true },
399
- timeout: 5000,
400
- critical: true
401
- }
402
- ],
403
- monitoringMetrics: ['query_execution_time', 'index_usage'],
404
- rollbackTriggers: [
405
- {
406
- metric: 'query_execution_time',
407
- threshold: 2000,
408
- operator: '>',
409
- timeWindow: 300,
410
- action: 'alert'
411
- }
412
- ]
413
- }
414
- });
415
- }
416
- // Memory optimization recommendations
417
- const memoryBottlenecks = bottlenecks.filter(b => b.type === 'memory');
418
- if (memoryBottlenecks.length > 0) {
419
- recommendations.push({
420
- id: 'memory_optimization',
421
- type: 'caching',
422
- priority: 'medium',
423
- title: 'Implement Intelligent Caching',
424
- description: 'Add caching layer to reduce memory usage and improve response times',
425
- implementation: {
426
- method: 'semi_automatic',
427
- steps: [
428
- {
429
- order: 1,
430
- action: 'identify_cacheable_data',
431
- description: 'Identify frequently accessed data suitable for caching',
432
- parameters: { analysis_window: '24h' },
433
- validation: 'Cache candidates identified'
434
- },
435
- {
436
- order: 2,
437
- action: 'implement_cache_layer',
438
- description: 'Implement memory-efficient caching layer',
439
- parameters: { cache_strategy: 'LRU', max_size: '10MB' },
440
- validation: 'Cache layer operational'
441
- }
442
- ],
443
- estimatedTime: 45,
444
- rollbackPlan: 'Disable caching and revert to direct data access',
445
- prerequisites: ['Memory monitoring enabled'],
446
- testingRequired: true
447
- },
448
- expectedImpact: {
449
- performanceImprovement: {
450
- executionTime: 25,
451
- throughput: 35,
452
- resourceUsage: 40
453
- },
454
- reliability: {
455
- errorReduction: 10,
456
- availabilityImprovement: 8
457
- },
458
- scalability: {
459
- capacityIncrease: 75,
460
- concurrencyImprovement: 100
461
- },
462
- cost: {
463
- resourceSavings: 30,
464
- maintenanceReduction: 15
465
- },
466
- confidence: 0.75
467
- },
468
- riskLevel: 'medium',
469
- effort: 'moderate',
470
- dependencies: ['memory_monitoring'],
471
- validationStrategy: {
472
- preValidation: [
473
- {
474
- name: 'Memory Baseline Check',
475
- type: 'performance',
476
- script: 'return process.memoryUsage()',
477
- expectedResult: { heapUsed: '<50MB' },
478
- timeout: 5000,
479
- critical: false
480
- }
481
- ],
482
- postValidation: [
483
- {
484
- name: 'Cache Hit Rate Validation',
485
- type: 'performance',
486
- script: 'return cache.getHitRate()',
487
- expectedResult: { hitRate: '>0.7' },
488
- timeout: 10000,
489
- critical: true
490
- }
491
- ],
492
- monitoringMetrics: ['cache_hit_rate', 'memory_usage'],
493
- rollbackTriggers: [
494
- {
495
- metric: 'memory_usage',
496
- threshold: 60 * 1024 * 1024,
497
- operator: '>',
498
- timeWindow: 180,
499
- action: 'automatic_rollback'
500
- }
501
- ]
502
- }
503
- });
504
- }
505
- return recommendations;
506
- }
507
- assessOptimizationRisks(recommendations) {
508
- // Calculate overall risk based on individual recommendation risks
509
- const highRiskCount = recommendations.filter(r => r.riskLevel === 'high').length;
510
- const mediumRiskCount = recommendations.filter(r => r.riskLevel === 'medium').length;
511
- let overall = 'low';
512
- if (highRiskCount > 2) {
513
- overall = 'critical';
514
- }
515
- else if (highRiskCount > 0) {
516
- overall = 'high';
517
- }
518
- else if (mediumRiskCount > 3) {
519
- overall = 'medium';
520
- }
521
- return {
522
- overall,
523
- categories: {
524
- dataIntegrity: 'low',
525
- systemStability: 'medium',
526
- performanceRegression: 'low',
527
- securityImpact: 'low',
528
- complianceRisk: 'low'
529
- },
530
- mitigationStrategies: [
531
- {
532
- risk: 'Performance regression',
533
- strategy: 'Gradual rollout with monitoring',
534
- implementation: 'Deploy optimizations incrementally with rollback capability',
535
- effectiveness: 0.9
536
- }
537
- ],
538
- contingencyPlans: [
539
- {
540
- scenario: 'Critical performance degradation',
541
- actions: ['Immediate rollback', 'Alert stakeholders', 'Root cause analysis'],
542
- responsibleParty: 'Performance Team',
543
- escalationPath: ['Team Lead', 'Engineering Manager', 'CTO']
544
- }
545
- ]
546
- };
547
- }
548
- async executeOptimizationRecommendation(recommendation, dryRun, execution) {
549
- this.logger.info(`Executing optimization: ${recommendation.title}`, { dryRun });
550
- const startTime = Date.now();
551
- try {
552
- if (dryRun) {
553
- // Simulate execution
554
- await new Promise(resolve => setTimeout(resolve, 1000));
555
- return {
556
- recommendationId: recommendation.id,
557
- status: 'success',
558
- actualImpact: recommendation.expectedImpact,
559
- validationResults: [
560
- {
561
- checkName: 'Dry Run Validation',
562
- passed: true,
563
- expectedValue: 'simulation',
564
- actualValue: 'simulation',
565
- message: 'Dry run completed successfully'
566
- }
567
- ],
568
- executionTime: Date.now() - startTime,
569
- notes: 'Dry run - no actual changes made'
570
- };
571
- }
572
- // Execute actual optimization steps
573
- for (const step of recommendation.implementation.steps) {
574
- this.logger.info(`Executing step: ${step.description}`);
575
- // Step execution logic would go here
576
- await new Promise(resolve => setTimeout(resolve, 500));
577
- }
578
- return {
579
- recommendationId: recommendation.id,
580
- status: 'success',
581
- actualImpact: recommendation.expectedImpact, // Would be measured
582
- validationResults: [],
583
- executionTime: Date.now() - startTime,
584
- notes: 'Optimization completed successfully'
585
- };
586
- }
587
- catch (error) {
588
- return {
589
- recommendationId: recommendation.id,
590
- status: 'failed',
591
- actualImpact: {
592
- performanceImprovement: { executionTime: 0, throughput: 0, resourceUsage: 0 },
593
- reliability: { errorReduction: 0, availabilityImprovement: 0 },
594
- scalability: { capacityIncrease: 0, concurrencyImprovement: 0 },
595
- cost: { resourceSavings: 0, maintenanceReduction: 0 },
596
- confidence: 0
597
- },
598
- validationResults: [],
599
- executionTime: Date.now() - startTime,
600
- notes: `Optimization failed: ${error instanceof Error ? error.message : String(error)}`
601
- };
602
- }
603
- }
604
- async validateOptimizationResults(execution, validationLevel) {
605
- this.logger.info('Validating optimization results', { validationLevel });
606
- // Validation logic would go here
607
- // For now, simulate validation
608
- await new Promise(resolve => setTimeout(resolve, 2000));
609
- }
610
- getPriorityWeight(priority) {
611
- const weights = { critical: 4, high: 3, medium: 2, low: 1 };
612
- return weights[priority] || 0;
613
- }
614
- generateSummaryReport(profile) {
615
- return `
616
- # Performance Summary Report
617
-
618
- **Flow**: ${profile.flowName}
619
- **Analysis Date**: ${new Date(profile.analysisDate).toLocaleDateString()}
620
-
621
- ## Key Metrics
622
- - Average Execution Time: ${profile.metrics.executionTime.average}ms
623
- - Success Rate: ${profile.metrics.reliability.successRate}%
624
- - Throughput: ${profile.metrics.throughput.recordsPerSecond} records/sec
625
-
626
- ## Issues Found
627
- - **Bottlenecks**: ${profile.bottlenecks.length}
628
- - **High Priority**: ${profile.bottlenecks.filter(b => b.severity === 'high' || b.severity === 'critical').length}
629
-
630
- ## Recommendations
631
- - **Total**: ${profile.optimizations.length}
632
- - **High Priority**: ${profile.optimizations.filter(o => o.priority === 'high' || o.priority === 'critical').length}
633
-
634
- ## Risk Assessment
635
- - **Overall Risk**: ${profile.riskAssessment.overall}
636
- `.trim();
637
- }
638
- generateDetailedReport(profile) {
639
- return `
640
- # Detailed Performance Report
641
-
642
- **Flow**: ${profile.flowName}
643
- **Analysis Date**: ${new Date(profile.analysisDate).toLocaleDateString()}
644
- **Version**: ${profile.version}
645
-
646
- ## Executive Summary
647
- This flow has been analyzed for performance optimization opportunities.
648
-
649
- ## Performance Metrics
650
- ${JSON.stringify(profile.metrics, null, 2)}
651
-
652
- ## Bottlenecks Identified
653
- ${profile.bottlenecks.map(b => `
654
- ### ${b.type} - ${b.severity}
655
- - **Location**: ${b.location}
656
- - **Description**: ${b.description}
657
- - **Impact**: ${b.impact.performanceDegradation}% performance degradation
658
- `).join('\n')}
659
-
660
- ## Optimization Recommendations
661
- ${profile.optimizations.map(o => `
662
- ### ${o.title} (${o.priority})
663
- - **Type**: ${o.type}
664
- - **Description**: ${o.description}
665
- - **Expected Impact**: ${o.expectedImpact.performanceImprovement.executionTime}% execution time improvement
666
- - **Risk Level**: ${o.riskLevel}
667
- - **Effort**: ${o.effort}
668
- `).join('\n')}
669
- `.trim();
670
- }
671
- generateExecutiveReport(profile) {
672
- return `
673
- # Executive Performance Report
674
-
675
- **Flow**: ${profile.flowName}
676
- **Analysis Date**: ${new Date(profile.analysisDate).toLocaleDateString()}
677
-
678
- ## Business Impact
679
- This flow analysis identifies opportunities to improve system performance and reduce operational costs.
680
-
681
- ## Key Findings
682
- - **Performance Issues**: ${profile.bottlenecks.length} bottlenecks identified
683
- - **Optimization Potential**: Up to ${Math.max(...profile.optimizations.map(o => o.expectedImpact.performanceImprovement.executionTime))}% performance improvement possible
684
- - **Cost Savings**: Estimated ${Math.max(...profile.optimizations.map(o => o.expectedImpact.cost.resourceSavings))}% resource cost reduction
685
-
686
- ## Recommendations
687
- 1. **Immediate Actions**: Address ${profile.optimizations.filter(o => o.priority === 'critical' || o.priority === 'high').length} high-priority optimizations
688
- 2. **Risk Management**: Overall risk level is ${profile.riskAssessment.overall}
689
- 3. **Timeline**: Estimated ${Math.sum(...profile.optimizations.map(o => o.implementation.estimatedTime))} minutes total implementation time
690
-
691
- ## Next Steps
692
- 1. Review and approve optimization plan
693
- 2. Schedule implementation during maintenance window
694
- 3. Monitor results and validate improvements
695
- `.trim();
696
- }
697
- initializeBenchmarks() {
698
- // Initialize industry standard benchmarks
699
- const genericBenchmarks = [
700
- {
701
- name: 'Execution Time',
702
- category: 'industry_standard',
703
- value: 2000,
704
- unit: 'ms',
705
- context: 'Average flow execution time',
706
- achievable: true,
707
- timeToAchieve: 30
708
- },
709
- {
710
- name: 'Success Rate',
711
- category: 'best_practice',
712
- value: 99.9,
713
- unit: '%',
714
- context: 'Flow execution success rate',
715
- achievable: true,
716
- timeToAchieve: 60
717
- }
718
- ];
719
- this.benchmarks.set('generic', genericBenchmarks);
720
- }
721
- }
722
- exports.FlowPerformanceOptimizer = FlowPerformanceOptimizer;
723
- exports.default = FlowPerformanceOptimizer;