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,1409 @@
1
+ "use strict";
2
+ /**
3
+ * ServiceNow Queen Agent
4
+ * Central coordination point for the ServiceNow hive-mind
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ServiceNowQueen = void 0;
41
+ const queen_memory_1 = require("./queen-memory");
42
+ const neural_learning_1 = require("./neural-learning");
43
+ const agent_factory_1 = require("./agent-factory");
44
+ const mcp_execution_bridge_1 = require("./mcp-execution-bridge");
45
+ const queen_knowledge_base_1 = require("./queen-knowledge-base");
46
+ const theme_manager_1 = require("../utils/theme-manager");
47
+ const dependency_detector_1 = require("../utils/dependency-detector");
48
+ // Gap Analysis Engine removed - using direct MCP approach
49
+ const logger_1 = require("../utils/logger");
50
+ const crypto = __importStar(require("crypto"));
51
+ class ServiceNowQueen {
52
+ constructor(config = {}) {
53
+ this.config = {
54
+ memoryPath: config.memoryPath,
55
+ maxConcurrentAgents: config.maxConcurrentAgents || 5,
56
+ learningRate: config.learningRate || 0.1,
57
+ debugMode: config.debugMode || false,
58
+ autoPermissions: config.autoPermissions || false
59
+ };
60
+ // Initialize logger
61
+ this.logger = new logger_1.Logger('ServiceNowQueen');
62
+ // Initialize hive-mind components
63
+ this.memory = new queen_memory_1.QueenMemorySystem(this.config.memoryPath);
64
+ this.neuralLearning = new neural_learning_1.NeuralLearning(this.memory);
65
+ this.agentFactory = new agent_factory_1.AgentFactory(this.memory);
66
+ this.mcpBridge = new mcp_execution_bridge_1.MCPExecutionBridge(this.memory);
67
+ // Gap analysis integrated directly into MCP workflow
68
+ this.activeTasks = new Map();
69
+ if (this.config.debugMode) {
70
+ this.logger.info('🐝 ServiceNow Queen Agent initialized with hive-mind intelligence');
71
+ this.logger.info('🔌 MCP Execution Bridge connected for real ServiceNow operations');
72
+ this.logger.info('🧠 ServiceNow integration engine ready for MCP operations');
73
+ }
74
+ }
75
+ /**
76
+ * Main entry point: Execute ServiceNow objective with STRATEGIC ORCHESTRATION
77
+ *
78
+ * This is where the Queen Agent demonstrates true helicopter-view thinking:
79
+ * - Deep problem analysis beyond surface requirements
80
+ * - Strategic risk assessment and mitigation planning
81
+ * - Holistic solution architecture considering all stakeholders
82
+ * - Proactive bottleneck identification and resolution
83
+ * - Comprehensive orchestration of specialized agents
84
+ */
85
+ async executeObjective(objective) {
86
+ const taskId = this.generateTaskId();
87
+ const startTime = Date.now();
88
+ try {
89
+ // 🧠 STRATEGIC PHASE 1: DEEP PROBLEM ANALYSIS
90
+ this.logger.info(`👑 QUEEN STRATEGIC ANALYSIS INITIATED`);
91
+ this.logger.info(`🎯 Objective: ${objective}`);
92
+ this.logger.info(`🧠 Analyzing: What is the REAL problem we're solving here?`);
93
+ // Analyze what the user ACTUALLY needs vs what they asked for
94
+ const problemAnalysis = await this.performDeepProblemAnalysis(objective);
95
+ this.logger.info(`📊 Problem Complexity: ${problemAnalysis.complexity} | Business Impact: ${problemAnalysis.businessImpact}`);
96
+ this.logger.info(`🎯 Core Problem: ${problemAnalysis.coreProblem}`);
97
+ this.logger.info(`👥 Stakeholders: ${problemAnalysis.stakeholders.join(', ')}`);
98
+ // 🧠 STRATEGIC PHASE 2: RISK & CONSTRAINT ASSESSMENT
99
+ this.logger.info(`🔍 STRATEGIC RISK ASSESSMENT`);
100
+ const riskAssessment = await this.performRiskAssessment(objective, problemAnalysis);
101
+ this.logger.info(`⚠️ Risk Level: ${riskAssessment.overallRisk} | Critical Risks: ${riskAssessment.criticalRisks.length}`);
102
+ if (riskAssessment.criticalRisks.length > 0) {
103
+ this.logger.info(`🚨 CRITICAL RISKS IDENTIFIED:`);
104
+ riskAssessment.criticalRisks.forEach(risk => {
105
+ this.logger.info(` • ${risk.description} (Impact: ${risk.impact}, Likelihood: ${risk.likelihood})`);
106
+ });
107
+ }
108
+ if (this.config.debugMode) {
109
+ this.logger.info(`🎯 Queen analyzing objective: ${objective}`);
110
+ this.logger.info(`🚨 ENFORCING MCP-FIRST WORKFLOW`);
111
+ }
112
+ // 🚨 PHASE 1: MANDATORY MCP PRE-FLIGHT AUTHENTICATION CHECK
113
+ this.logger.info('🔐 Step 1: Validating ServiceNow connection...');
114
+ const authCheck = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, {
115
+ agentId: 'queen-agent',
116
+ agentType: 'queen',
117
+ action: 'validate-connection',
118
+ tool: 'snow_validate_live_connection',
119
+ server: 'operations',
120
+ params: { test_level: 'permissions' },
121
+ reasoning: 'MANDATORY: Pre-flight authentication check before any ServiceNow operations',
122
+ confidence: 0.95
123
+ });
124
+ if (!authCheck.success) {
125
+ const authError = `
126
+ 🚨 ServiceNow Authentication Failed: ${authCheck.error}
127
+
128
+ 🔧 Fix this now:
129
+ 1. Run: snow-flow auth login
130
+ 2. Check .env: SNOW_INSTANCE, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET
131
+ 3. Test: snow_auth_diagnostics()
132
+
133
+ ❌ Cannot proceed with Queen Agent operations until authentication works!
134
+ `;
135
+ this.logger.error('Authentication failed:', authError);
136
+ throw new Error(authError);
137
+ }
138
+ this.logger.info('✅ ServiceNow authentication validated');
139
+ // 🚨 PHASE 2: MANDATORY SMART DISCOVERY (Prevent Duplication)
140
+ this.logger.info('🔍 Step 2: Discovering existing artifacts...');
141
+ const discovery = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, {
142
+ agentId: 'queen-agent',
143
+ agentType: 'queen',
144
+ action: 'discover-artifacts',
145
+ tool: 'snow_comprehensive_search',
146
+ server: 'intelligent',
147
+ params: {
148
+ query: objective,
149
+ include_inactive: false
150
+ },
151
+ reasoning: 'MANDATORY: Check for existing artifacts before creating new ones',
152
+ confidence: 0.90
153
+ });
154
+ if (discovery.success && discovery.toolResult?.found?.length > 0) {
155
+ this.logger.info(`🔍 Found ${discovery.toolResult.found.length} existing artifacts that might be relevant:`);
156
+ discovery.toolResult.found.forEach((artifact) => {
157
+ this.logger.info(`💡 Consider reusing: ${artifact.name} (${artifact.sys_id})`);
158
+ });
159
+ }
160
+ // Phase 3: Initial Neural Analysis (informed by MCP discovery)
161
+ const _analysis = this.neuralLearning.analyzeTask(objective);
162
+ // Phase 4: Create and register task
163
+ const task = {
164
+ id: taskId,
165
+ objective,
166
+ type: _analysis.type,
167
+ artifacts: [],
168
+ status: 'analyzing'
169
+ };
170
+ this.activeTasks.set(taskId, task);
171
+ // 🧠 PHASE 5: STRATEGIC SOLUTION ARCHITECTURE
172
+ this.logger.info(`🧠 Strategic Solution Architecture based on analysis...`);
173
+ this.logger.info(`🎯 Mitigation Strategies: ${riskAssessment.mitigationStrategies.join(', ')}`);
174
+ // Strategic solution design based on deep analysis
175
+ const solutionArchitecture = await this.designSolutionArchitecture(problemAnalysis, riskAssessment);
176
+ this.logger.info(`🏗️ Solution Architecture: ${solutionArchitecture.approach}`);
177
+ this.logger.info(`👥 Recommended Team: ${solutionArchitecture.recommendedAgents.join(', ')}`);
178
+ // Store strategic analysis in task
179
+ task.strategicAnalysis = {
180
+ problemAnalysis,
181
+ riskAssessment,
182
+ solutionArchitecture
183
+ };
184
+ // Phase 6: Spawn optimal agent swarm
185
+ const agents = this.spawnOptimalSwarm(task, _analysis);
186
+ // Phase 7: Execute coordinated deployment
187
+ task.status = 'executing';
188
+ const result = await this.coordinateExecution(task, agents, _analysis);
189
+ // Phase 8: Learn from execution
190
+ const duration = Date.now() - startTime;
191
+ this.learnFromExecution(task, agents, result, duration, null);
192
+ task.status = 'completed';
193
+ task.result = result;
194
+ if (this.config.debugMode) {
195
+ this.logger.info(`✅ Queen completed objective in ${duration}ms`);
196
+ }
197
+ return result;
198
+ }
199
+ catch (error) {
200
+ const duration = Date.now() - startTime;
201
+ await this.handleExecutionFailure(taskId, objective, error, duration);
202
+ throw error;
203
+ }
204
+ finally {
205
+ this.cleanupTask(taskId);
206
+ }
207
+ }
208
+ spawnOptimalSwarm(task, _analysis) {
209
+ if (this.config.debugMode) {
210
+ this.logger.info(`🐛 Spawning swarm for ${task.type} task (complexity: ${_analysis.estimatedComplexity})`);
211
+ }
212
+ // Use learned patterns or optimal sequence
213
+ const agentTypes = _analysis.suggestedPattern?.agentSequence ||
214
+ this.agentFactory.getOptimalAgentSequence(task.type, _analysis.estimatedComplexity);
215
+ // Spawn agent swarm
216
+ const agents = this.agentFactory.spawnAgentSwarm(agentTypes, task.id);
217
+ if (this.config.debugMode) {
218
+ this.logger.info(`👥 Spawned ${agents.length} agents: ${agents.map(a => a.type).join(', ')}`);
219
+ }
220
+ return agents;
221
+ }
222
+ async coordinateExecution(task, agents, _analysis) {
223
+ const results = [];
224
+ try {
225
+ // Execute agents in optimal sequence
226
+ if (this.shouldExecuteInParallel(agents)) {
227
+ results.push(...await this.executeAgentsInParallel(agents, task.objective));
228
+ }
229
+ else {
230
+ results.push(...await this.executeAgentsSequentially(agents, task.objective));
231
+ }
232
+ // Coordinate final deployment using MCP tools
233
+ const deploymentResult = await this.executeFinalDeployment(task, results, _analysis);
234
+ return {
235
+ taskId: task.id,
236
+ objective: task.objective,
237
+ agentResults: results,
238
+ deploymentResult,
239
+ artifacts: task.artifacts
240
+ };
241
+ }
242
+ catch (error) {
243
+ // Attempt recovery or fallback
244
+ return await this.attemptRecovery(task, agents, error);
245
+ }
246
+ }
247
+ shouldExecuteInParallel(agents) {
248
+ // Parallel execution for independent agents
249
+ const independentAgents = ['researcher', 'tester', 'script-writer'];
250
+ return agents.some(agent => independentAgents.includes(agent.type));
251
+ }
252
+ async executeAgentsInParallel(agents, objective) {
253
+ if (this.config.debugMode) {
254
+ this.logger.info('⚡ Executing agents in parallel');
255
+ }
256
+ const promises = agents.map(agent => this.agentFactory.executeAgentTask(agent.id, objective));
257
+ return await Promise.all(promises);
258
+ }
259
+ async executeAgentsSequentially(agents, objective) {
260
+ if (this.config.debugMode) {
261
+ this.logger.info('🔄 Executing agents sequentially');
262
+ }
263
+ const results = [];
264
+ for (const agent of agents) {
265
+ const result = await this.agentFactory.executeAgentTask(agent.id, objective);
266
+ results.push(result);
267
+ // Allow agents to coordinate between executions
268
+ this.facilitateAgentCoordination(agent, results);
269
+ }
270
+ return results;
271
+ }
272
+ facilitateAgentCoordination(currentAgent, previousResults) {
273
+ // Send relevant results to collaborative agents
274
+ const activeAgents = this.agentFactory.getActiveAgents();
275
+ for (const agent of activeAgents) {
276
+ if (agent.id !== currentAgent.id) {
277
+ this.agentFactory.sendAgentMessage(currentAgent.id, agent.id, 'result', {
278
+ results: previousResults.slice(-1)[0], // Latest result
279
+ fromAgent: currentAgent.type
280
+ });
281
+ }
282
+ }
283
+ }
284
+ async executeFinalDeployment(task, agentResults, _analysis) {
285
+ if (this.config.debugMode) {
286
+ this.logger.info('🚀 Executing final deployment with MCP tools');
287
+ }
288
+ // The Queen coordinates the actual MCP tool calls based on agent recommendations
289
+ const deploymentPlan = this.createDeploymentPlan(task, agentResults, _analysis);
290
+ try {
291
+ // Execute deployment using the unified deployment API
292
+ const deploymentResult = await this.executeDeploymentPlan(deploymentPlan);
293
+ // Track artifacts created
294
+ if (deploymentResult.sys_id) {
295
+ task.artifacts.push(deploymentResult.sys_id);
296
+ // Store artifact in memory for future reference
297
+ this.memory.storeArtifact({
298
+ type: task.type,
299
+ name: deploymentResult.name || task.objective,
300
+ sys_id: deploymentResult.sys_id,
301
+ config: deploymentResult.config || {},
302
+ dependencies: _analysis.dependencies
303
+ });
304
+ }
305
+ return deploymentResult;
306
+ }
307
+ catch (error) {
308
+ if (this.config.debugMode) {
309
+ console.error('❌ Deployment failed:', error);
310
+ }
311
+ throw error;
312
+ }
313
+ }
314
+ createDeploymentPlan(task, agentResults, _analysis) {
315
+ // Determine optimal approach based on knowledge base
316
+ const hasExistingArtifact = task.objective.toLowerCase().includes('update') ||
317
+ task.objective.toLowerCase().includes('edit') ||
318
+ task.objective.toLowerCase().includes('modify') ||
319
+ task.objective.toLowerCase().includes('change');
320
+ const requiresRefactoring = task.objective.toLowerCase().includes('refactor') ||
321
+ task.objective.toLowerCase().includes('rename') ||
322
+ task.objective.toLowerCase().includes('reorganize');
323
+ const userMentionedModifications = task.objective.toLowerCase().includes('i modified') ||
324
+ task.objective.toLowerCase().includes('i changed') ||
325
+ task.objective.toLowerCase().includes('i updated') ||
326
+ task.objective.toLowerCase().includes('aangepast') ||
327
+ task.objective.toLowerCase().includes('zelf');
328
+ const approach = (0, queen_knowledge_base_1.determineOptimalApproach)(task.objective, task.type, {
329
+ hasExistingArtifact,
330
+ complexity: _analysis.estimatedComplexity > 7 ? 'high' :
331
+ _analysis.estimatedComplexity > 4 ? 'medium' : 'low',
332
+ requiresRefactoring,
333
+ userMentionedModifications
334
+ });
335
+ if (this.config.debugMode) {
336
+ this.logger.info(`🎨 Optimal approach: ${approach}`);
337
+ this.logger.info(`🔍 Artifact sync available: ${queen_knowledge_base_1.QUEEN_KNOWLEDGE_BASE.artifactCapabilities[this.getTableForType(task.type)]?.localSync}`);
338
+ }
339
+ // If local sync is optimal and available
340
+ if (approach === 'Local Sync Development' && hasExistingArtifact) {
341
+ const table = this.getTableForType(task.type);
342
+ if (queen_knowledge_base_1.QUEEN_KNOWLEDGE_BASE.artifactCapabilities[table]?.localSync) {
343
+ return {
344
+ type: 'local-sync',
345
+ approach: approach,
346
+ mcpTool: 'snow_pull_artifact',
347
+ workflow: queen_knowledge_base_1.QUEEN_KNOWLEDGE_BASE.developmentPatterns.widgetDevelopment.approaches[0].workflow,
348
+ config: {
349
+ table: table,
350
+ sys_id: this.extractSysIdFromObjective(task.objective)
351
+ }
352
+ };
353
+ }
354
+ }
355
+ // Extract deployment instructions from agent results
356
+ const widgetCreator = agentResults.find(r => r.agentType === 'widget-creator');
357
+ const flowBuilder = agentResults.find(r => r.agentType === 'flow-builder');
358
+ const scriptWriter = agentResults.find(r => r.agentType === 'script-writer');
359
+ const catalogManager = agentResults.find(r => r.agentType === 'catalog-manager');
360
+ if (task.type === 'widget' && widgetCreator) {
361
+ return {
362
+ type: 'widget',
363
+ mcpTool: 'snow_deploy',
364
+ config: this.extractWidgetConfig(task.objective, agentResults),
365
+ autoPermissions: this.config.autoPermissions // Pass auto-permissions flag for dependency handling
366
+ };
367
+ }
368
+ // Flow creation is no longer supported - use ServiceNow Flow Designer directly
369
+ if (task.type === 'flow') {
370
+ throw new Error('Flow creation is no longer supported in Snow-Flow. Please use ServiceNow Flow Designer directly.');
371
+ }
372
+ if (task.type === 'script' && scriptWriter) {
373
+ return {
374
+ type: 'script',
375
+ mcpTool: 'snow_create_script_include',
376
+ config: this.extractScriptConfig(task.objective, agentResults)
377
+ };
378
+ }
379
+ // Default deployment plan
380
+ return {
381
+ type: task.type,
382
+ mcpTool: 'snow_deploy',
383
+ instruction: task.objective
384
+ };
385
+ }
386
+ extractWidgetConfig(objective, agentResults) {
387
+ // Extract widget configuration from agent results
388
+ const widgetResult = agentResults.find(r => r.agentType === 'widget-creator');
389
+ return {
390
+ name: this.generateArtifactName(objective, 'widget'),
391
+ title: this.generateArtifactTitle(objective),
392
+ template: this.generateWidgetTemplate(objective),
393
+ css: this.generateWidgetCss(objective),
394
+ client_script: this.generateClientScript(objective),
395
+ script: this.generateServerScript(objective), // ServiceNow uses 'script' field, not 'server_script'
396
+ demo_data: this.generateDemoData(objective)
397
+ };
398
+ }
399
+ extractScriptConfig(objective, agentResults) {
400
+ return {
401
+ name: this.generateArtifactName(objective, 'script'),
402
+ description: `Auto-generated script for: ${objective}`,
403
+ script: this.generateScriptCode(objective)
404
+ };
405
+ }
406
+ // Simple artifact generation based on objective analysis
407
+ generateArtifactName(objective, type) {
408
+ const words = objective.toLowerCase().replace(/[^a-z\s]/g, '').split(/\s+/).filter(w => w.length > 2);
409
+ const key_words = words.slice(0, 3).join('_');
410
+ return `${key_words}_${type}`;
411
+ }
412
+ generateArtifactTitle(objective) {
413
+ return objective.charAt(0).toUpperCase() + objective.slice(1);
414
+ }
415
+ generateWidgetTemplate(objective) {
416
+ const isChart = objective.toLowerCase().includes('chart') || objective.toLowerCase().includes('graph');
417
+ const isDashboard = objective.toLowerCase().includes('dashboard');
418
+ if (isChart) {
419
+ return `
420
+ <div class="panel panel-default">
421
+ <div class="panel-heading">
422
+ <h3 class="panel-title">{{data.title || '${this.generateArtifactTitle(objective)}'}}</h3>
423
+ </div>
424
+ <div class="panel-body">
425
+ <canvas id="chart-{{::data.widget_id}}" width="400" height="200"></canvas>
426
+ </div>
427
+ </div>`;
428
+ }
429
+ if (isDashboard) {
430
+ return `
431
+ <div class="row">
432
+ <div class="col-md-12">
433
+ <div class="panel panel-default">
434
+ <div class="panel-heading">
435
+ <h3 class="panel-title">{{data.title || '${this.generateArtifactTitle(objective)}'}}</h3>
436
+ </div>
437
+ <div class="panel-body">
438
+ <div class="row">
439
+ <div class="col-md-4" ng-repeat="item in data.items">
440
+ <div class="well text-center">
441
+ <h4>{{item.label}}</h4>
442
+ <h2 class="text-primary">{{item.value}}</h2>
443
+ </div>
444
+ </div>
445
+ </div>
446
+ </div>
447
+ </div>
448
+ </div>
449
+ </div>`;
450
+ }
451
+ return `
452
+ <div class="panel panel-default">
453
+ <div class="panel-heading">
454
+ <h3 class="panel-title">{{data.title || '${this.generateArtifactTitle(objective)}'}}</h3>
455
+ </div>
456
+ <div class="panel-body">
457
+ <div ng-if="data.items.length > 0">
458
+ <div class="list-group">
459
+ <div class="list-group-item" ng-repeat="item in data.items">
460
+ <h4 class="list-group-item-heading">{{item.title}}</h4>
461
+ <p class="list-group-item-text">{{item.description}}</p>
462
+ </div>
463
+ </div>
464
+ </div>
465
+ <div ng-if="data.items.length === 0" class="text-center">
466
+ <p>No items to display</p>
467
+ </div>
468
+ </div>
469
+ </div>`;
470
+ }
471
+ generateWidgetCss(objective) {
472
+ return `
473
+ .panel {
474
+ margin-bottom: 20px;
475
+ border-radius: 6px;
476
+ }
477
+
478
+ .panel-heading {
479
+ background-color: #f5f5f5;
480
+ border-bottom: 1px solid #ddd;
481
+ }
482
+
483
+ .panel-body {
484
+ padding: 15px;
485
+ }
486
+
487
+ .well {
488
+ background-color: #f9f9f9;
489
+ border: 1px solid #e3e3e3;
490
+ border-radius: 4px;
491
+ padding: 19px;
492
+ margin-bottom: 20px;
493
+ }
494
+
495
+ .text-primary {
496
+ color: #337ab7;
497
+ }
498
+
499
+ @media (max-width: 768px) {
500
+ .col-md-4 {
501
+ margin-bottom: 15px;
502
+ }
503
+ }`;
504
+ }
505
+ generateClientScript(objective) {
506
+ const isChart = objective.toLowerCase().includes('chart') || objective.toLowerCase().includes('graph');
507
+ if (isChart) {
508
+ return `
509
+ function($scope) {
510
+ var c = this;
511
+
512
+ c.$onInit = function() {
513
+ if (c.data.chartData) {
514
+ c.renderChart();
515
+ }
516
+ };
517
+
518
+ c.renderChart = function() {
519
+ var ctx = document.getElementById('chart-' + c.data.widget_id);
520
+ if (ctx && c.data.chartData) {
521
+ new Chart(ctx, {
522
+ type: c.data.chartType || 'bar',
523
+ data: c.data.chartData,
524
+ options: {
525
+ responsive: true,
526
+ plugins: {
527
+ title: {
528
+ display: true,
529
+ text: c.data.title || 'Chart'
530
+ }
531
+ }
532
+ }
533
+ });
534
+ }
535
+ };
536
+ }`;
537
+ }
538
+ return `
539
+ function($scope) {
540
+ var c = this;
541
+
542
+ c.$onInit = function() {
543
+ // Initialize widget
544
+ if (c.data.items) {
545
+ c.processItems();
546
+ }
547
+ };
548
+
549
+ c.processItems = function() {
550
+ // Process and format items for display
551
+ c.data.items = c.data.items || [];
552
+ };
553
+
554
+ c.refreshData = function() {
555
+ c.server.refresh();
556
+ };
557
+ }`;
558
+ }
559
+ generateServerScript(objective) {
560
+ const lowerObjective = objective.toLowerCase();
561
+ if (lowerObjective.includes('incident')) {
562
+ return `
563
+ (function() {
564
+ data.title = options.title || 'Incidents Dashboard';
565
+ data.widget_id = gs.generateGUID();
566
+
567
+ // Query incidents
568
+ var gr = new GlideRecord('incident');
569
+ gr.addActiveQuery();
570
+ gr.orderByDesc('sys_created_on');
571
+ gr.setLimit(10);
572
+ gr.query();
573
+
574
+ data.items = [];
575
+ while (gr.next()) {
576
+ data.items.push({
577
+ title: gr.getValue('short_description'),
578
+ description: 'Priority: ' + gr.getDisplayValue('priority') + ' | State: ' + gr.getDisplayValue('state'),
579
+ sys_id: gr.getValue('sys_id'),
580
+ priority: gr.getValue('priority'),
581
+ state: gr.getValue('state')
582
+ });
583
+ }
584
+
585
+ // Chart data for incidents by priority
586
+ if (data.items.length > 0) {
587
+ var priorityCounts = {};
588
+ data.items.forEach(function(item) {
589
+ priorityCounts[item.priority] = (priorityCounts[item.priority] || 0) + 1;
590
+ });
591
+
592
+ data.chartData = {
593
+ labels: Object.keys(priorityCounts),
594
+ datasets: [{
595
+ label: 'Incidents by Priority',
596
+ data: Object.values(priorityCounts),
597
+ backgroundColor: ['#ff6384', '#ff9f40', '#ffcd56', '#4bc0c0']
598
+ }]
599
+ };
600
+ data.chartType = 'doughnut';
601
+ }
602
+ })();`;
603
+ }
604
+ return `
605
+ (function() {
606
+ data.title = options.title || '${this.generateArtifactTitle(objective)}';
607
+ data.widget_id = gs.generateGUID();
608
+ data.items = [];
609
+
610
+ // Add your data processing logic here
611
+ // Example: Query relevant records and populate data.items
612
+
613
+ // Default demo data
614
+ data.items = [
615
+ {
616
+ title: 'Sample Item 1',
617
+ description: 'This is a sample item for demonstration'
618
+ },
619
+ {
620
+ title: 'Sample Item 2',
621
+ description: 'This is another sample item'
622
+ }
623
+ ];
624
+ })();`;
625
+ }
626
+ generateDemoData(objective) {
627
+ return {
628
+ title: this.generateArtifactTitle(objective),
629
+ items: [
630
+ {
631
+ title: 'Demo Item 1',
632
+ description: 'Sample data for testing the widget'
633
+ }
634
+ ]
635
+ };
636
+ }
637
+ generateScriptCode(objective) {
638
+ return `
639
+ // Auto-generated script for: ${objective}
640
+ // Generated by ServiceNow Queen Agent
641
+
642
+ (function() {
643
+ // Add your script logic here
644
+ gs.info('${objective} script executed');
645
+
646
+ return {
647
+ success: true,
648
+ message: 'Script executed successfully'
649
+ };
650
+ })();`;
651
+ }
652
+ async executeDeploymentPlan(plan) {
653
+ // Handle local sync workflow for artifact editing
654
+ if (plan.type === 'local-sync') {
655
+ if (this.config.debugMode) {
656
+ this.logger.info('🔄 Executing Local Sync Development workflow');
657
+ this.logger.info('📁 Artifact will be synced to local files for editing');
658
+ }
659
+ // Create recommendation for local sync
660
+ const recommendation = {
661
+ agentId: 'queen-agent',
662
+ agentType: 'queen',
663
+ action: 'local-sync',
664
+ tool: 'snow_pull_artifact',
665
+ server: 'servicenow-local-development',
666
+ params: plan.config,
667
+ reasoning: 'Syncing artifact to local files for advanced editing with Claude Code',
668
+ confidence: 0.95
669
+ };
670
+ // Execute pull through MCP bridge
671
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
672
+ if (result.success) {
673
+ return {
674
+ success: true,
675
+ type: 'local-sync',
676
+ approach: plan.approach,
677
+ message: 'Artifact synced to local files. Edit with Claude Code, then use snow_push_artifact to sync back.',
678
+ localPath: result.toolResult?.localPath,
679
+ files: result.toolResult?.files
680
+ };
681
+ }
682
+ }
683
+ // Execute real MCP tools through the bridge
684
+ if (this.config.debugMode) {
685
+ this.logger.info('🚀 Executing deployment plan with MCP Bridge');
686
+ }
687
+ // Create agent recommendation from plan
688
+ const recommendation = {
689
+ agentId: 'queen-agent',
690
+ agentType: 'queen',
691
+ action: `deploy-${plan.type}`,
692
+ tool: plan.mcpTool,
693
+ server: this.getServerForTool(plan.mcpTool),
694
+ params: plan.config || {},
695
+ reasoning: `Deploying ${plan.type} artifact as requested`,
696
+ confidence: 0.95
697
+ };
698
+ // Execute through MCP bridge
699
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
700
+ if (result.success && result.toolResult) {
701
+ const deploymentResult = {
702
+ success: true,
703
+ type: plan.type,
704
+ name: plan.config?.name || result.toolResult.name,
705
+ sys_id: result.toolResult.sys_id, // Real sys_id from ServiceNow!
706
+ config: plan.config,
707
+ mcpTool: plan.mcpTool,
708
+ executionTime: result.executionTime
709
+ };
710
+ // Handle dependency injection for widgets
711
+ if (plan.type === 'widget' && plan.config) {
712
+ await this.handleWidgetDependencies(plan.config, plan.autoPermissions);
713
+ }
714
+ return deploymentResult;
715
+ }
716
+ else {
717
+ throw new Error(`MCP execution failed: ${result.error || 'Unknown error'}`);
718
+ }
719
+ }
720
+ getServerForTool(tool) {
721
+ // Map tools to their servers
722
+ const toolServerMap = {
723
+ 'snow_deploy': 'deployment',
724
+ 'snow_deploy_widget': 'deployment',
725
+ 'snow_deploy_flow': 'deployment',
726
+ 'snow_find_artifact': 'intelligent',
727
+ 'snow_update_set_create': 'update-set',
728
+ 'snow_get_by_sysid': 'intelligent',
729
+ 'snow_edit_by_sysid': 'intelligent'
730
+ };
731
+ return toolServerMap[tool] || 'deployment';
732
+ }
733
+ async handleWidgetDependencies(widgetConfig, autoPermissions) {
734
+ try {
735
+ // Detect dependencies in widget code
736
+ const dependencies = dependency_detector_1.DependencyDetector.analyzeWidget(widgetConfig);
737
+ if (dependencies.length === 0) {
738
+ return; // No dependencies needed
739
+ }
740
+ this.logger.info(`\n📦 Detected ${dependencies.length} external dependencies in widget:`);
741
+ dependencies.forEach(dep => {
742
+ this.logger.info(` • ${dep.name} - ${dep.description}`);
743
+ });
744
+ // Create MCP tools wrapper for theme manager
745
+ const mcpTools = {
746
+ snow_find_artifact: async (params) => {
747
+ const recommendation = {
748
+ agentId: 'queen-agent',
749
+ agentType: 'queen',
750
+ action: 'find-theme',
751
+ tool: 'snow_find_artifact',
752
+ server: 'intelligent',
753
+ params,
754
+ reasoning: 'Finding Service Portal theme for dependency injection',
755
+ confidence: 0.95
756
+ };
757
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
758
+ return result.toolResult;
759
+ },
760
+ snow_comprehensive_search: async (params) => {
761
+ const recommendation = {
762
+ agentId: 'queen-agent',
763
+ agentType: 'queen',
764
+ action: 'search-themes',
765
+ tool: 'snow_comprehensive_search',
766
+ server: 'intelligent',
767
+ params,
768
+ reasoning: 'Searching for Service Portal themes',
769
+ confidence: 0.95
770
+ };
771
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
772
+ return result.toolResult;
773
+ },
774
+ snow_get_by_sysid: async (params) => {
775
+ const recommendation = {
776
+ agentId: 'queen-agent',
777
+ agentType: 'queen',
778
+ action: 'get-theme',
779
+ tool: 'snow_get_by_sysid',
780
+ server: 'intelligent',
781
+ params,
782
+ reasoning: 'Getting Service Portal theme details',
783
+ confidence: 0.95
784
+ };
785
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
786
+ return result.toolResult;
787
+ },
788
+ snow_edit_by_sysid: async (params) => {
789
+ const recommendation = {
790
+ agentId: 'queen-agent',
791
+ agentType: 'queen',
792
+ action: 'update-theme',
793
+ tool: 'snow_edit_by_sysid',
794
+ server: 'intelligent',
795
+ params,
796
+ reasoning: 'Updating Service Portal theme with dependencies',
797
+ confidence: 0.95
798
+ };
799
+ const result = await this.mcpBridge.executeAgentRecommendation({ id: 'queen-agent', type: 'queen' }, recommendation);
800
+ return result.toolResult;
801
+ }
802
+ };
803
+ // Update theme with dependencies
804
+ const result = await theme_manager_1.ServicePortalThemeManager.updateThemeWithDependencies(dependencies, mcpTools, {
805
+ autoPermissions,
806
+ skipPrompt: autoPermissions, // Skip prompt if auto-permissions enabled
807
+ useMinified: true
808
+ });
809
+ if (result.success) {
810
+ this.logger.info(`✅ ${result.message}`);
811
+ }
812
+ else {
813
+ this.logger.warn(`⚠️ Dependencies not installed: ${result.message}`);
814
+ this.logger.info('💡 You may need to manually add these dependencies to your Service Portal theme');
815
+ }
816
+ }
817
+ catch (error) {
818
+ console.error('❌ Error handling widget dependencies:', error.message);
819
+ // Don't fail the deployment, just warn
820
+ this.logger.warn('⚠️ Widget deployed successfully but dependencies may need manual installation');
821
+ }
822
+ }
823
+ async attemptRecovery(task, agents, error) {
824
+ if (this.config.debugMode) {
825
+ this.logger.info(`🔄 Attempting recovery for task ${task.id}`);
826
+ }
827
+ // Try with reduced complexity or different agent sequence
828
+ const fallbackResult = {
829
+ taskId: task.id,
830
+ objective: task.objective,
831
+ status: 'recovered',
832
+ error: error.message,
833
+ fallbackApplied: true
834
+ };
835
+ return fallbackResult;
836
+ }
837
+ learnFromExecution(task, agents, result, duration, error) {
838
+ const agentTypes = agents.map(a => a.type);
839
+ if (error) {
840
+ // Learn from failure
841
+ this.neuralLearning.learnFromFailure(task, error.message, agentTypes);
842
+ this.memory.recordTaskCompletion(task.id, task.objective, task.type, agentTypes, false, duration);
843
+ }
844
+ else {
845
+ // Learn from success
846
+ this.neuralLearning.learnFromSuccess(task, duration, agentTypes);
847
+ this.memory.recordTaskCompletion(task.id, task.objective, task.type, agentTypes, true, duration);
848
+ }
849
+ if (this.config.debugMode) {
850
+ this.logger.info(`📚 Queen learned from ${error ? 'failure' : 'success'}: ${task.objective}`);
851
+ }
852
+ }
853
+ async handleExecutionFailure(taskId, objective, error, duration) {
854
+ const task = this.activeTasks.get(taskId);
855
+ if (task) {
856
+ task.status = 'failed';
857
+ task.error = error.message;
858
+ // Learn from failure
859
+ this.memory.storeLearning(`failure_${task.type}`, `Failed: ${objective} - Error: ${error.message}`, 0.8);
860
+ }
861
+ if (this.config.debugMode) {
862
+ console.error(`❌ Task ${taskId} failed after ${duration}ms:`, error.message);
863
+ }
864
+ }
865
+ cleanupTask(taskId) {
866
+ this.activeTasks.delete(taskId);
867
+ this.agentFactory.cleanupCompletedAgents();
868
+ }
869
+ generateTaskId() {
870
+ return `task_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`;
871
+ }
872
+ // Public API methods
873
+ getActiveTaskCount() {
874
+ return this.activeTasks.size;
875
+ }
876
+ getTaskStatus(taskId) {
877
+ return this.activeTasks.get(taskId) || null;
878
+ }
879
+ /**
880
+ * Get gap _analysis results for a task
881
+ */
882
+ getGapAnalysisResults(taskId) {
883
+ const task = this.activeTasks.get(taskId);
884
+ return task?.gapAnalysis || null;
885
+ }
886
+ /**
887
+ * Get all manual guides from gap _analysis for a task
888
+ */
889
+ getManualConfigurationGuides(taskId) {
890
+ // Get strategic analysis from task
891
+ const task = this.activeTasks.get(taskId);
892
+ const strategicAnalysis = task?.strategicAnalysis;
893
+ return strategicAnalysis?.problemAnalysis?.hiddenRequirements || null;
894
+ }
895
+ getHiveMindStatus() {
896
+ return {
897
+ activeTasks: this.activeTasks.size,
898
+ activeAgents: this.agentFactory.getActiveAgents().length,
899
+ memoryStats: {
900
+ patterns: this.memory['memory'].patterns.length,
901
+ artifacts: this.memory['memory'].artifacts.size,
902
+ learnings: this.memory['memory'].learnings.size
903
+ },
904
+ factoryStats: this.agentFactory.getStatistics(),
905
+ learningInsights: this.neuralLearning.getLearningInsights()
906
+ };
907
+ }
908
+ exportMemory() {
909
+ return this.memory.exportMemory();
910
+ }
911
+ importMemory(memoryData) {
912
+ this.memory.importMemory(memoryData);
913
+ if (this.config.debugMode) {
914
+ this.logger.info('🧠 Queen hive-mind memory imported successfully');
915
+ }
916
+ }
917
+ clearMemory() {
918
+ this.memory.clearMemory();
919
+ // Also reset neural learning weights
920
+ this.neuralLearning = new neural_learning_1.NeuralLearning(this.memory);
921
+ if (this.config.debugMode) {
922
+ this.logger.info('🧠 Queen hive-mind memory cleared - starting fresh');
923
+ }
924
+ }
925
+ getLearningInsights() {
926
+ const neuralInsights = this.neuralLearning.getLearningInsights();
927
+ return {
928
+ successfulPatterns: this.memory['memory'].patterns.slice(0, 5).map(pattern => ({
929
+ description: `${pattern.taskType} deployment using ${pattern.agentSequence.join(' → ')}`,
930
+ successRate: Math.round(pattern.successRate * 100),
931
+ avgDuration: pattern.avgDuration,
932
+ useCount: this.memory.getSuccessRate(pattern.taskType)
933
+ })),
934
+ recommendations: [
935
+ 'Use Queen Agent for complex multi-step ServiceNow tasks',
936
+ 'Enable --debug mode for detailed hive-mind insights',
937
+ 'Export memory regularly to preserve learning patterns',
938
+ 'Let Queen analyze objectives for optimal agent coordination'
939
+ ],
940
+ commonTasks: Object.entries(neuralInsights.weights || {})
941
+ .map(([type, count]) => ({
942
+ type,
943
+ count: typeof count === 'number' ? count : 0
944
+ }))
945
+ .sort((a, b) => b.count - a.count)
946
+ .slice(0, 5),
947
+ memoryStats: {
948
+ totalPatterns: this.memory['memory'].patterns.length,
949
+ totalArtifacts: this.memory['memory'].artifacts.size,
950
+ totalLearnings: this.memory['memory'].learnings.size
951
+ },
952
+ neuralInsights
953
+ };
954
+ }
955
+ async shutdown() {
956
+ this.logger.info('🛑 DISABLED: ServiceNow Queen shutdown disabled for persistence');
957
+ this.logger.info('🔄 Queen Agent and MCP servers will continue running indefinitely');
958
+ // DISABLED: All shutdown logic for persistent operation
959
+ /*
960
+ if (this.config.debugMode) {
961
+ this.logger.info('🛑 Shutting down ServiceNow Queen Agent');
962
+ }
963
+
964
+ // Clean up all agents
965
+ const activeAgents = this.agentFactory.getActiveAgents();
966
+ for (const agent of activeAgents) {
967
+ this.agentFactory.terminateAgent(agent.id);
968
+ }
969
+
970
+ // Shutdown MCP Bridge
971
+ if (this.mcpBridge) {
972
+ await this.mcpBridge.shutdown();
973
+ }
974
+ */
975
+ // Close memory system
976
+ this.memory.close();
977
+ }
978
+ /**
979
+ * STRATEGIC ORCHESTRATION METHODS
980
+ * These methods implement the Queen Agent's strategic thinking capabilities
981
+ */
982
+ /**
983
+ * Perform deep problem analysis to understand what user ACTUALLY needs
984
+ */
985
+ async performDeepProblemAnalysis(objective) {
986
+ this.logger.info('🧠 Deep Problem Analysis: Looking beyond surface requirements...');
987
+ // Analyze the objective for hidden complexity and real business needs
988
+ const analysis = {
989
+ coreProblem: this.extractCoreProblem(objective),
990
+ complexity: this.assessObjectiveComplexity(objective),
991
+ businessImpact: this.assessBusinessImpact(objective),
992
+ stakeholders: this.identifyStakeholders(objective),
993
+ hiddenRequirements: this.identifyHiddenRequirements(objective),
994
+ successCriteria: this.defineSuccessCriteria(objective)
995
+ };
996
+ this.logger.info(`🎯 Core Problem Identified: ${analysis.coreProblem}`);
997
+ this.logger.info(`📈 Success Criteria: ${analysis.successCriteria.join(', ')}`);
998
+ return analysis;
999
+ }
1000
+ /**
1001
+ * Perform comprehensive risk assessment
1002
+ */
1003
+ async performRiskAssessment(objective, problemAnalysis) {
1004
+ this.logger.info('⚠️ Strategic Risk Assessment: Identifying all potential failure points...');
1005
+ const risks = [
1006
+ ...this.identifyTechnicalRisks(objective, problemAnalysis),
1007
+ ...this.identifyBusinessRisks(objective, problemAnalysis),
1008
+ ...this.identifyOperationalRisks(objective, problemAnalysis),
1009
+ ...this.identifyComplianceRisks(objective, problemAnalysis)
1010
+ ];
1011
+ const criticalRisks = risks.filter(risk => risk.impact === 'high' && risk.likelihood === 'high');
1012
+ const overallRisk = this.calculateOverallRisk(risks);
1013
+ return {
1014
+ risks,
1015
+ criticalRisks,
1016
+ overallRisk,
1017
+ mitigationStrategies: this.developMitigationStrategies(criticalRisks)
1018
+ };
1019
+ }
1020
+ /**
1021
+ * Extract the core business problem from user request
1022
+ */
1023
+ getTableForType(type) {
1024
+ const typeToTable = {
1025
+ 'widget': 'sp_widget',
1026
+ 'flow': 'sys_hub_flow',
1027
+ 'script': 'sys_script_include',
1028
+ 'business_rule': 'sys_script',
1029
+ 'ui_page': 'sys_ui_page',
1030
+ 'client_script': 'sys_script_client',
1031
+ 'ui_policy': 'sys_ui_policy',
1032
+ 'scheduled_job': 'sysauto_script',
1033
+ 'fix_script': 'sys_script_fix'
1034
+ };
1035
+ return typeToTable[type] || 'sys_metadata';
1036
+ }
1037
+ extractSysIdFromObjective(objective) {
1038
+ // Look for sys_id patterns in the objective
1039
+ const sysIdPattern = /[a-f0-9]{32}/i;
1040
+ const match = objective.match(sysIdPattern);
1041
+ return match ? match[0] : undefined;
1042
+ }
1043
+ extractCoreProblem(objective) {
1044
+ const objective_lower = objective.toLowerCase();
1045
+ // Analyze patterns to understand underlying need
1046
+ if (objective_lower.includes('widget') || objective_lower.includes('dashboard')) {
1047
+ return 'Users need better access to information or functionality through improved interface';
1048
+ }
1049
+ else if (objective_lower.includes('workflow') || objective_lower.includes('process')) {
1050
+ return 'Business process efficiency and automation needs improvement';
1051
+ }
1052
+ else if (objective_lower.includes('integration') || objective_lower.includes('api')) {
1053
+ return 'Systems need to communicate effectively to eliminate manual work';
1054
+ }
1055
+ else if (objective_lower.includes('report') || objective_lower.includes('analytics')) {
1056
+ return 'Decision makers need better visibility into business performance';
1057
+ }
1058
+ else if (objective_lower.includes('notification') || objective_lower.includes('alert')) {
1059
+ return 'Stakeholders need timely awareness of important events or status changes';
1060
+ }
1061
+ else {
1062
+ return 'Business capability needs enhancement through ServiceNow platform optimization';
1063
+ }
1064
+ }
1065
+ /**
1066
+ * Assess objective complexity
1067
+ */
1068
+ assessObjectiveComplexity(objective) {
1069
+ let complexity_score = 0;
1070
+ const high_complexity_indicators = ['integration', 'multiple', 'complex', 'enterprise', 'automated', 'workflow'];
1071
+ const medium_complexity_indicators = ['dashboard', 'report', 'widget', 'form', 'approval'];
1072
+ high_complexity_indicators.forEach(indicator => {
1073
+ if (objective.toLowerCase().includes(indicator))
1074
+ complexity_score += 2;
1075
+ });
1076
+ medium_complexity_indicators.forEach(indicator => {
1077
+ if (objective.toLowerCase().includes(indicator))
1078
+ complexity_score += 1;
1079
+ });
1080
+ if (objective.length > 100)
1081
+ complexity_score += 1;
1082
+ if (objective.split(' ').length > 20)
1083
+ complexity_score += 1;
1084
+ if (complexity_score >= 4)
1085
+ return 'high';
1086
+ if (complexity_score >= 2)
1087
+ return 'medium';
1088
+ return 'low';
1089
+ }
1090
+ /**
1091
+ * Assess business impact
1092
+ */
1093
+ assessBusinessImpact(objective) {
1094
+ const high_impact_keywords = ['critical', 'urgent', 'production', 'enterprise', 'compliance', 'security'];
1095
+ const medium_impact_keywords = ['efficiency', 'automation', 'improvement', 'optimization', 'user experience'];
1096
+ const objective_lower = objective.toLowerCase();
1097
+ if (high_impact_keywords.some(keyword => objective_lower.includes(keyword)))
1098
+ return 'high';
1099
+ if (medium_impact_keywords.some(keyword => objective_lower.includes(keyword)))
1100
+ return 'medium';
1101
+ return 'low';
1102
+ }
1103
+ /**
1104
+ * Identify stakeholders affected by the change
1105
+ */
1106
+ identifyStakeholders(objective) {
1107
+ const stakeholders = new Set();
1108
+ const objective_lower = objective.toLowerCase();
1109
+ // Default stakeholders for any ServiceNow change
1110
+ stakeholders.add('End Users');
1111
+ stakeholders.add('System Administrators');
1112
+ // Add specific stakeholders based on objective
1113
+ if (objective_lower.includes('approval'))
1114
+ stakeholders.add('Approvers');
1115
+ if (objective_lower.includes('manager'))
1116
+ stakeholders.add('Managers');
1117
+ if (objective_lower.includes('report') || objective_lower.includes('dashboard'))
1118
+ stakeholders.add('Business Analysts');
1119
+ if (objective_lower.includes('integration'))
1120
+ stakeholders.add('IT Operations');
1121
+ if (objective_lower.includes('security') || objective_lower.includes('compliance'))
1122
+ stakeholders.add('Security Team');
1123
+ if (objective_lower.includes('catalog') || objective_lower.includes('service'))
1124
+ stakeholders.add('Service Desk');
1125
+ return Array.from(stakeholders);
1126
+ }
1127
+ /**
1128
+ * Identify hidden requirements not explicitly stated
1129
+ */
1130
+ identifyHiddenRequirements(objective) {
1131
+ const hiddenReqs = [];
1132
+ const objective_lower = objective.toLowerCase();
1133
+ // Universal hidden requirements
1134
+ hiddenReqs.push('Solution must be maintainable by current team');
1135
+ hiddenReqs.push('Performance must not degrade existing system');
1136
+ hiddenReqs.push('Solution must be scalable for future growth');
1137
+ // Context-specific hidden requirements
1138
+ if (objective_lower.includes('widget') || objective_lower.includes('portal')) {
1139
+ hiddenReqs.push('Must work across all browsers and devices');
1140
+ hiddenReqs.push('Must meet accessibility standards');
1141
+ }
1142
+ if (objective_lower.includes('integration')) {
1143
+ hiddenReqs.push('Must handle integration failures gracefully');
1144
+ hiddenReqs.push('Must maintain data consistency');
1145
+ }
1146
+ if (objective_lower.includes('workflow') || objective_lower.includes('automation')) {
1147
+ hiddenReqs.push('Must handle exceptions and edge cases');
1148
+ hiddenReqs.push('Must provide clear audit trail');
1149
+ }
1150
+ return hiddenReqs;
1151
+ }
1152
+ /**
1153
+ * Define clear success criteria
1154
+ */
1155
+ defineSuccessCriteria(objective) {
1156
+ const criteria = [];
1157
+ const objective_lower = objective.toLowerCase();
1158
+ // Universal success criteria
1159
+ criteria.push('Solution deployed without system disruption');
1160
+ criteria.push('All stakeholders can use the solution effectively');
1161
+ criteria.push('Performance meets or exceeds baseline requirements');
1162
+ // Specific success criteria based on objective
1163
+ if (objective_lower.includes('widget') || objective_lower.includes('dashboard')) {
1164
+ criteria.push('Users can access information faster than before');
1165
+ criteria.push('User satisfaction with interface is positive');
1166
+ }
1167
+ if (objective_lower.includes('workflow') || objective_lower.includes('automation')) {
1168
+ criteria.push('Process time reduced compared to manual process');
1169
+ criteria.push('Error rate is lower than manual process');
1170
+ }
1171
+ if (objective_lower.includes('integration')) {
1172
+ criteria.push('Data flows correctly between systems');
1173
+ criteria.push('Integration performs within SLA requirements');
1174
+ }
1175
+ return criteria;
1176
+ }
1177
+ /**
1178
+ * Identify technical risks
1179
+ */
1180
+ identifyTechnicalRisks(objective, analysis) {
1181
+ const risks = [];
1182
+ const objective_lower = objective.toLowerCase();
1183
+ if (objective_lower.includes('integration')) {
1184
+ risks.push({
1185
+ type: 'technical',
1186
+ description: 'Integration points may fail or perform poorly',
1187
+ impact: 'high',
1188
+ likelihood: 'medium',
1189
+ mitigation: 'Implement robust error handling and monitoring'
1190
+ });
1191
+ }
1192
+ if (objective_lower.includes('widget') || objective_lower.includes('custom')) {
1193
+ risks.push({
1194
+ type: 'technical',
1195
+ description: 'Custom code may conflict with platform updates',
1196
+ impact: 'medium',
1197
+ likelihood: 'medium',
1198
+ mitigation: 'Follow platform best practices and test thoroughly'
1199
+ });
1200
+ }
1201
+ if (analysis.complexity === 'high') {
1202
+ risks.push({
1203
+ type: 'technical',
1204
+ description: 'High complexity increases chance of defects',
1205
+ impact: 'high',
1206
+ likelihood: 'high',
1207
+ mitigation: 'Break down into smaller phases with thorough testing'
1208
+ });
1209
+ }
1210
+ return risks;
1211
+ }
1212
+ /**
1213
+ * Identify business risks
1214
+ */
1215
+ identifyBusinessRisks(objective, analysis) {
1216
+ const risks = [];
1217
+ if (analysis.businessImpact === 'high') {
1218
+ risks.push({
1219
+ type: 'business',
1220
+ description: 'High business impact means high visibility and pressure',
1221
+ impact: 'high',
1222
+ likelihood: 'medium',
1223
+ mitigation: 'Ensure thorough testing and stakeholder communication'
1224
+ });
1225
+ }
1226
+ if (analysis.stakeholders.length > 5) {
1227
+ risks.push({
1228
+ type: 'business',
1229
+ description: 'Many stakeholders increase coordination complexity',
1230
+ impact: 'medium',
1231
+ likelihood: 'high',
1232
+ mitigation: 'Establish clear communication plan and change management'
1233
+ });
1234
+ }
1235
+ return risks;
1236
+ }
1237
+ /**
1238
+ * Identify operational risks
1239
+ */
1240
+ identifyOperationalRisks(objective, analysis) {
1241
+ const risks = [];
1242
+ const objective_lower = objective.toLowerCase();
1243
+ if (objective_lower.includes('automation') || objective_lower.includes('workflow')) {
1244
+ risks.push({
1245
+ type: 'operational',
1246
+ description: 'Automated processes may fail and require manual intervention',
1247
+ impact: 'medium',
1248
+ likelihood: 'medium',
1249
+ mitigation: 'Build in manual override capabilities and monitoring'
1250
+ });
1251
+ }
1252
+ return risks;
1253
+ }
1254
+ /**
1255
+ * Identify compliance risks
1256
+ */
1257
+ identifyComplianceRisks(objective, analysis) {
1258
+ const risks = [];
1259
+ const objective_lower = objective.toLowerCase();
1260
+ if (objective_lower.includes('data') || objective_lower.includes('integration')) {
1261
+ risks.push({
1262
+ type: 'compliance',
1263
+ description: 'Data handling may not meet privacy or security requirements',
1264
+ impact: 'high',
1265
+ likelihood: 'low',
1266
+ mitigation: 'Review with security and compliance teams'
1267
+ });
1268
+ }
1269
+ return risks;
1270
+ }
1271
+ /**
1272
+ * Calculate overall risk level
1273
+ */
1274
+ calculateOverallRisk(risks) {
1275
+ const high_risk_count = risks.filter(r => r.impact === 'high' && r.likelihood === 'high').length;
1276
+ const medium_risk_count = risks.filter(r => (r.impact === 'high' && r.likelihood === 'medium') ||
1277
+ (r.impact === 'medium' && r.likelihood === 'high')).length;
1278
+ if (high_risk_count > 0)
1279
+ return 'high';
1280
+ if (medium_risk_count > 1)
1281
+ return 'high';
1282
+ if (medium_risk_count > 0 || risks.length > 3)
1283
+ return 'medium';
1284
+ return 'low';
1285
+ }
1286
+ /**
1287
+ * Develop mitigation strategies for critical risks
1288
+ */
1289
+ developMitigationStrategies(criticalRisks) {
1290
+ const strategies = criticalRisks.map(risk => risk.mitigation);
1291
+ // Add general mitigation strategies
1292
+ strategies.push('Implement comprehensive testing at each phase');
1293
+ strategies.push('Establish rollback procedures before deployment');
1294
+ strategies.push('Monitor solution performance post-deployment');
1295
+ return [...new Set(strategies)]; // Remove duplicates
1296
+ }
1297
+ /**
1298
+ * Design solution architecture based on strategic analysis
1299
+ */
1300
+ async designSolutionArchitecture(problemAnalysis, riskAssessment) {
1301
+ this.logger.info('🏗️ Designing Strategic Solution Architecture...');
1302
+ // Determine optimal approach based on complexity and risks
1303
+ let approach = 'standard';
1304
+ let recommendedAgents = ['researcher', 'widget-creator', 'tester'];
1305
+ if (problemAnalysis.complexity === 'high' || riskAssessment.overallRisk === 'high') {
1306
+ approach = 'phased-implementation';
1307
+ recommendedAgents = ['researcher', 'app-architect', 'widget-creator', 'security-specialist', 'tester'];
1308
+ }
1309
+ if (riskAssessment.criticalRisks.length > 2) {
1310
+ approach = 'risk-first-architecture';
1311
+ recommendedAgents.unshift('security-specialist');
1312
+ }
1313
+ // Add specialized agents based on problem domain
1314
+ const objective_lower = problemAnalysis.coreProblem.toLowerCase();
1315
+ if (objective_lower.includes('integration')) {
1316
+ recommendedAgents.push('integration-specialist');
1317
+ }
1318
+ if (objective_lower.includes('workflow') || objective_lower.includes('process')) {
1319
+ recommendedAgents.push('flow-builder');
1320
+ }
1321
+ if (objective_lower.includes('performance')) {
1322
+ recommendedAgents.push('performance-specialist');
1323
+ }
1324
+ return {
1325
+ approach,
1326
+ recommendedAgents: [...new Set(recommendedAgents)], // Remove duplicates
1327
+ implementationSteps: this.generateImplementationSteps(approach, problemAnalysis),
1328
+ qualityGates: this.defineQualityGates(problemAnalysis, riskAssessment),
1329
+ monitoringStrategy: this.defineMonitoringStrategy(problemAnalysis)
1330
+ };
1331
+ }
1332
+ /**
1333
+ * Generate implementation steps based on approach
1334
+ */
1335
+ generateImplementationSteps(approach, problemAnalysis) {
1336
+ const baseSteps = [
1337
+ 'Validate requirements with stakeholders',
1338
+ 'Create proof of concept',
1339
+ 'Implement core functionality',
1340
+ 'Conduct security review',
1341
+ 'Perform comprehensive testing',
1342
+ 'Deploy with monitoring'
1343
+ ];
1344
+ if (approach === 'phased-implementation') {
1345
+ return [
1346
+ 'Phase 1: Research and architecture design',
1347
+ 'Phase 2: Build minimal viable solution',
1348
+ 'Phase 3: Add advanced features',
1349
+ 'Phase 4: Performance optimization',
1350
+ 'Phase 5: Full deployment and monitoring'
1351
+ ];
1352
+ }
1353
+ else if (approach === 'risk-first-architecture') {
1354
+ return [
1355
+ 'Risk mitigation planning',
1356
+ 'Security architecture review',
1357
+ ...baseSteps,
1358
+ 'Post-deployment risk validation'
1359
+ ];
1360
+ }
1361
+ return baseSteps;
1362
+ }
1363
+ /**
1364
+ * Define quality gates based on analysis
1365
+ */
1366
+ defineQualityGates(problemAnalysis, riskAssessment) {
1367
+ const gates = [
1368
+ 'Requirements validation complete',
1369
+ 'Architecture review passed',
1370
+ 'Code review completed',
1371
+ 'Security scan passed',
1372
+ 'Performance benchmarks met'
1373
+ ];
1374
+ if (riskAssessment.overallRisk === 'high') {
1375
+ gates.unshift('Risk mitigation plan approved');
1376
+ gates.push('Rollback procedures tested');
1377
+ }
1378
+ if (problemAnalysis.businessImpact === 'high') {
1379
+ gates.push('Stakeholder sign-off obtained');
1380
+ gates.push('Production readiness review passed');
1381
+ }
1382
+ return gates;
1383
+ }
1384
+ /**
1385
+ * Define monitoring strategy
1386
+ */
1387
+ defineMonitoringStrategy(problemAnalysis) {
1388
+ return {
1389
+ metrics: [
1390
+ 'System performance indicators',
1391
+ 'User experience metrics',
1392
+ 'Error rates and failure patterns',
1393
+ 'Business impact measurements'
1394
+ ],
1395
+ alerting: [
1396
+ 'Performance degradation alerts',
1397
+ 'Error threshold alerts',
1398
+ 'User satisfaction alerts'
1399
+ ],
1400
+ reporting: [
1401
+ 'Daily operational health reports',
1402
+ 'Weekly business impact reports',
1403
+ 'Monthly optimization recommendations'
1404
+ ]
1405
+ };
1406
+ }
1407
+ }
1408
+ exports.ServiceNowQueen = ServiceNowQueen;
1409
+ //# sourceMappingURL=servicenow-queen.js.map