snow-flow 8.31.32 → 8.31.35

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 (415) hide show
  1. package/dist/api/health-api.d.ts +1 -1
  2. package/dist/api/health-api.d.ts.map +1 -1
  3. package/dist/api/simple-health-api.d.ts +1 -1
  4. package/dist/api/simple-health-api.d.ts.map +1 -1
  5. package/dist/cli/partners.d.ts +47 -0
  6. package/dist/cli/partners.d.ts.map +1 -0
  7. package/dist/cli/partners.js +283 -0
  8. package/dist/cli/partners.js.map +1 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +150 -565
  11. package/dist/cli.js.map +1 -1
  12. package/dist/examples/queen/integration-example.d.ts +83 -0
  13. package/dist/examples/queen/integration-example.d.ts.map +1 -0
  14. package/dist/examples/queen/integration-example.js +219 -0
  15. package/dist/examples/queen/integration-example.js.map +1 -0
  16. package/dist/intelligence/acl-analyzer.d.ts +88 -0
  17. package/dist/intelligence/acl-analyzer.d.ts.map +1 -0
  18. package/dist/intelligence/acl-analyzer.js +276 -0
  19. package/dist/intelligence/acl-analyzer.js.map +1 -0
  20. package/dist/intelligence/auto-resolution-engine.d.ts +74 -0
  21. package/dist/intelligence/auto-resolution-engine.d.ts.map +1 -0
  22. package/dist/intelligence/auto-resolution-engine.js +518 -0
  23. package/dist/intelligence/auto-resolution-engine.js.map +1 -0
  24. package/dist/intelligence/gap-analysis-engine.d.ts +103 -0
  25. package/dist/intelligence/gap-analysis-engine.d.ts.map +1 -0
  26. package/dist/intelligence/gap-analysis-engine.js +333 -0
  27. package/dist/intelligence/gap-analysis-engine.js.map +1 -0
  28. package/dist/intelligence/manual-instructions-generator.d.ts +88 -0
  29. package/dist/intelligence/manual-instructions-generator.d.ts.map +1 -0
  30. package/dist/intelligence/manual-instructions-generator.js +641 -0
  31. package/dist/intelligence/manual-instructions-generator.js.map +1 -0
  32. package/dist/intelligence/mcp-coverage-analyzer.d.ts +89 -0
  33. package/dist/intelligence/mcp-coverage-analyzer.d.ts.map +1 -0
  34. package/dist/intelligence/mcp-coverage-analyzer.js +556 -0
  35. package/dist/intelligence/mcp-coverage-analyzer.js.map +1 -0
  36. package/dist/intelligence/multi-pass-requirements-analyzer.d.ts +79 -0
  37. package/dist/intelligence/multi-pass-requirements-analyzer.d.ts.map +1 -0
  38. package/dist/intelligence/multi-pass-requirements-analyzer.js +478 -0
  39. package/dist/intelligence/multi-pass-requirements-analyzer.js.map +1 -0
  40. package/dist/intelligence/performance-recommendations-engine.d.ts +236 -0
  41. package/dist/intelligence/performance-recommendations-engine.d.ts.map +1 -0
  42. package/dist/intelligence/performance-recommendations-engine.js +958 -0
  43. package/dist/intelligence/performance-recommendations-engine.js.map +1 -0
  44. package/dist/intelligence/requirements-analyzer.d.ts +59 -0
  45. package/dist/intelligence/requirements-analyzer.d.ts.map +1 -0
  46. package/dist/intelligence/requirements-analyzer.js +978 -0
  47. package/dist/intelligence/requirements-analyzer.js.map +1 -0
  48. package/dist/intelligence/task-analyzer.d.ts +119 -0
  49. package/dist/intelligence/task-analyzer.d.ts.map +1 -0
  50. package/dist/intelligence/task-analyzer.js +494 -0
  51. package/dist/intelligence/task-analyzer.js.map +1 -0
  52. package/dist/mcp/mcp-tool-manager.d.ts +80 -0
  53. package/dist/mcp/mcp-tool-manager.d.ts.map +1 -0
  54. package/dist/mcp/mcp-tool-manager.js +272 -0
  55. package/dist/mcp/mcp-tool-manager.js.map +1 -0
  56. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_jira_integration.d.ts +9 -0
  57. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_jira_integration.d.ts.map +1 -0
  58. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_jira_integration.js +49 -0
  59. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_jira_integration.js.map +1 -0
  60. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_ldap_sync.d.ts +9 -0
  61. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_ldap_sync.d.ts.map +1 -0
  62. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_ldap_sync.js +48 -0
  63. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_ldap_sync.js.map +1 -0
  64. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_oauth_provider.d.ts +9 -0
  65. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_oauth_provider.d.ts.map +1 -0
  66. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_oauth_provider.js +50 -0
  67. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_oauth_provider.js.map +1 -0
  68. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_saml_config.d.ts +9 -0
  69. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_saml_config.d.ts.map +1 -0
  70. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_saml_config.js +49 -0
  71. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_saml_config.js.map +1 -0
  72. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_webhook_config.d.ts +9 -0
  73. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_webhook_config.d.ts.map +1 -0
  74. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_webhook_config.js +51 -0
  75. package/dist/mcp/servicenow-mcp-unified/tools/adapters/snow_webhook_config.js.map +1 -0
  76. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/index.d.ts +3 -0
  77. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/index.d.ts.map +1 -0
  78. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/index.js +10 -0
  79. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/index.js.map +1 -0
  80. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_predict.d.ts +8 -0
  81. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_predict.d.ts.map +1 -0
  82. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_predict.js +40 -0
  83. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_predict.js.map +1 -0
  84. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_train_classifier.d.ts +8 -0
  85. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_train_classifier.d.ts.map +1 -0
  86. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_train_classifier.js +42 -0
  87. package/dist/mcp/servicenow-mcp-unified/tools/ai-ml/snow_train_classifier.js.map +1 -0
  88. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_approve_change.d.ts +8 -0
  89. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_approve_change.d.ts.map +1 -0
  90. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_approve_change.js +43 -0
  91. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_approve_change.js.map +1 -0
  92. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_assess_change_risk.d.ts +8 -0
  93. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_assess_change_risk.d.ts.map +1 -0
  94. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_assess_change_risk.js +53 -0
  95. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_assess_change_risk.js.map +1 -0
  96. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change.d.ts +8 -0
  97. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change.d.ts.map +1 -0
  98. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change.js +50 -0
  99. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change.js.map +1 -0
  100. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change_task.d.ts +8 -0
  101. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change_task.d.ts.map +1 -0
  102. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change_task.js +50 -0
  103. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_create_change_task.js.map +1 -0
  104. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_get_change_request.d.ts +8 -0
  105. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_get_change_request.d.ts.map +1 -0
  106. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_get_change_request.js +60 -0
  107. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_get_change_request.js.map +1 -0
  108. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_schedule_cab_meeting.d.ts +8 -0
  109. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_schedule_cab_meeting.d.ts.map +1 -0
  110. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_schedule_cab_meeting.js +55 -0
  111. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_schedule_cab_meeting.js.map +1 -0
  112. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_search_change_requests.d.ts +8 -0
  113. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_search_change_requests.d.ts.map +1 -0
  114. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_search_change_requests.js +54 -0
  115. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_search_change_requests.js.map +1 -0
  116. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_update_change_state.d.ts +8 -0
  117. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_update_change_state.d.ts.map +1 -0
  118. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_update_change_state.js +67 -0
  119. package/dist/mcp/servicenow-mcp-unified/tools/change/snow_update_change_state.js.map +1 -0
  120. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_csv_to_json.d.ts +9 -0
  121. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_csv_to_json.d.ts.map +1 -0
  122. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_csv_to_json.js +52 -0
  123. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_csv_to_json.js.map +1 -0
  124. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_csv.d.ts +9 -0
  125. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_csv.d.ts.map +1 -0
  126. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_csv.js +51 -0
  127. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_csv.js.map +1 -0
  128. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_xml.d.ts +9 -0
  129. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_xml.d.ts.map +1 -0
  130. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_xml.js +42 -0
  131. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_json_to_xml.js.map +1 -0
  132. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_xml_to_json.d.ts +9 -0
  133. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_xml_to_json.d.ts.map +1 -0
  134. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_xml_to_json.js +42 -0
  135. package/dist/mcp/servicenow-mcp-unified/tools/converters/snow_xml_to_json.js.map +1 -0
  136. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_details.d.ts +8 -0
  137. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_details.d.ts.map +1 -0
  138. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_details.js +68 -0
  139. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_details.js.map +1 -0
  140. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_history.d.ts +8 -0
  141. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_history.d.ts.map +1 -0
  142. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_history.js +76 -0
  143. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_history.js.map +1 -0
  144. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_status.d.ts +8 -0
  145. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_status.d.ts.map +1 -0
  146. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_status.js +71 -0
  147. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_get_flow_execution_status.js.map +1 -0
  148. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_list_flows.d.ts +8 -0
  149. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_list_flows.d.ts.map +1 -0
  150. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_list_flows.js +42 -0
  151. package/dist/mcp/servicenow-mcp-unified/tools/flow-designer/snow_list_flows.js.map +1 -0
  152. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_create_knowledge_article.d.ts +12 -0
  153. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_create_knowledge_article.d.ts.map +1 -0
  154. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_create_knowledge_article.js +80 -0
  155. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_create_knowledge_article.js.map +1 -0
  156. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_get_knowledge_article_details.d.ts +11 -0
  157. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_get_knowledge_article_details.d.ts.map +1 -0
  158. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_get_knowledge_article_details.js +63 -0
  159. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_get_knowledge_article_details.js.map +1 -0
  160. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_publish_kb_article.d.ts +8 -0
  161. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_publish_kb_article.d.ts.map +1 -0
  162. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_publish_kb_article.js +41 -0
  163. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_publish_kb_article.js.map +1 -0
  164. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_retire_knowledge_article.d.ts +11 -0
  165. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_retire_knowledge_article.d.ts.map +1 -0
  166. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_retire_knowledge_article.js +59 -0
  167. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_retire_knowledge_article.js.map +1 -0
  168. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_search_knowledge.d.ts +11 -0
  169. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_search_knowledge.d.ts.map +1 -0
  170. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_search_knowledge.js +72 -0
  171. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_search_knowledge.js.map +1 -0
  172. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_update_knowledge_article.d.ts +11 -0
  173. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_update_knowledge_article.d.ts.map +1 -0
  174. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_update_knowledge_article.js +68 -0
  175. package/dist/mcp/servicenow-mcp-unified/tools/knowledge/snow_update_knowledge_article.js.map +1 -0
  176. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_assign_user_to_group.d.ts +11 -0
  177. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_assign_user_to_group.d.ts.map +1 -0
  178. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_assign_user_to_group.js +106 -0
  179. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_assign_user_to_group.js.map +1 -0
  180. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_create_record.d.ts +12 -0
  181. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_create_record.d.ts.map +1 -0
  182. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_create_record.js +107 -0
  183. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_create_record.js.map +1 -0
  184. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_delete_record.d.ts +12 -0
  185. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_delete_record.d.ts.map +1 -0
  186. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_delete_record.js +157 -0
  187. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_delete_record.js.map +1 -0
  188. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_list_group_members.d.ts +11 -0
  189. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_list_group_members.d.ts.map +1 -0
  190. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_list_group_members.js +117 -0
  191. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_list_group_members.js.map +1 -0
  192. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_remove_user_from_group.d.ts +11 -0
  193. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_remove_user_from_group.d.ts.map +1 -0
  194. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_remove_user_from_group.js +99 -0
  195. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_remove_user_from_group.js.map +1 -0
  196. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_update_record.d.ts +12 -0
  197. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_update_record.d.ts.map +1 -0
  198. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_update_record.js +105 -0
  199. package/dist/mcp/servicenow-mcp-unified/tools/operations/snow_update_record.js.map +1 -0
  200. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_collect_pa_data.d.ts +8 -0
  201. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_collect_pa_data.d.ts.map +1 -0
  202. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_collect_pa_data.js +55 -0
  203. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_collect_pa_data.js.map +1 -0
  204. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_data_visualization.d.ts +8 -0
  205. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_data_visualization.d.ts.map +1 -0
  206. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_data_visualization.js +70 -0
  207. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_data_visualization.js.map +1 -0
  208. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_kpi.d.ts +8 -0
  209. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_kpi.d.ts.map +1 -0
  210. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_kpi.js +69 -0
  211. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_kpi.js.map +1 -0
  212. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_breakdown.d.ts +8 -0
  213. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_breakdown.d.ts.map +1 -0
  214. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_breakdown.js +55 -0
  215. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_breakdown.js.map +1 -0
  216. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_indicator.d.ts +8 -0
  217. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_indicator.d.ts.map +1 -0
  218. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_indicator.js +43 -0
  219. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_indicator.js.map +1 -0
  220. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_threshold.d.ts +8 -0
  221. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_threshold.d.ts.map +1 -0
  222. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_threshold.js +57 -0
  223. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_threshold.js.map +1 -0
  224. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_widget.d.ts +8 -0
  225. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_widget.d.ts.map +1 -0
  226. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_widget.js +62 -0
  227. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_pa_widget.js.map +1 -0
  228. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_scheduled_report.d.ts +8 -0
  229. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_scheduled_report.d.ts.map +1 -0
  230. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_scheduled_report.js +69 -0
  231. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_create_scheduled_report.js.map +1 -0
  232. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_pa_indicators.d.ts +8 -0
  233. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_pa_indicators.d.ts.map +1 -0
  234. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_pa_indicators.js +55 -0
  235. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_pa_indicators.js.map +1 -0
  236. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_report_fields.d.ts +8 -0
  237. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_report_fields.d.ts.map +1 -0
  238. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_report_fields.js +53 -0
  239. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_report_fields.js.map +1 -0
  240. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_reporting_tables.d.ts +8 -0
  241. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_reporting_tables.d.ts.map +1 -0
  242. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_reporting_tables.js +51 -0
  243. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_discover_reporting_tables.js.map +1 -0
  244. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_export_report_data.d.ts +8 -0
  245. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_export_report_data.d.ts.map +1 -0
  246. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_export_report_data.js +62 -0
  247. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_export_report_data.js.map +1 -0
  248. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_generate_insights.d.ts +8 -0
  249. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_generate_insights.d.ts.map +1 -0
  250. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_generate_insights.js +69 -0
  251. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_generate_insights.js.map +1 -0
  252. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_get_pa_scores.d.ts +8 -0
  253. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_get_pa_scores.d.ts.map +1 -0
  254. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_get_pa_scores.js +42 -0
  255. package/dist/mcp/servicenow-mcp-unified/tools/performance-analytics/snow_get_pa_scores.js.map +1 -0
  256. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/index.d.ts +10 -0
  257. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/index.d.ts.map +1 -0
  258. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/index.js +28 -0
  259. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/index.js.map +1 -0
  260. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_activate_pi_solution.d.ts +11 -0
  261. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_activate_pi_solution.d.ts.map +1 -0
  262. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_activate_pi_solution.js +168 -0
  263. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_activate_pi_solution.js.map +1 -0
  264. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_create_pi_solution.d.ts +20 -0
  265. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_create_pi_solution.d.ts.map +1 -0
  266. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_create_pi_solution.js +235 -0
  267. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_create_pi_solution.js.map +1 -0
  268. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_list_pi_solutions.d.ts +10 -0
  269. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_list_pi_solutions.d.ts.map +1 -0
  270. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_list_pi_solutions.js +166 -0
  271. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_list_pi_solutions.js.map +1 -0
  272. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_monitor_pi_training.d.ts +11 -0
  273. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_monitor_pi_training.d.ts.map +1 -0
  274. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_monitor_pi_training.js +142 -0
  275. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_monitor_pi_training.js.map +1 -0
  276. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_train_pi_solution.d.ts +14 -0
  277. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_train_pi_solution.d.ts.map +1 -0
  278. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_train_pi_solution.js +149 -0
  279. package/dist/mcp/servicenow-mcp-unified/tools/predictive-intelligence/snow_train_pi_solution.js.map +1 -0
  280. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_add_uib_page_element.d.ts +12 -0
  281. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_add_uib_page_element.d.ts.map +1 -0
  282. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_add_uib_page_element.js +111 -0
  283. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_add_uib_page_element.js.map +1 -0
  284. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_clone_uib_component.d.ts +12 -0
  285. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_clone_uib_component.d.ts.map +1 -0
  286. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_clone_uib_component.js +99 -0
  287. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_clone_uib_component.js.map +1 -0
  288. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_component.d.ts +12 -0
  289. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_component.d.ts.map +1 -0
  290. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_component.js +102 -0
  291. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_component.js.map +1 -0
  292. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_page.d.ts +12 -0
  293. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_page.d.ts.map +1 -0
  294. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_page.js +99 -0
  295. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_create_uib_page.js.map +1 -0
  296. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_delete_uib_page.d.ts +12 -0
  297. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_delete_uib_page.d.ts.map +1 -0
  298. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_delete_uib_page.js +108 -0
  299. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_delete_uib_page.js.map +1 -0
  300. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_components.d.ts +12 -0
  301. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_components.d.ts.map +1 -0
  302. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_components.js +96 -0
  303. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_components.js.map +1 -0
  304. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_page_usage.d.ts +12 -0
  305. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_page_usage.d.ts.map +1 -0
  306. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_page_usage.js +106 -0
  307. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_page_usage.js.map +1 -0
  308. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_pages.d.ts +11 -0
  309. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_pages.d.ts.map +1 -0
  310. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_pages.js +102 -0
  311. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_pages.js.map +1 -0
  312. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_routes.d.ts +12 -0
  313. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_routes.d.ts.map +1 -0
  314. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_routes.js +99 -0
  315. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib_routes.js.map +1 -0
  316. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_remove_uib_page_element.d.ts +11 -0
  317. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_remove_uib_page_element.d.ts.map +1 -0
  318. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_remove_uib_page_element.js +138 -0
  319. package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_remove_uib_page_element.js.map +1 -0
  320. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_add_user_to_group.d.ts +9 -0
  321. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_add_user_to_group.d.ts.map +1 -0
  322. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_add_user_to_group.js +42 -0
  323. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_add_user_to_group.js.map +1 -0
  324. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_assign_role.d.ts +9 -0
  325. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_assign_role.d.ts.map +1 -0
  326. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_assign_role.js +51 -0
  327. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_assign_role.js.map +1 -0
  328. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_group.d.ts +9 -0
  329. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_group.d.ts.map +1 -0
  330. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_group.js +51 -0
  331. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_group.js.map +1 -0
  332. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_role.d.ts +9 -0
  333. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_role.d.ts.map +1 -0
  334. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_role.js +47 -0
  335. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_role.js.map +1 -0
  336. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_user.d.ts +9 -0
  337. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_user.d.ts.map +1 -0
  338. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_user.js +51 -0
  339. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_create_user.js.map +1 -0
  340. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_deactivate_user.d.ts +9 -0
  341. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_deactivate_user.d.ts.map +1 -0
  342. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_deactivate_user.js +40 -0
  343. package/dist/mcp/servicenow-mcp-unified/tools/user-admin/snow_deactivate_user.js.map +1 -0
  344. package/dist/memory/session-memory.d.ts +70 -0
  345. package/dist/memory/session-memory.d.ts.map +1 -0
  346. package/dist/memory/session-memory.js +110 -0
  347. package/dist/memory/session-memory.js.map +1 -0
  348. package/dist/partners/license-parser.d.ts +52 -0
  349. package/dist/partners/license-parser.d.ts.map +1 -0
  350. package/dist/partners/license-parser.js +240 -0
  351. package/dist/partners/license-parser.js.map +1 -0
  352. package/dist/partners/types.d.ts +253 -0
  353. package/dist/partners/types.d.ts.map +1 -0
  354. package/dist/partners/types.js +111 -0
  355. package/dist/partners/types.js.map +1 -0
  356. package/dist/portal/partner-backend.d.ts +106 -0
  357. package/dist/portal/partner-backend.d.ts.map +1 -0
  358. package/dist/portal/partner-backend.js +254 -0
  359. package/dist/portal/partner-backend.js.map +1 -0
  360. package/dist/queen/agent-factory.d.ts +45 -0
  361. package/dist/queen/agent-factory.d.ts.map +1 -0
  362. package/dist/queen/agent-factory.js +659 -0
  363. package/dist/queen/agent-factory.js.map +1 -0
  364. package/dist/queen/index.d.ts +59 -0
  365. package/dist/queen/index.d.ts.map +1 -0
  366. package/dist/queen/index.js +80 -0
  367. package/dist/queen/index.js.map +1 -0
  368. package/dist/queen/mcp-execution-bridge.d.ts +115 -0
  369. package/dist/queen/mcp-execution-bridge.d.ts.map +1 -0
  370. package/dist/queen/mcp-execution-bridge.js +535 -0
  371. package/dist/queen/mcp-execution-bridge.js.map +1 -0
  372. package/dist/queen/neural-learning.d.ts +28 -0
  373. package/dist/queen/neural-learning.d.ts.map +1 -0
  374. package/dist/queen/neural-learning.js +252 -0
  375. package/dist/queen/neural-learning.js.map +1 -0
  376. package/dist/queen/parallel-agent-engine.d.ts +126 -0
  377. package/dist/queen/parallel-agent-engine.d.ts.map +1 -0
  378. package/dist/queen/parallel-agent-engine.js +704 -0
  379. package/dist/queen/parallel-agent-engine.js.map +1 -0
  380. package/dist/queen/queen-knowledge-base.d.ts +151 -0
  381. package/dist/queen/queen-knowledge-base.d.ts.map +1 -0
  382. package/dist/queen/queen-knowledge-base.js +283 -0
  383. package/dist/queen/queen-knowledge-base.js.map +1 -0
  384. package/dist/queen/queen-memory.d.ts +65 -0
  385. package/dist/queen/queen-memory.d.ts.map +1 -0
  386. package/dist/queen/queen-memory.js +467 -0
  387. package/dist/queen/queen-memory.js.map +1 -0
  388. package/dist/queen/servicenow-queen.d.ts +154 -0
  389. package/dist/queen/servicenow-queen.d.ts.map +1 -0
  390. package/dist/queen/servicenow-queen.js +1409 -0
  391. package/dist/queen/servicenow-queen.js.map +1 -0
  392. package/dist/queen/types.d.ts +65 -0
  393. package/dist/queen/types.d.ts.map +1 -0
  394. package/dist/queen/types.js +7 -0
  395. package/dist/queen/types.js.map +1 -0
  396. package/dist/sdk/queen-orchestrator.d.ts +94 -0
  397. package/dist/sdk/queen-orchestrator.d.ts.map +1 -0
  398. package/dist/sdk/queen-orchestrator.js +309 -0
  399. package/dist/sdk/queen-orchestrator.js.map +1 -0
  400. package/dist/sdk/universal-agent-spawner.d.ts +112 -0
  401. package/dist/sdk/universal-agent-spawner.d.ts.map +1 -0
  402. package/dist/sdk/universal-agent-spawner.js +353 -0
  403. package/dist/sdk/universal-agent-spawner.js.map +1 -0
  404. package/dist/sparc/sparc-help.d.ts +5 -0
  405. package/dist/sparc/sparc-help.d.ts.map +1 -0
  406. package/dist/sparc/sparc-help.js +52 -0
  407. package/dist/sparc/sparc-help.js.map +1 -0
  408. package/dist/sparc/team-sparc.d.ts +9 -0
  409. package/dist/sparc/team-sparc.d.ts.map +1 -0
  410. package/dist/sparc/team-sparc.js +83 -0
  411. package/dist/sparc/team-sparc.js.map +1 -0
  412. package/dist/templates/readme-template.d.ts +1 -1
  413. package/dist/templates/readme-template.d.ts.map +1 -1
  414. package/dist/templates/readme-template.js +3 -3
  415. package/package.json +2 -9
@@ -0,0 +1,958 @@
1
+ "use strict";
2
+ /**
3
+ * 🚀 PERFORMANCE FIX: Enhanced AI-Powered Performance Recommendations Engine
4
+ *
5
+ * Provides intelligent database index suggestions, real-time performance optimizations,
6
+ * predictive analytics, and AI-powered recommendations for ServiceNow artifacts.
7
+ *
8
+ * Enhanced features from beta testing feedback:
9
+ * - Real-time performance trend analysis
10
+ * - AI-powered pattern recognition
11
+ * - Predictive performance modeling
12
+ * - Automated optimization suggestions
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PerformanceRecommendationsEngine = void 0;
16
+ const logger_js_1 = require("../utils/logger.js");
17
+ const memory_system_js_1 = require("../memory/memory-system.js");
18
+ class PerformanceRecommendationsEngine {
19
+ constructor(memory) {
20
+ this.performancePatterns = new Map();
21
+ this.systemBaselines = new Map();
22
+ this.aiRecommendations = new Map();
23
+ this.predictiveInsights = [];
24
+ this.learningEnabled = true;
25
+ // 🔍 ServiceNow table performance patterns based on real-world analysis
26
+ this.SERVICENOW_TABLE_PATTERNS = {
27
+ 'incident': {
28
+ table: 'incident',
29
+ commonQueries: [
30
+ 'state=1^active=true^assigned_to=user',
31
+ 'priority=1^state!=6^state!=7',
32
+ 'caller_id=user^opened_by=user',
33
+ 'assignment_group=group^state=2'
34
+ ],
35
+ frequentFields: ['state', 'priority', 'assigned_to', 'assignment_group', 'caller_id', 'opened_by', 'sys_created_on'],
36
+ joinPatterns: [
37
+ { with_table: 'sys_user', on_fields: ['assigned_to', 'caller_id'] },
38
+ { with_table: 'sys_user_group', on_fields: ['assignment_group'] }
39
+ ],
40
+ slowQueries: [
41
+ 'sys_created_on>javascript:gs.dateGenerate()', // Date range queries
42
+ 'short_description.indexOf("text")', // Text search without indexes
43
+ ],
44
+ recordVolume: 'high',
45
+ updateFrequency: 'high'
46
+ },
47
+ 'change_request': {
48
+ table: 'change_request',
49
+ commonQueries: [
50
+ 'state=1^type=standard',
51
+ 'start_date>=javascript:gs.beginningOfToday()^end_date<=javascript:gs.endOfToday()',
52
+ 'approval=approved^state=2'
53
+ ],
54
+ frequentFields: ['state', 'type', 'start_date', 'end_date', 'approval', 'risk', 'assigned_to'],
55
+ joinPatterns: [
56
+ { with_table: 'sys_user', on_fields: ['assigned_to', 'requested_by'] },
57
+ { with_table: 'cmdb_ci', on_fields: ['cmdb_ci'] }
58
+ ],
59
+ slowQueries: [
60
+ 'start_date>=date^end_date<=date', // Date range queries
61
+ 'description.indexOf("text")'
62
+ ],
63
+ recordVolume: 'medium',
64
+ updateFrequency: 'medium'
65
+ },
66
+ 'sc_request': {
67
+ table: 'sc_request',
68
+ commonQueries: [
69
+ 'state=1^requested_for=user',
70
+ 'request_state=approved^stage=fulfillment',
71
+ 'opened_by=user^sys_created_on>date'
72
+ ],
73
+ frequentFields: ['state', 'request_state', 'stage', 'requested_for', 'opened_by', 'sys_created_on'],
74
+ joinPatterns: [
75
+ { with_table: 'sys_user', on_fields: ['requested_for', 'opened_by'] },
76
+ { with_table: 'sc_req_item', on_fields: ['sys_id'] }
77
+ ],
78
+ slowQueries: [
79
+ 'sys_created_on>date_range', // Date filters
80
+ 'requested_for.department=dept' // Dot-walking queries
81
+ ],
82
+ recordVolume: 'high',
83
+ updateFrequency: 'medium'
84
+ },
85
+ 'sc_task': {
86
+ table: 'sc_task',
87
+ commonQueries: [
88
+ 'state=1^assigned_to=user',
89
+ 'request.requested_for=user^state!=3',
90
+ 'assignment_group=group^active=true'
91
+ ],
92
+ frequentFields: ['state', 'assigned_to', 'assignment_group', 'request', 'active', 'sys_created_on'],
93
+ joinPatterns: [
94
+ { with_table: 'sc_request', on_fields: ['request'] },
95
+ { with_table: 'sys_user', on_fields: ['assigned_to'] }
96
+ ],
97
+ slowQueries: [
98
+ 'request.requested_for=user', // Dot-walking to parent record
99
+ ],
100
+ recordVolume: 'high',
101
+ updateFrequency: 'high'
102
+ },
103
+ 'sys_user': {
104
+ table: 'sys_user',
105
+ commonQueries: [
106
+ 'active=true^user_name=username',
107
+ 'email=email^active=true',
108
+ 'department=dept^active=true'
109
+ ],
110
+ frequentFields: ['active', 'user_name', 'email', 'department', 'manager', 'sys_created_on'],
111
+ joinPatterns: [
112
+ { with_table: 'sys_user_grmember', on_fields: ['sys_id'] },
113
+ { with_table: 'sys_user_group', on_fields: ['manager'] }
114
+ ],
115
+ slowQueries: [
116
+ 'last_login_time>date', // Date comparisons
117
+ 'name.indexOf("partial")', // Text searches
118
+ ],
119
+ recordVolume: 'medium',
120
+ updateFrequency: 'low'
121
+ }
122
+ };
123
+ // 🎯 Critical index recommendations based on real ServiceNow performance analysis
124
+ this.CRITICAL_INDEXES = [
125
+ {
126
+ table: 'incident',
127
+ fields: ['state', 'assigned_to'],
128
+ indexType: 'composite',
129
+ reason: 'Most common query pattern: incidents assigned to users by state',
130
+ estimatedImprovement: 85,
131
+ priority: 'critical',
132
+ createStatement: 'CREATE INDEX idx_incident_state_assigned ON incident (state, assigned_to)',
133
+ impactAnalysis: {
134
+ queryImpact: ['Dashboard widgets', 'My Work lists', 'Assignment queries'],
135
+ storageImpact: 'Low: approximately 5-10MB for typical instance',
136
+ maintenanceImpact: 'Minimal: updated only when incidents are assigned/closed'
137
+ }
138
+ },
139
+ {
140
+ table: 'incident',
141
+ fields: ['assignment_group', 'state'],
142
+ indexType: 'composite',
143
+ reason: 'Group assignment boards and team dashboards rely heavily on this pattern',
144
+ estimatedImprovement: 75,
145
+ priority: 'critical',
146
+ createStatement: 'CREATE INDEX idx_incident_group_state ON incident (assignment_group, state)',
147
+ impactAnalysis: {
148
+ queryImpact: ['Team dashboards', 'Group assignment lists', 'Manager reports'],
149
+ storageImpact: 'Low: approximately 8-12MB for typical instance',
150
+ maintenanceImpact: 'Low: updated when group assignments change'
151
+ }
152
+ },
153
+ {
154
+ table: 'change_request',
155
+ fields: ['start_date', 'end_date'],
156
+ indexType: 'composite',
157
+ reason: 'Change calendar and scheduling queries are extremely slow without this index',
158
+ estimatedImprovement: 90,
159
+ priority: 'critical',
160
+ createStatement: 'CREATE INDEX idx_change_date_range ON change_request (start_date, end_date)',
161
+ impactAnalysis: {
162
+ queryImpact: ['Change calendar', 'Scheduling conflicts', 'CAB reports'],
163
+ storageImpact: 'Minimal: date indexes are very compact',
164
+ maintenanceImpact: 'Low: only updated when change dates are modified'
165
+ }
166
+ },
167
+ {
168
+ table: 'sc_request',
169
+ fields: ['requested_for', 'state'],
170
+ indexType: 'composite',
171
+ reason: 'User self-service portals query heavily by requester and status',
172
+ estimatedImprovement: 80,
173
+ priority: 'high',
174
+ createStatement: 'CREATE INDEX idx_request_user_state ON sc_request (requested_for, state)',
175
+ impactAnalysis: {
176
+ queryImpact: ['Service Portal', 'My Requests', 'User dashboards'],
177
+ storageImpact: 'Medium: 15-25MB for high-volume instances',
178
+ maintenanceImpact: 'Medium: updated frequently as requests progress'
179
+ }
180
+ },
181
+ {
182
+ table: 'sc_task',
183
+ fields: ['request', 'state'],
184
+ indexType: 'composite',
185
+ reason: 'Task tracking and request fulfillment depends on this relationship',
186
+ estimatedImprovement: 70,
187
+ priority: 'high',
188
+ createStatement: 'CREATE INDEX idx_task_request_state ON sc_task (request, state)',
189
+ impactAnalysis: {
190
+ queryImpact: ['Request details', 'Task workflows', 'Fulfillment tracking'],
191
+ storageImpact: 'Medium: grows with task volume',
192
+ maintenanceImpact: 'High: updated as tasks progress through workflow'
193
+ }
194
+ }
195
+ ];
196
+ this.logger = new logger_js_1.Logger('PerformanceRecommendationsEngine');
197
+ this.memory = memory || new memory_system_js_1.BasicMemorySystem();
198
+ // Initialize AI-powered capabilities
199
+ this.initializeAICapabilities();
200
+ }
201
+ /**
202
+ * 🧠 Initialize AI-powered capabilities and load historical patterns
203
+ */
204
+ async initializeAICapabilities() {
205
+ try {
206
+ await this.memory.initialize();
207
+ await this.loadHistoricalPatterns();
208
+ await this.loadSystemBaselines();
209
+ await this.loadAIRecommendations();
210
+ this.logger.info('🚀 AI-powered performance engine initialized', {
211
+ patterns: this.performancePatterns.size,
212
+ baselines: this.systemBaselines.size,
213
+ recommendations: this.aiRecommendations.size
214
+ });
215
+ }
216
+ catch (error) {
217
+ this.logger.error('❌ Failed to initialize AI capabilities:', error);
218
+ }
219
+ }
220
+ /**
221
+ * 🧠 Generate AI-powered performance recommendations based on real-time data
222
+ */
223
+ async generateAIRecommendations(systemMetrics, performanceData, options = {}) {
224
+ this.logger.info('🧠 Generating AI-powered performance recommendations...');
225
+ const { includePreventive = true, includePredictive = true, confidenceThreshold = 0.7 } = options;
226
+ const recommendations = [];
227
+ // 1. Pattern-based recommendations
228
+ if (includePreventive) {
229
+ const patternRecommendations = await this.generatePatternBasedRecommendations(systemMetrics);
230
+ recommendations.push(...patternRecommendations);
231
+ }
232
+ // 2. Predictive recommendations
233
+ if (includePredictive) {
234
+ const predictiveRecommendations = await this.generatePredictiveRecommendations(performanceData);
235
+ recommendations.push(...predictiveRecommendations);
236
+ }
237
+ // 3. Real-time anomaly recommendations
238
+ const anomalyRecommendations = await this.generateAnomalyRecommendations(systemMetrics);
239
+ recommendations.push(...anomalyRecommendations);
240
+ // 4. Machine learning insights
241
+ const mlRecommendations = await this.generateMLRecommendations(systemMetrics, performanceData);
242
+ recommendations.push(...mlRecommendations);
243
+ // Filter by confidence threshold
244
+ const filteredRecommendations = recommendations.filter(rec => rec.confidence >= confidenceThreshold);
245
+ // Sort by priority and impact
246
+ filteredRecommendations.sort((a, b) => {
247
+ if (a.priority !== b.priority)
248
+ return b.priority - a.priority;
249
+ const impactOrder = { critical: 4, high: 3, medium: 2, low: 1 };
250
+ return impactOrder[b.impact] - impactOrder[a.impact];
251
+ });
252
+ // Store recommendations
253
+ for (const recommendation of filteredRecommendations.slice(0, 20)) {
254
+ this.aiRecommendations.set(recommendation.id, recommendation);
255
+ await this.memory.store(`ai_recommendation_${recommendation.id}`, recommendation, 7200000); // 2 hours
256
+ }
257
+ this.logger.info('✅ Generated AI recommendations', {
258
+ total: recommendations.length,
259
+ filtered: filteredRecommendations.length,
260
+ highPriority: filteredRecommendations.filter(r => r.priority >= 8).length
261
+ });
262
+ return filteredRecommendations.slice(0, 10); // Return top 10
263
+ }
264
+ /**
265
+ * 🔮 Generate predictive insights based on historical trends
266
+ */
267
+ async generatePredictiveInsights(timeHorizonHours = 24) {
268
+ this.logger.info('🔮 Generating predictive insights...', { timeHorizonHours });
269
+ const insights = [];
270
+ // Analyze memory growth patterns
271
+ const memoryInsight = await this.predictMemoryExhaustion(timeHorizonHours);
272
+ if (memoryInsight)
273
+ insights.push(memoryInsight);
274
+ // Analyze database growth patterns
275
+ const dbInsight = await this.predictDatabaseBottlenecks(timeHorizonHours);
276
+ if (dbInsight)
277
+ insights.push(dbInsight);
278
+ // Analyze API performance degradation
279
+ const apiInsight = await this.predictAPIPerformanceDegradation(timeHorizonHours);
280
+ if (apiInsight)
281
+ insights.push(apiInsight);
282
+ // Analyze cache effectiveness
283
+ const cacheInsight = await this.predictCacheEffectivenessIssues(timeHorizonHours);
284
+ if (cacheInsight)
285
+ insights.push(cacheInsight);
286
+ // Store insights
287
+ this.predictiveInsights = insights;
288
+ await this.memory.store('predictive_insights', insights, 3600000); // 1 hour
289
+ return insights.sort((a, b) => b.probability - a.probability);
290
+ }
291
+ /**
292
+ * 📊 Calculate comprehensive performance score
293
+ */
294
+ async calculatePerformanceScore(systemMetrics, performanceData) {
295
+ this.logger.info('📊 Calculating performance score...');
296
+ const components = {
297
+ database: this.calculateDatabaseScore(systemMetrics, performanceData),
298
+ api: this.calculateAPIScore(systemMetrics, performanceData),
299
+ memory: this.calculateMemoryScore(systemMetrics),
300
+ cache: this.calculateCacheScore(systemMetrics, performanceData),
301
+ network: this.calculateNetworkScore(systemMetrics)
302
+ };
303
+ const overall = Object.values(components).reduce((sum, score) => sum + score, 0) / 5;
304
+ // Calculate trends
305
+ const trends = await this.calculatePerformanceTrends();
306
+ const score = {
307
+ overall: Math.round(overall),
308
+ components,
309
+ trends,
310
+ comparison: {
311
+ industryAverage: 72, // Benchmark data
312
+ bestPractice: 85
313
+ },
314
+ calculatedAt: new Date()
315
+ };
316
+ // Store score for trend analysis
317
+ await this.memory.store('performance_score', score, 3600000); // 1 hour
318
+ return score;
319
+ }
320
+ /**
321
+ * 🎯 Learn from performance patterns and update AI models
322
+ */
323
+ async learnFromPerformanceData(performanceData, systemMetrics, outcomes) {
324
+ if (!this.learningEnabled)
325
+ return;
326
+ this.logger.info('🎯 Learning from performance data...');
327
+ // Extract patterns from data
328
+ const patterns = this.extractPerformancePatterns(performanceData, systemMetrics, outcomes);
329
+ // Update pattern knowledge
330
+ for (const pattern of patterns) {
331
+ const existingPattern = this.performancePatterns.get(pattern.pattern);
332
+ if (existingPattern) {
333
+ // Update existing pattern
334
+ existingPattern.frequency += pattern.frequency;
335
+ existingPattern.occurrences += pattern.occurrences;
336
+ existingPattern.lastSeen = new Date();
337
+ // Update solutions based on outcomes
338
+ this.updatePatternSolutions(existingPattern, outcomes);
339
+ }
340
+ else {
341
+ // Add new pattern
342
+ this.performancePatterns.set(pattern.pattern, pattern);
343
+ }
344
+ }
345
+ // Update system baselines
346
+ await this.updateSystemBaselines(systemMetrics);
347
+ // Generate new recommendations based on learned patterns
348
+ if (patterns.length > 0) {
349
+ const newRecommendations = await this.generateRecommendationsFromPatterns(patterns);
350
+ for (const rec of newRecommendations) {
351
+ this.aiRecommendations.set(rec.id, rec);
352
+ }
353
+ }
354
+ // Persist learned knowledge
355
+ await this.persistLearningData();
356
+ this.logger.info('✅ Learning completed', {
357
+ patternsUpdated: patterns.length,
358
+ totalPatterns: this.performancePatterns.size
359
+ });
360
+ }
361
+ /**
362
+ * 🔍 Analyze flow definition and provide performance recommendations
363
+ */
364
+ async analyzeFlowPerformance(flowDefinition) {
365
+ this.logger.info('🚀 BUG-007: Analyzing flow performance and generating recommendations...');
366
+ const databaseIndexes = [];
367
+ const performanceRecommendations = [];
368
+ // 1. Analyze table usage in flow
369
+ const tablesUsed = this.extractTablesFromFlow(flowDefinition);
370
+ this.logger.info(`📊 Flow uses tables: ${tablesUsed.join(', ')}`);
371
+ // 2. Generate database index recommendations for each table
372
+ for (const table of tablesUsed) {
373
+ const tableIndexes = this.getIndexRecommendationsForTable(table);
374
+ databaseIndexes.push(...tableIndexes);
375
+ }
376
+ // 3. Analyze flow activities for performance issues
377
+ const flowPerformanceIssues = this.analyzeFlowActivities(flowDefinition);
378
+ performanceRecommendations.push(...flowPerformanceIssues);
379
+ // 4. Generate general performance recommendations
380
+ const generalRecommendations = this.generateGeneralPerformanceRecommendations(flowDefinition);
381
+ performanceRecommendations.push(...generalRecommendations);
382
+ // 5. Calculate summary metrics
383
+ const criticalIssues = databaseIndexes.filter(idx => idx.priority === 'critical').length +
384
+ performanceRecommendations.filter(rec => rec.impact === 'high').length;
385
+ const estimatedImprovementPercent = databaseIndexes.reduce((total, idx) => total + idx.estimatedImprovement, 0) / Math.max(databaseIndexes.length, 1);
386
+ const recommendedActions = [
387
+ ...databaseIndexes.slice(0, 3).map(idx => `Create ${idx.indexType} index on ${idx.table} (${idx.fields.join(', ')})`),
388
+ ...performanceRecommendations.slice(0, 2).map(rec => rec.recommendation)
389
+ ];
390
+ this.logger.info(`✅ Performance _analysis complete: ${criticalIssues} critical issues, ${estimatedImprovementPercent.toFixed(1)}% potential improvement`);
391
+ return {
392
+ databaseIndexes,
393
+ performanceRecommendations,
394
+ summary: {
395
+ criticalIssues,
396
+ estimatedImprovementPercent: Math.round(estimatedImprovementPercent),
397
+ recommendedActions
398
+ }
399
+ };
400
+ }
401
+ /**
402
+ * 🎯 Get specific index recommendations for a ServiceNow table
403
+ */
404
+ getIndexRecommendationsForTable(table) {
405
+ const recommendations = [];
406
+ // Get critical indexes for this table
407
+ const criticalIndexes = this.CRITICAL_INDEXES.filter(idx => idx.table === table);
408
+ recommendations.push(...criticalIndexes);
409
+ // Get pattern-based recommendations
410
+ const pattern = this.SERVICENOW_TABLE_PATTERNS[table];
411
+ if (pattern) {
412
+ // Add recommendations based on common query patterns
413
+ if (pattern.recordVolume === 'high' && pattern.updateFrequency === 'high') {
414
+ recommendations.push({
415
+ table,
416
+ fields: ['sys_created_on'],
417
+ indexType: 'single',
418
+ reason: `High-volume table ${table} benefits from date-based filtering`,
419
+ estimatedImprovement: 45,
420
+ priority: 'medium',
421
+ createStatement: `CREATE INDEX idx_${table}_created ON ${table} (sys_created_on)`,
422
+ impactAnalysis: {
423
+ queryImpact: ['Date range queries', 'Recent records filters', 'Reporting queries'],
424
+ storageImpact: 'Low: date indexes are compact',
425
+ maintenanceImpact: 'Low: only grows with new records'
426
+ }
427
+ });
428
+ }
429
+ // Add recommendations for frequent field combinations
430
+ if (pattern.frequentFields.length >= 2) {
431
+ const topFields = pattern.frequentFields.slice(0, 2);
432
+ recommendations.push({
433
+ table,
434
+ fields: topFields,
435
+ indexType: 'composite',
436
+ reason: `Fields ${topFields.join(', ')} are frequently queried together in ${table}`,
437
+ estimatedImprovement: 60,
438
+ priority: 'medium',
439
+ createStatement: `CREATE INDEX idx_${table}_${topFields.join('_')} ON ${table} (${topFields.join(', ')})`,
440
+ impactAnalysis: {
441
+ queryImpact: [`Common ${table} queries`, 'List filtering', 'Dashboard widgets'],
442
+ storageImpact: 'Medium: varies with field types and data distribution',
443
+ maintenanceImpact: 'Medium: updated when indexed fields change'
444
+ }
445
+ });
446
+ }
447
+ }
448
+ return recommendations;
449
+ }
450
+ /**
451
+ * 📊 Analyze flow activities for performance bottlenecks
452
+ */
453
+ analyzeFlowActivities(flowDefinition) {
454
+ const recommendations = [];
455
+ const activities = flowDefinition.activities || [];
456
+ for (const activity of activities) {
457
+ // Check for inefficient script activities
458
+ if (activity.type === 'script' && activity.inputs?.script) {
459
+ const script = activity.inputs.script.toLowerCase();
460
+ // Detect N+1 query patterns
461
+ if (script.includes('gliderecord') && script.includes('while') && script.includes('query()')) {
462
+ recommendations.push({
463
+ category: 'flow',
464
+ type: 'script_optimization',
465
+ description: `Script activity "${activity.name}" may contain N+1 query pattern`,
466
+ impact: 'high',
467
+ effort: 'medium',
468
+ recommendation: 'Use batch queries or limit record processing with .setLimit()',
469
+ code_example: `// Instead of:\nwhile (gr.next()) {\n var gr2 = new GlideRecord('related_table');\n gr2.get(gr.sys_id);\n}\n\n// Use:\nvar batchIds = [];\nwhile (gr.next()) {\n batchIds.push(gr.sys_id.toString());\n}\nvar gr2 = new GlideRecord('related_table');\ngr2.addQuery('parent', 'IN', batchIds.join(','));\ngr2.query();`,
470
+ estimated_time_savings: '2-5 seconds per execution'
471
+ });
472
+ }
473
+ // Detect missing query limits
474
+ if (script.includes('gliderecord') && !script.includes('setlimit')) {
475
+ recommendations.push({
476
+ category: 'flow',
477
+ type: 'query_optimization',
478
+ description: `Script activity "${activity.name}" queries without limits`,
479
+ impact: 'medium',
480
+ effort: 'low',
481
+ recommendation: 'Add .setLimit() to prevent excessive record processing',
482
+ code_example: `// Add this line:\ngr.setLimit(100); // Adjust limit as needed\ngr.query();`,
483
+ estimated_time_savings: '1-3 seconds per execution'
484
+ });
485
+ }
486
+ }
487
+ // Check for inefficient approval activities
488
+ if (activity.type === 'approval' && activity.inputs?.approver) {
489
+ recommendations.push({
490
+ category: 'flow',
491
+ type: 'approval_optimization',
492
+ description: `Approval activity "${activity.name}" should use group approvals for better performance`,
493
+ impact: 'low',
494
+ effort: 'low',
495
+ recommendation: 'Consider using approval groups instead of individual approvers for scalability',
496
+ estimated_time_savings: 'Improves scalability and reduces lookup time'
497
+ });
498
+ }
499
+ // Check for excessive notification activities
500
+ if (activity.type === 'notification') {
501
+ recommendations.push({
502
+ category: 'flow',
503
+ type: 'notification_optimization',
504
+ description: `Consider batching notifications for better performance`,
505
+ impact: 'low',
506
+ effort: 'medium',
507
+ recommendation: 'Use notification batching for high-volume flows',
508
+ estimated_time_savings: 'Reduces email server load and improves flow execution time'
509
+ });
510
+ }
511
+ }
512
+ return recommendations;
513
+ }
514
+ /**
515
+ * 🔧 Generate general performance recommendations
516
+ */
517
+ generateGeneralPerformanceRecommendations(flowDefinition) {
518
+ const recommendations = [];
519
+ // Check flow complexity
520
+ const activityCount = (flowDefinition.activities || []).length;
521
+ if (activityCount > 10) {
522
+ recommendations.push({
523
+ category: 'flow',
524
+ type: 'complexity_optimization',
525
+ description: 'Flow has many activities which may impact performance',
526
+ impact: 'medium',
527
+ effort: 'high',
528
+ recommendation: 'Consider breaking complex flow into sub-flows for better maintainability and performance',
529
+ estimated_time_savings: 'Improves flow execution time and debugging'
530
+ });
531
+ }
532
+ // Check for synchronous vs asynchronous execution
533
+ recommendations.push({
534
+ category: 'flow',
535
+ type: 'execution_optimization',
536
+ description: 'Consider asynchronous execution for non-critical path activities',
537
+ impact: 'medium',
538
+ effort: 'medium',
539
+ recommendation: 'Use asynchronous sub-flows for activities that don\'t block the main process',
540
+ estimated_time_savings: '30-50% reduction in user-perceived response time'
541
+ });
542
+ // Database connection optimization
543
+ recommendations.push({
544
+ category: 'database',
545
+ type: 'connection_optimization',
546
+ description: 'Optimize database connections for better performance',
547
+ impact: 'medium',
548
+ effort: 'low',
549
+ recommendation: 'Use connection pooling and prepared statements where possible',
550
+ estimated_time_savings: '10-20% improvement in database operations'
551
+ });
552
+ // Caching recommendations
553
+ recommendations.push({
554
+ category: 'cache',
555
+ type: 'data_caching',
556
+ description: 'Implement caching for frequently accessed reference data',
557
+ impact: 'high',
558
+ effort: 'medium',
559
+ recommendation: 'Cache choice lists, user groups, and other reference data that changes infrequently',
560
+ estimated_time_savings: '50-80% reduction in lookup queries'
561
+ });
562
+ return recommendations;
563
+ }
564
+ /**
565
+ * 📋 Extract tables used in flow definition
566
+ */
567
+ extractTablesFromFlow(flowDefinition) {
568
+ const tables = new Set();
569
+ // Check flow table
570
+ if (flowDefinition.table) {
571
+ tables.add(flowDefinition.table);
572
+ }
573
+ // Check activities for table references
574
+ const activities = flowDefinition.activities || [];
575
+ for (const activity of activities) {
576
+ if (activity.inputs) {
577
+ // Check for table references in inputs
578
+ if (activity.inputs.table) {
579
+ tables.add(activity.inputs.table);
580
+ }
581
+ // Check script activities for GlideRecord table references
582
+ if (activity.inputs.script) {
583
+ const script = activity.inputs.script;
584
+ const glideRecordMatches = script.match(/new\s+GlideRecord\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g);
585
+ if (glideRecordMatches) {
586
+ for (const match of glideRecordMatches) {
587
+ const tableMatch = match.match(/['"`]([^'"`]+)['"`]/);
588
+ if (tableMatch) {
589
+ tables.add(tableMatch[1]);
590
+ }
591
+ }
592
+ }
593
+ }
594
+ // Check for field references that imply table usage
595
+ if (activity.inputs.fields && Array.isArray(activity.inputs.fields)) {
596
+ // If fields are specified, the primary table is likely being used
597
+ if (flowDefinition.table) {
598
+ tables.add(flowDefinition.table);
599
+ }
600
+ }
601
+ }
602
+ }
603
+ return Array.from(tables);
604
+ }
605
+ /**
606
+ * 📊 Generate comprehensive performance report
607
+ */
608
+ /**
609
+ * 🧠 Private AI helper methods
610
+ */
611
+ async loadHistoricalPatterns() {
612
+ try {
613
+ const patterns = await this.memory.get('performance_patterns');
614
+ if (patterns) {
615
+ for (const [key, pattern] of Object.entries(patterns)) {
616
+ this.performancePatterns.set(key, pattern);
617
+ }
618
+ }
619
+ }
620
+ catch (error) {
621
+ this.logger.debug('No historical patterns found');
622
+ }
623
+ }
624
+ async loadSystemBaselines() {
625
+ try {
626
+ const baselines = await this.memory.get('system_baselines');
627
+ if (baselines) {
628
+ for (const [key, baseline] of Object.entries(baselines)) {
629
+ this.systemBaselines.set(key, baseline);
630
+ }
631
+ }
632
+ }
633
+ catch (error) {
634
+ this.logger.debug('No system baselines found');
635
+ }
636
+ }
637
+ async loadAIRecommendations() {
638
+ try {
639
+ const recommendations = await this.memory.get('ai_recommendations');
640
+ if (recommendations) {
641
+ for (const [key, recommendation] of Object.entries(recommendations)) {
642
+ this.aiRecommendations.set(key, recommendation);
643
+ }
644
+ }
645
+ }
646
+ catch (error) {
647
+ this.logger.debug('No AI recommendations found');
648
+ }
649
+ }
650
+ async generatePatternBasedRecommendations(systemMetrics) {
651
+ const recommendations = [];
652
+ // Analyze current metrics against known patterns
653
+ for (const [patternKey, pattern] of this.performancePatterns) {
654
+ if (this.matchesPattern(systemMetrics, pattern)) {
655
+ const recommendations_from_pattern = this.createRecommendationsFromPattern(pattern);
656
+ recommendations.push(...recommendations_from_pattern);
657
+ }
658
+ }
659
+ return recommendations;
660
+ }
661
+ async generatePredictiveRecommendations(performanceData) {
662
+ const recommendations = [];
663
+ // Simple trend-based predictions
664
+ if (performanceData.averageResponseTime > 2000 && performanceData.trend === 'degrading') {
665
+ recommendations.push({
666
+ id: `pred_response_time_${Date.now()}`,
667
+ type: 'optimization',
668
+ confidence: 0.8,
669
+ impact: 'high',
670
+ category: 'api_performance',
671
+ title: 'Response Time Degradation Predicted',
672
+ description: 'Current response time trends indicate potential performance issues',
673
+ rationale: 'Historical data shows similar patterns lead to 40% performance degradation within 24 hours',
674
+ implementation: {
675
+ steps: [
676
+ 'Review database query performance',
677
+ 'Check for N+1 query patterns',
678
+ 'Implement caching for frequently accessed data',
679
+ 'Optimize slow database operations'
680
+ ],
681
+ estimatedTime: '2-4 hours',
682
+ complexity: 'medium',
683
+ prerequisites: ['Database access', 'Performance monitoring tools'],
684
+ risks: ['Temporary increased resource usage during optimization']
685
+ },
686
+ metrics: {
687
+ expectedImprovement: 35,
688
+ affectedComponents: ['api', 'database'],
689
+ kpiImpact: { response_time: -35, throughput: 20 }
690
+ },
691
+ priority: 8,
692
+ validUntil: new Date(Date.now() + 86400000), // 24 hours
693
+ source: 'ml_prediction'
694
+ });
695
+ }
696
+ return recommendations;
697
+ }
698
+ async generateAnomalyRecommendations(systemMetrics) {
699
+ const recommendations = [];
700
+ // Check for memory anomalies
701
+ if (systemMetrics.memoryUsage > 80) {
702
+ recommendations.push({
703
+ id: `anomaly_memory_${Date.now()}`,
704
+ type: 'optimization',
705
+ confidence: 0.9,
706
+ impact: 'critical',
707
+ category: 'memory_management',
708
+ title: 'High Memory Usage Detected',
709
+ description: 'Memory usage is above critical threshold',
710
+ rationale: 'High memory usage can lead to system instability and performance degradation',
711
+ implementation: {
712
+ steps: [
713
+ 'Analyze memory usage patterns',
714
+ 'Identify memory leaks',
715
+ 'Implement garbage collection optimization',
716
+ 'Add memory monitoring alerts'
717
+ ],
718
+ estimatedTime: '1-2 hours',
719
+ complexity: 'medium',
720
+ prerequisites: ['System access', 'Memory profiling tools'],
721
+ risks: ['Potential service interruption during optimization']
722
+ },
723
+ metrics: {
724
+ expectedImprovement: 25,
725
+ affectedComponents: ['memory', 'api', 'database'],
726
+ kpiImpact: { memory_usage: -30, stability: 40 }
727
+ },
728
+ priority: 9,
729
+ validUntil: new Date(Date.now() + 3600000), // 1 hour
730
+ source: 'real_time_monitoring'
731
+ });
732
+ }
733
+ return recommendations;
734
+ }
735
+ async generateMLRecommendations(systemMetrics, performanceData) {
736
+ const recommendations = [];
737
+ // Simple ML-like _analysis based on correlations
738
+ const dbScore = this.calculateDatabaseScore(systemMetrics, performanceData);
739
+ const cacheScore = this.calculateCacheScore(systemMetrics, performanceData);
740
+ if (dbScore < 60 && cacheScore > 80) {
741
+ recommendations.push({
742
+ id: `ml_db_optimization_${Date.now()}`,
743
+ type: 'optimization',
744
+ confidence: 0.75,
745
+ impact: 'high',
746
+ category: 'database_optimization',
747
+ title: 'Database Performance Optimization Opportunity',
748
+ description: 'ML _analysis indicates database optimization would provide significant benefits',
749
+ rationale: 'Cache performance is good but database performance is poor, indicating database bottlenecks',
750
+ implementation: {
751
+ steps: [
752
+ 'Analyze slow database queries',
753
+ 'Add missing database indexes',
754
+ 'Optimize query patterns',
755
+ 'Consider database scaling'
756
+ ],
757
+ estimatedTime: '3-6 hours',
758
+ complexity: 'high',
759
+ prerequisites: ['Database admin access', 'Query _analysis tools'],
760
+ risks: ['Index creation may temporarily impact performance']
761
+ },
762
+ metrics: {
763
+ expectedImprovement: 45,
764
+ affectedComponents: ['database', 'api'],
765
+ kpiImpact: { db_performance: 45, response_time: -30 }
766
+ },
767
+ priority: 7,
768
+ validUntil: new Date(Date.now() + 86400000), // 24 hours
769
+ source: 'ml_prediction'
770
+ });
771
+ }
772
+ return recommendations;
773
+ }
774
+ calculateDatabaseScore(systemMetrics, performanceData) {
775
+ let score = 100;
776
+ if (performanceData?.averageResponseTime > 2000)
777
+ score -= 30;
778
+ if (performanceData?.errorRate > 5)
779
+ score -= 20;
780
+ if (systemMetrics?.dbSize > 1000)
781
+ score -= 10; // Large DB
782
+ return Math.max(0, score);
783
+ }
784
+ calculateAPIScore(systemMetrics, performanceData) {
785
+ let score = 100;
786
+ if (performanceData?.averageResponseTime > 1000)
787
+ score -= 25;
788
+ if (performanceData?.throughput < 10)
789
+ score -= 15;
790
+ if (performanceData?.errorRate > 2)
791
+ score -= 30;
792
+ return Math.max(0, score);
793
+ }
794
+ calculateMemoryScore(systemMetrics) {
795
+ let score = 100;
796
+ if (systemMetrics?.memoryUsage > 85)
797
+ score -= 40;
798
+ else if (systemMetrics?.memoryUsage > 70)
799
+ score -= 20;
800
+ if (systemMetrics?.heapUsed > 500)
801
+ score -= 15; // MB
802
+ return Math.max(0, score);
803
+ }
804
+ calculateCacheScore(systemMetrics, performanceData) {
805
+ let score = 100;
806
+ if (performanceData?.cacheHitRate < 50)
807
+ score -= 40;
808
+ else if (performanceData?.cacheHitRate < 70)
809
+ score -= 20;
810
+ if (systemMetrics?.cacheSize > 1000)
811
+ score -= 10; // Large cache
812
+ return Math.max(0, score);
813
+ }
814
+ calculateNetworkScore(systemMetrics) {
815
+ // Placeholder for network scoring
816
+ return 85; // Default good score
817
+ }
818
+ async calculatePerformanceTrends() {
819
+ // Simplified trend calculation
820
+ return {
821
+ daily: 2.5, // 2.5% improvement
822
+ weekly: -1.2, // 1.2% degradation
823
+ monthly: 5.8 // 5.8% improvement
824
+ };
825
+ }
826
+ matchesPattern(systemMetrics, pattern) {
827
+ // Simple pattern matching logic
828
+ return pattern.contexts.some(context => context.toLowerCase().includes('memory') && systemMetrics?.memoryUsage > 70);
829
+ }
830
+ createRecommendationsFromPattern(pattern) {
831
+ // Return existing solutions from pattern
832
+ return pattern.solutions || [];
833
+ }
834
+ extractPerformancePatterns(performanceData, systemMetrics, outcomes) {
835
+ const patterns = [];
836
+ // Simple pattern extraction
837
+ if (performanceData.averageResponseTime > 2000) {
838
+ patterns.push({
839
+ pattern: 'high_response_time',
840
+ frequency: 1,
841
+ severity: 'high',
842
+ contexts: ['api_performance'],
843
+ solutions: [],
844
+ firstSeen: new Date(),
845
+ lastSeen: new Date(),
846
+ occurrences: 1
847
+ });
848
+ }
849
+ return patterns;
850
+ }
851
+ updatePatternSolutions(pattern, outcomes) {
852
+ // Update pattern solutions based on outcomes
853
+ // This would be more sophisticated in a real ML system
854
+ }
855
+ async updateSystemBaselines(systemMetrics) {
856
+ const baseline = {
857
+ component: 'system',
858
+ metrics: {
859
+ memory_usage: {
860
+ baseline: systemMetrics?.memoryUsage || 0,
861
+ threshold: 80,
862
+ trend: 'stable',
863
+ variance: 5
864
+ },
865
+ response_time: {
866
+ baseline: systemMetrics?.responseTime || 0,
867
+ threshold: 2000,
868
+ trend: 'stable',
869
+ variance: 200
870
+ }
871
+ },
872
+ lastUpdated: new Date(),
873
+ sampleCount: 1
874
+ };
875
+ this.systemBaselines.set('system', baseline);
876
+ }
877
+ async generateRecommendationsFromPatterns(patterns) {
878
+ // Generate new recommendations based on learned patterns
879
+ return [];
880
+ }
881
+ async persistLearningData() {
882
+ await this.memory.store('performance_patterns', Object.fromEntries(this.performancePatterns));
883
+ await this.memory.store('system_baselines', Object.fromEntries(this.systemBaselines));
884
+ await this.memory.store('ai_recommendations', Object.fromEntries(this.aiRecommendations));
885
+ }
886
+ async predictMemoryExhaustion(timeHorizonHours) {
887
+ // Simplified memory exhaustion prediction
888
+ return null; // Placeholder
889
+ }
890
+ async predictDatabaseBottlenecks(timeHorizonHours) {
891
+ // Simplified database bottleneck prediction
892
+ return null; // Placeholder
893
+ }
894
+ async predictAPIPerformanceDegradation(timeHorizonHours) {
895
+ // Simplified API performance prediction
896
+ return null; // Placeholder
897
+ }
898
+ async predictCacheEffectivenessIssues(timeHorizonHours) {
899
+ // Simplified cache effectiveness prediction
900
+ return null; // Placeholder
901
+ }
902
+ /**
903
+ * 📊 Generate comprehensive performance report
904
+ */
905
+ generatePerformanceReport(analysisResults) {
906
+ const { databaseIndexes, performanceRecommendations, summary } = analysisResults;
907
+ let report = `
908
+ 🚀 ServiceNow Performance Analysis Report
909
+ ==========================================
910
+
911
+ 📊 SUMMARY:
912
+ • Critical Issues: ${summary.criticalIssues}
913
+ • Estimated Performance Improvement: ${summary.estimatedImprovementPercent}%
914
+ • Total Recommendations: ${databaseIndexes.length + performanceRecommendations.length}
915
+
916
+ 🎯 TOP PRIORITY ACTIONS:
917
+ ${summary.recommendedActions.map((action, i) => `${i + 1}. ${action}`).join('\n')}
918
+
919
+ `;
920
+ if (databaseIndexes.length > 0) {
921
+ report += `
922
+ 🗄️ DATABASE INDEX RECOMMENDATIONS:
923
+ ${databaseIndexes.map((idx, i) => `
924
+ ${i + 1}. ${idx.table} - ${idx.fields.join(', ')} [${idx.priority.toUpperCase()}]
925
+ 💡 ${idx.reason}
926
+ 📈 Expected Improvement: ${idx.estimatedImprovement}%
927
+ 💻 SQL: ${idx.createStatement}
928
+ 📊 Impact: ${idx.impactAnalysis.queryImpact.join(', ')}
929
+ 💾 Storage: ${idx.impactAnalysis.storageImpact}
930
+ `).join('')}`;
931
+ }
932
+ if (performanceRecommendations.length > 0) {
933
+ report += `
934
+ ⚡ PERFORMANCE RECOMMENDATIONS:
935
+ ${performanceRecommendations.map((rec, i) => `
936
+ ${i + 1}. ${rec.type.replace(/_/g, ' ').toUpperCase()} [${rec.impact.toUpperCase()} IMPACT]
937
+ 📋 ${rec.description}
938
+ 💡 ${rec.recommendation}
939
+ ⏱️ Time Savings: ${rec.estimated_time_savings}
940
+ ${rec.code_example ? `\n 💻 Example:\n ${rec.code_example.split('\n').map(line => ` ${line}`).join('\n')}` : ''}
941
+ `).join('')}`;
942
+ }
943
+ report += `
944
+ 🔍 NEXT STEPS:
945
+ 1. Implement critical database indexes first (highest ROI)
946
+ 2. Review and optimize flow scripts for N+1 query patterns
947
+ 3. Consider implementing caching for frequently accessed data
948
+ 4. Monitor performance metrics after implementing changes
949
+ 5. Schedule regular performance reviews for optimal results
950
+
951
+ ⚠️ IMPORTANT: Test all database changes in a development environment first!
952
+ `;
953
+ return report;
954
+ }
955
+ }
956
+ exports.PerformanceRecommendationsEngine = PerformanceRecommendationsEngine;
957
+ exports.default = PerformanceRecommendationsEngine;
958
+ //# sourceMappingURL=performance-recommendations-engine.js.map