snow-flow 3.0.9 → 3.0.13

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 (302) hide show
  1. package/claude-flow.bat +0 -0
  2. package/claude-flow.ps1 +0 -0
  3. package/dist/mcp/intelligent-reporting-mcp.d.ts +7 -0
  4. package/dist/mcp/intelligent-reporting-mcp.js +379 -0
  5. package/dist/mcp/servicenow-automation-mcp.js +0 -0
  6. package/dist/mcp/servicenow-deployment-mcp.js +0 -0
  7. package/dist/mcp/servicenow-integration-mcp.js +0 -0
  8. package/dist/mcp/servicenow-mcp-server.js +0 -0
  9. package/dist/mcp/servicenow-operations-mcp.js +0 -0
  10. package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
  11. package/dist/mcp/servicenow-progressive-indexer.js +0 -0
  12. package/dist/mcp/servicenow-reporting-analytics-mcp.js +280 -29
  13. package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
  14. package/dist/mcp/servicenow-update-set-mcp.js +0 -0
  15. package/dist/mcp/start-all-mcp-servers.js +0 -0
  16. package/dist/mcp/start-servicenow-mcp.js +0 -0
  17. package/dist/services/widget-deployment-service.d.ts +2 -1
  18. package/dist/services/widget-deployment-service.js +17 -16
  19. package/dist/utils/anti-mock-data-validator.d.ts +66 -0
  20. package/dist/utils/anti-mock-data-validator.js +316 -0
  21. package/dist/utils/servicenow-eventual-consistency.d.ts +120 -0
  22. package/dist/utils/servicenow-eventual-consistency.js +220 -0
  23. package/memory/agents/README.md +1 -1
  24. package/memory/claude-flow-data.json +1 -1
  25. package/memory/sessions/README.md +1 -1
  26. package/package.json +4 -3
  27. package/.mcp.json +0 -22
  28. package/claude-flow.config.json +0 -20
  29. package/dist/agents/app-creator.agent.d.ts +0 -55
  30. package/dist/agents/app-creator.agent.js +0 -1292
  31. package/dist/agents/base/base-snow-agent.d.ts +0 -75
  32. package/dist/agents/base/base-snow-agent.js +0 -169
  33. package/dist/agents/base-snow-agent.d.ts +0 -63
  34. package/dist/agents/base-snow-agent.js +0 -296
  35. package/dist/agents/coordinator.d.ts +0 -200
  36. package/dist/agents/coordinator.js +0 -777
  37. package/dist/agents/flow-builder-agent.d.ts +0 -18
  38. package/dist/agents/flow-builder-agent.js +0 -197
  39. package/dist/agents/queen-403-handler.d.ts +0 -47
  40. package/dist/agents/queen-403-handler.js +0 -175
  41. package/dist/agents/queen-agent-example.d.ts +0 -23
  42. package/dist/agents/queen-agent-example.js +0 -240
  43. package/dist/agents/queen-agent.test.d.ts +0 -6
  44. package/dist/agents/script-generator.agent.d.ts +0 -32
  45. package/dist/agents/script-generator.agent.js +0 -772
  46. package/dist/agents/script-writer-agent.d.ts +0 -22
  47. package/dist/agents/script-writer-agent.js +0 -695
  48. package/dist/agents/security-agent.d.ts +0 -23
  49. package/dist/agents/security-agent.js +0 -619
  50. package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
  51. package/dist/agents/specialists/automation-specialist.agent.js +0 -204
  52. package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
  53. package/dist/agents/specialists/data-specialist.agent.js +0 -484
  54. package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
  55. package/dist/agents/specialists/integration-specialist.agent.js +0 -725
  56. package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
  57. package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
  58. package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
  59. package/dist/agents/specialists/security-specialist.agent.js +0 -309
  60. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
  61. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
  62. package/dist/agents/teams/base-team.d.ts +0 -72
  63. package/dist/agents/teams/base-team.js +0 -253
  64. package/dist/agents/teams/team-types.d.ts +0 -265
  65. package/dist/agents/teams/team-types.js +0 -3
  66. package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
  67. package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
  68. package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
  69. package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
  70. package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
  71. package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
  72. package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
  73. package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
  74. package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
  75. package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
  76. package/dist/agents/test-agent.d.ts +0 -26
  77. package/dist/agents/test-agent.js +0 -734
  78. package/dist/agents/test-agents.d.ts +0 -7
  79. package/dist/agents/test-agents.js +0 -64
  80. package/dist/agents/ui-builder.agent.d.ts +0 -50
  81. package/dist/agents/ui-builder.agent.js +0 -1539
  82. package/dist/agents/widget-builder.agent.d.ts +0 -32
  83. package/dist/agents/widget-builder.agent.js +0 -439
  84. package/dist/agents/widget-creator-agent.d.ts +0 -18
  85. package/dist/agents/widget-creator-agent.js +0 -498
  86. package/dist/agents/workflow-designer.agent.d.ts +0 -31
  87. package/dist/agents/workflow-designer.agent.js +0 -583
  88. package/dist/api/error-handling.d.ts +0 -325
  89. package/dist/api/error-handling.js +0 -1488
  90. package/dist/api/flow-designer-api.d.ts +0 -167
  91. package/dist/api/flow-designer-api.js +0 -554
  92. package/dist/api/natural-language-mapper.d.ts +0 -124
  93. package/dist/api/natural-language-mapper.js +0 -501
  94. package/dist/api/performance-optimizer.d.ts +0 -240
  95. package/dist/api/performance-optimizer.js +0 -706
  96. package/dist/api/transaction-manager.d.ts +0 -189
  97. package/dist/api/transaction-manager.js +0 -576
  98. package/dist/assembly/team-assembler.d.ts +0 -140
  99. package/dist/assembly/team-assembler.js +0 -502
  100. package/dist/benchmark-performance.d.ts +0 -41
  101. package/dist/benchmark-performance.js +0 -230
  102. package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
  103. package/dist/cli/snow-flow-cli-integration.js +0 -396
  104. package/dist/coordination/coordination-engine.d.ts +0 -41
  105. package/dist/coordination/coordination-engine.js +0 -324
  106. package/dist/coordination/coordination.test.d.ts +0 -6
  107. package/dist/coordination/example.d.ts +0 -31
  108. package/dist/coordination/example.js +0 -394
  109. package/dist/coordination/execution-patterns.d.ts +0 -43
  110. package/dist/coordination/execution-patterns.js +0 -507
  111. package/dist/coordination/factory.d.ts +0 -94
  112. package/dist/coordination/factory.js +0 -433
  113. package/dist/coordination/index.d.ts +0 -71
  114. package/dist/coordination/index.js +0 -135
  115. package/dist/coordination/progress-monitor.d.ts +0 -71
  116. package/dist/coordination/progress-monitor.js +0 -505
  117. package/dist/coordination/quality-gates.d.ts +0 -124
  118. package/dist/coordination/quality-gates.js +0 -577
  119. package/dist/coordination/shared-memory.d.ts +0 -39
  120. package/dist/coordination/shared-memory.js +0 -289
  121. package/dist/coordination/task-dependencies.d.ts +0 -50
  122. package/dist/coordination/task-dependencies.js +0 -407
  123. package/dist/coordination/team-coordinator.d.ts +0 -59
  124. package/dist/coordination/team-coordinator.js +0 -550
  125. package/dist/coordination/types.d.ts +0 -152
  126. package/dist/coordination/types.js +0 -3
  127. package/dist/mcp/mcp-wrapper.d.ts +0 -8
  128. package/dist/mcp/mcp-wrapper.js +0 -77
  129. package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
  130. package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
  131. package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
  132. package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
  133. package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
  134. package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
  135. package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
  136. package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
  137. package/dist/mcp/singleton-check.js +0 -31
  138. package/dist/mcp/test-simple-mcp.d.ts +0 -6
  139. package/dist/mcp/test-simple-mcp.js +0 -63
  140. package/dist/memory/hierarchical-memory-system.d.ts +0 -90
  141. package/dist/memory/hierarchical-memory-system.js +0 -400
  142. package/dist/memory/index.d.ts +0 -9
  143. package/dist/memory/index.js +0 -20
  144. package/dist/memory/mcp-integration-example.d.ts +0 -6
  145. package/dist/memory/mcp-integration-example.js +0 -281
  146. package/dist/memory/memory-client.d.ts +0 -199
  147. package/dist/memory/memory-client.js +0 -364
  148. package/dist/memory/memory-manager.d.ts +0 -29
  149. package/dist/memory/memory-manager.js +0 -280
  150. package/dist/memory/memory-operations.d.ts +0 -179
  151. package/dist/memory/memory-operations.js +0 -691
  152. package/dist/memory/memory-system.d.ts +0 -153
  153. package/dist/memory/memory-system.js +0 -651
  154. package/dist/memory/memory-test.d.ts +0 -6
  155. package/dist/memory/memory-test.js +0 -161
  156. package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
  157. package/dist/memory/snow-flow-memory-patterns.js +0 -200
  158. package/dist/memory/snow-memory.d.ts +0 -54
  159. package/dist/memory/snow-memory.js +0 -301
  160. package/dist/memory/swarm-memory.d.ts +0 -135
  161. package/dist/memory/swarm-memory.js +0 -378
  162. package/dist/optimization/flow-performance-optimizer.js +0 -723
  163. package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
  164. package/dist/orchestration/discovery/service-discovery.js +0 -808
  165. package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
  166. package/dist/orchestration/distributed-orchestrator.js +0 -712
  167. package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
  168. package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
  169. package/dist/orchestration/flow-update-orchestrator.js +0 -648
  170. package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
  171. package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
  172. package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
  173. package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
  174. package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
  175. package/dist/orchestration/state/distributed-state-manager.js +0 -716
  176. package/dist/orchestrator/flow-composer.d.ts +0 -105
  177. package/dist/orchestrator/flow-composer.js +0 -404
  178. package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
  179. package/dist/orchestrator/flow-pattern-templates.js +0 -908
  180. package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
  181. package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
  182. package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
  183. package/dist/orchestrator/flow-validation-engine.js +0 -913
  184. package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
  185. package/dist/orchestrator/snow-orchestrator.js +0 -235
  186. package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
  187. package/dist/orchestrator/subflow-creation-handler.js +0 -791
  188. package/dist/patterns/adaptive-patterns.d.ts +0 -140
  189. package/dist/patterns/adaptive-patterns.js +0 -549
  190. package/dist/queen/advanced-integration-test.d.ts +0 -48
  191. package/dist/queen/advanced-integration-test.js +0 -473
  192. package/dist/queen/integration-example.d.ts +0 -82
  193. package/dist/queen/integration-example.js +0 -219
  194. package/dist/queen/integration-test.d.ts +0 -72
  195. package/dist/queen/integration-test.js +0 -563
  196. package/dist/queen/mock-mcp-client.d.ts +0 -71
  197. package/dist/queen/mock-mcp-client.js +0 -317
  198. package/dist/queen/run-integration-tests.d.ts +0 -9
  199. package/dist/queen/run-integration-tests.js +0 -27
  200. package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
  201. package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
  202. package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
  203. package/dist/sparc/coordinators/team-coordinator.js +0 -402
  204. package/dist/sparc/modes/team-modes.d.ts +0 -33
  205. package/dist/sparc/modes/team-modes.js +0 -399
  206. package/dist/sparc/teams/application-team.d.ts +0 -73
  207. package/dist/sparc/teams/application-team.js +0 -463
  208. package/dist/sparc/teams/flow-team.d.ts +0 -67
  209. package/dist/sparc/teams/flow-team.js +0 -373
  210. package/dist/sparc/teams/widget-team.d.ts +0 -61
  211. package/dist/sparc/teams/widget-team.js +0 -280
  212. package/dist/specialists/app-specialists.d.ts +0 -93
  213. package/dist/specialists/app-specialists.js +0 -1639
  214. package/dist/specialists/base-specialist.d.ts +0 -19
  215. package/dist/specialists/base-specialist.js +0 -54
  216. package/dist/specialists/flow-specialists.d.ts +0 -113
  217. package/dist/specialists/flow-specialists.js +0 -1787
  218. package/dist/specialists/individual-specialists.d.ts +0 -67
  219. package/dist/specialists/individual-specialists.js +0 -632
  220. package/dist/specialists/widget-specialists.d.ts +0 -70
  221. package/dist/specialists/widget-specialists.js +0 -1264
  222. package/dist/src/utils/agent-detector.js +0 -655
  223. package/dist/teams/adaptive-team.d.ts +0 -81
  224. package/dist/teams/adaptive-team.js +0 -1153
  225. package/dist/teams/application-team.d.ts +0 -30
  226. package/dist/teams/application-team.js +0 -547
  227. package/dist/teams/base-team.d.ts +0 -55
  228. package/dist/teams/base-team.js +0 -243
  229. package/dist/teams/flow-team.d.ts +0 -28
  230. package/dist/teams/flow-team.js +0 -525
  231. package/dist/teams/widget-team.d.ts +0 -26
  232. package/dist/teams/widget-team.js +0 -459
  233. package/dist/templates/flow-template-system.js +0 -625
  234. package/dist/test-fetch-incidents.d.ts +0 -2
  235. package/dist/test-fetch-incidents.js +0 -84
  236. package/dist/test-incident-access.d.ts +0 -2
  237. package/dist/test-incident-access.js +0 -72
  238. package/dist/test-iphone-flow.js +0 -189
  239. package/dist/test-limit-problem.d.ts +0 -2
  240. package/dist/test-limit-problem.js +0 -60
  241. package/dist/test-ml-batch-fix.d.ts +0 -2
  242. package/dist/test-ml-batch-fix.js +0 -104
  243. package/dist/test-ml-batch.d.ts +0 -2
  244. package/dist/test-ml-batch.js +0 -87
  245. package/dist/test-ml-query.d.ts +0 -2
  246. package/dist/test-ml-query.js +0 -100
  247. package/dist/test-ml-training-fix.d.ts +0 -12
  248. package/dist/test-ml-training-fix.js +0 -113
  249. package/dist/test-ml-training.d.ts +0 -2
  250. package/dist/test-ml-training.js +0 -32
  251. package/dist/test-operations-query.d.ts +0 -2
  252. package/dist/test-operations-query.js +0 -84
  253. package/dist/test-performance-query.d.ts +0 -2
  254. package/dist/test-performance-query.js +0 -52
  255. package/dist/test-singleton-protection.d.ts +0 -8
  256. package/dist/test-singleton-protection.js +0 -110
  257. package/dist/test-smart-limits.d.ts +0 -13
  258. package/dist/test-smart-limits.js +0 -100
  259. package/dist/test-snow-query-incidents.d.ts +0 -2
  260. package/dist/test-snow-query-incidents.js +0 -66
  261. package/dist/test-universal-query.d.ts +0 -2
  262. package/dist/test-universal-query.js +0 -106
  263. package/dist/testing/flow-testing-automation.js +0 -641
  264. package/dist/utils/complete-flow-xml-generator.js +0 -1285
  265. package/dist/utils/file-storage-fallback.d.ts +0 -62
  266. package/dist/utils/file-storage-fallback.js +0 -289
  267. package/dist/utils/flow-api-discovery.d.ts +0 -151
  268. package/dist/utils/flow-api-discovery.js +0 -439
  269. package/dist/utils/flow-examples.js +0 -720
  270. package/dist/utils/flow-structure-builder.js +0 -677
  271. package/dist/utils/flow-xml-generator.d.ts +0 -41
  272. package/dist/utils/flow-xml-generator.js +0 -258
  273. package/dist/utils/improved-flow-xml-generator.js +0 -820
  274. package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
  275. package/dist/utils/mcp-process-manager.backup.js +0 -220
  276. package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
  277. package/dist/utils/mcp-singleton-enforcer.js +0 -201
  278. package/dist/utils/mcp-timeout-fix.d.ts +0 -53
  279. package/dist/utils/mcp-timeout-fix.js +0 -221
  280. package/dist/utils/migrate-claude-flow.d.ts +0 -22
  281. package/dist/utils/migrate-claude-flow.js +0 -120
  282. package/dist/utils/scope-utils.d.ts +0 -72
  283. package/dist/utils/scope-utils.js +0 -386
  284. package/dist/utils/snow-oauth-old.d.ts +0 -65
  285. package/dist/utils/snow-oauth-old.js +0 -345
  286. package/dist/utils/xml-first-flow-generator.js +0 -513
  287. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
  288. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
  289. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
  290. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
  291. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
  292. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
  293. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
  294. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
  295. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
  296. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
  297. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
  298. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
  299. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
  300. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
  301. package/reports/swarm-auto-centralized-1752649029776.json +0 -13
  302. package/src/memory/README.md +0 -240
@@ -1,791 +0,0 @@
1
- "use strict";
2
- /**
3
- * ServiceNow Subflow Creation Handler
4
- *
5
- * This module handles the creation of subflows with proper input/output management,
6
- * validation, and integration with the main flow composer.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.SubflowCreationHandler = void 0;
10
- const logger_js_1 = require("../utils/logger.js");
11
- const servicenow_client_js_1 = require("../utils/servicenow-client.js");
12
- const flow_subflow_decision_engine_js_1 = require("./flow-subflow-decision-engine.js");
13
- /**
14
- * Subflow Creation Handler
15
- */
16
- class SubflowCreationHandler {
17
- constructor() {
18
- this.templates = new Map();
19
- this.logger = new logger_js_1.Logger('SubflowCreationHandler');
20
- this.client = new servicenow_client_js_1.ServiceNowClient();
21
- this.initializeTemplates();
22
- }
23
- /**
24
- * Create a subflow from a candidate
25
- */
26
- async createSubflow(candidate) {
27
- this.logger.info('Creating subflow from candidate', { name: candidate.name });
28
- try {
29
- // Validate the candidate
30
- const validationResult = this.validateCandidate(candidate);
31
- if (!validationResult.isValid) {
32
- return {
33
- success: false,
34
- validationErrors: validationResult.errors
35
- };
36
- }
37
- // Build the subflow definition
38
- const subflowDef = this.buildSubflowDefinition(candidate);
39
- // Validate the complete definition
40
- const defValidation = this.validateSubflowDefinition(subflowDef);
41
- if (!defValidation.isValid) {
42
- return {
43
- success: false,
44
- validationErrors: defValidation.errors
45
- };
46
- }
47
- // Deploy to ServiceNow
48
- const deployResult = await this.deploySubflow(subflowDef);
49
- if (!deployResult.success) {
50
- return {
51
- success: false,
52
- validationErrors: [deployResult.error || 'Deployment failed']
53
- };
54
- }
55
- // Generate recommendations
56
- const recommendations = this.generateRecommendations(subflowDef);
57
- return {
58
- success: true,
59
- subflow: subflowDef,
60
- sys_id: deployResult.sys_id,
61
- url: deployResult.url,
62
- warnings: defValidation.warnings,
63
- recommendations
64
- };
65
- }
66
- catch (error) {
67
- this.logger.error('Failed to create subflow', error);
68
- return {
69
- success: false,
70
- validationErrors: [error instanceof Error ? error.message : String(error)]
71
- };
72
- }
73
- }
74
- /**
75
- * Create multiple subflows from candidates
76
- */
77
- async createMultipleSubflows(candidates) {
78
- this.logger.info('Creating multiple subflows', { count: candidates.length });
79
- const results = [];
80
- for (const candidate of candidates) {
81
- const result = await this.createSubflow(candidate);
82
- results.push(result);
83
- // Add delay to avoid overwhelming ServiceNow
84
- await this.delay(500);
85
- }
86
- return results;
87
- }
88
- /**
89
- * Build subflow definition from candidate
90
- */
91
- buildSubflowDefinition(candidate) {
92
- const name = this.sanitizeName(candidate.name);
93
- const label = candidate.name;
94
- // Get template if available
95
- const template = this.findMatchingTemplate(candidate);
96
- return {
97
- name,
98
- label,
99
- description: candidate.description,
100
- category: this.determineCategory(candidate),
101
- inputs: this.buildInputDefinitions(candidate.inputs, template),
102
- outputs: this.buildOutputDefinitions(candidate.outputs, template),
103
- activities: this.buildActivities(candidate, template),
104
- connections: this.buildConnections(candidate, template),
105
- errorHandling: this.buildErrorHandling(candidate),
106
- metadata: {
107
- version: '1.0.0',
108
- author: 'ServiceNow Multi-Agent System',
109
- created: new Date(),
110
- updated: new Date(),
111
- tags: this.generateTags(candidate),
112
- complexity: candidate.complexity,
113
- reusability: candidate.reusability,
114
- testCoverage: 0,
115
- documentation: this.generateDocumentation(candidate),
116
- dependencies: [],
117
- compatibleVersions: ['Tokyo', 'Utah', 'Vancouver']
118
- }
119
- };
120
- }
121
- /**
122
- * Build input definitions with enhanced metadata
123
- */
124
- buildInputDefinitions(inputs, template) {
125
- return inputs.map((input, index) => {
126
- const baseInput = template?.baseInputs.find(base => base.name === input.name);
127
- return {
128
- ...input,
129
- label: this.generateInputLabel(input.name),
130
- category: this.categorizeInput(input),
131
- order: index + 1,
132
- tooltip: input.description,
133
- placeholder: this.generatePlaceholder(input),
134
- options: this.generateInputOptions(input),
135
- dependsOn: this.findInputDependencies(input, inputs),
136
- conditionalLogic: baseInput?.conditionalLogic
137
- };
138
- });
139
- }
140
- /**
141
- * Build output definitions with enhanced metadata
142
- */
143
- buildOutputDefinitions(outputs, template) {
144
- return outputs.map((output, index) => {
145
- const baseOutput = template?.baseOutputs.find(base => base.name === output.name);
146
- return {
147
- ...output,
148
- label: this.generateOutputLabel(output.name),
149
- category: this.categorizeOutput(output),
150
- order: index + 1,
151
- tooltip: output.description,
152
- format: this.generateOutputFormat(output),
153
- conditionalLogic: baseOutput?.conditionalLogic
154
- };
155
- });
156
- }
157
- /**
158
- * Build activities for the subflow
159
- */
160
- buildActivities(candidate, template) {
161
- const activities = [];
162
- // Add start activity
163
- activities.push({
164
- id: 'start',
165
- name: 'Start',
166
- type: 'start',
167
- label: 'Start',
168
- description: 'Subflow start point',
169
- inputs: {},
170
- outputs: {},
171
- position: { x: 100, y: 100 },
172
- configuration: {},
173
- errorHandling: []
174
- });
175
- // Add main processing activities based on actions
176
- candidate.actions.forEach((action, index) => {
177
- const activityId = `activity_${index + 1}`;
178
- const activity = this.createActivityFromAction(action, activityId, index);
179
- activities.push(activity);
180
- });
181
- // Add end activity
182
- activities.push({
183
- id: 'end',
184
- name: 'End',
185
- type: 'end',
186
- label: 'End',
187
- description: 'Subflow end point',
188
- inputs: {},
189
- outputs: this.buildEndOutputs(candidate.outputs),
190
- position: { x: 100 + (candidate.actions.length + 1) * 200, y: 100 },
191
- configuration: {},
192
- errorHandling: []
193
- });
194
- return activities;
195
- }
196
- /**
197
- * Build connections between activities
198
- */
199
- buildConnections(candidate, template) {
200
- const connections = [];
201
- // Sequential connections
202
- let previousId = 'start';
203
- candidate.actions.forEach((action, index) => {
204
- const currentId = `activity_${index + 1}`;
205
- connections.push({
206
- id: `connection_${index + 1}`,
207
- from: previousId,
208
- to: currentId,
209
- label: this.generateConnectionLabel(action)
210
- });
211
- previousId = currentId;
212
- });
213
- // Final connection to end
214
- connections.push({
215
- id: 'connection_end',
216
- from: previousId,
217
- to: 'end',
218
- label: 'Complete'
219
- });
220
- return connections;
221
- }
222
- /**
223
- * Build error handling for the subflow
224
- */
225
- buildErrorHandling(candidate) {
226
- const errorHandling = [];
227
- // Global error handler
228
- errorHandling.push({
229
- id: 'global_error',
230
- condition: 'any_activity_failed',
231
- action: 'stop',
232
- parameters: {
233
- message: `Error in ${candidate.name} subflow`,
234
- log_level: 'error'
235
- },
236
- description: 'Handle any unexpected errors'
237
- });
238
- // Specific error handlers based on complexity
239
- if (candidate.complexity === flow_subflow_decision_engine_js_1.ComplexityLevel.HIGH || candidate.complexity === flow_subflow_decision_engine_js_1.ComplexityLevel.VERY_HIGH) {
240
- errorHandling.push({
241
- id: 'retry_handler',
242
- condition: 'temporary_failure',
243
- action: 'retry',
244
- parameters: {
245
- max_retries: 3,
246
- delay_seconds: 5
247
- },
248
- description: 'Retry on temporary failures'
249
- });
250
- }
251
- return errorHandling;
252
- }
253
- /**
254
- * Create activity from action string
255
- */
256
- createActivityFromAction(action, activityId, index) {
257
- const activityType = this.mapActionToActivityType(action);
258
- return {
259
- id: activityId,
260
- name: this.generateActivityName(action),
261
- type: activityType,
262
- label: this.generateActivityLabel(action),
263
- description: this.generateActivityDescription(action),
264
- inputs: this.generateActivityInputs(action),
265
- outputs: this.generateActivityOutputs(action),
266
- position: { x: 100 + (index + 1) * 200, y: 100 },
267
- configuration: this.generateActivityConfiguration(action),
268
- errorHandling: this.generateActivityErrorHandling(action)
269
- };
270
- }
271
- /**
272
- * Validate candidate before processing
273
- */
274
- validateCandidate(candidate) {
275
- const errors = [];
276
- if (!candidate.name || candidate.name.trim() === '') {
277
- errors.push('Subflow name is required');
278
- }
279
- if (!candidate.description || candidate.description.trim() === '') {
280
- errors.push('Subflow description is required');
281
- }
282
- if (!candidate.actions || candidate.actions.length === 0) {
283
- errors.push('At least one action is required');
284
- }
285
- if (candidate.inputs.length === 0) {
286
- errors.push('At least one input parameter is required');
287
- }
288
- if (candidate.outputs.length === 0) {
289
- errors.push('At least one output parameter is required');
290
- }
291
- // Validate input parameters
292
- candidate.inputs.forEach((input, index) => {
293
- if (!input.name || input.name.trim() === '') {
294
- errors.push(`Input parameter ${index + 1} name is required`);
295
- }
296
- if (!input.type || input.type.trim() === '') {
297
- errors.push(`Input parameter ${index + 1} type is required`);
298
- }
299
- });
300
- // Validate output parameters
301
- candidate.outputs.forEach((output, index) => {
302
- if (!output.name || output.name.trim() === '') {
303
- errors.push(`Output parameter ${index + 1} name is required`);
304
- }
305
- if (!output.type || output.type.trim() === '') {
306
- errors.push(`Output parameter ${index + 1} type is required`);
307
- }
308
- });
309
- return { isValid: errors.length === 0, errors };
310
- }
311
- /**
312
- * Validate complete subflow definition
313
- */
314
- validateSubflowDefinition(definition) {
315
- const errors = [];
316
- const warnings = [];
317
- // Validate basic structure
318
- if (!definition.name || definition.name.trim() === '') {
319
- errors.push('Subflow name is required');
320
- }
321
- if (definition.activities.length < 3) { // start, at least one activity, end
322
- errors.push('Subflow must have at least one processing activity');
323
- }
324
- if (definition.connections.length < 2) { // start->activity, activity->end
325
- errors.push('Subflow must have proper connections');
326
- }
327
- // Validate connections
328
- const activityIds = new Set(definition.activities.map(a => a.id));
329
- definition.connections.forEach(conn => {
330
- if (!activityIds.has(conn.from)) {
331
- errors.push(`Connection references unknown activity: ${conn.from}`);
332
- }
333
- if (!activityIds.has(conn.to)) {
334
- errors.push(`Connection references unknown activity: ${conn.to}`);
335
- }
336
- });
337
- // Warnings for best practices
338
- if (definition.inputs.length > 10) {
339
- warnings.push('Subflow has many input parameters, consider grouping related parameters');
340
- }
341
- if (definition.outputs.length > 5) {
342
- warnings.push('Subflow has many output parameters, consider consolidating outputs');
343
- }
344
- if (definition.activities.length > 15) {
345
- warnings.push('Subflow is complex, consider breaking into smaller subflows');
346
- }
347
- return { isValid: errors.length === 0, errors, warnings };
348
- }
349
- /**
350
- * Deploy subflow to ServiceNow
351
- */
352
- async deploySubflow(definition) {
353
- try {
354
- // Convert to ServiceNow format
355
- const serviceNowFormat = this.convertToServiceNowFormat(definition);
356
- // Deploy via ServiceNow client (using createFlow for now until createSubflow is implemented)
357
- const result = await this.client.createFlow(serviceNowFormat);
358
- if (result.success) {
359
- return {
360
- success: true,
361
- sys_id: result.data.sys_id,
362
- url: `https://${process.env.SNOW_INSTANCE}/flow_designer.do#/subflow/${result.data.sys_id}`
363
- };
364
- }
365
- else {
366
- return {
367
- success: false,
368
- error: result.error || 'Unknown deployment error'
369
- };
370
- }
371
- }
372
- catch (error) {
373
- return {
374
- success: false,
375
- error: error instanceof Error ? error.message : String(error)
376
- };
377
- }
378
- }
379
- /**
380
- * Convert subflow definition to ServiceNow format
381
- */
382
- convertToServiceNowFormat(definition) {
383
- return {
384
- name: definition.name,
385
- label: definition.label,
386
- description: definition.description,
387
- category: definition.category,
388
- active: true,
389
- inputs: definition.inputs.map(input => ({
390
- name: input.name,
391
- label: input.label,
392
- type: input.type,
393
- mandatory: input.required,
394
- description: input.description,
395
- default_value: input.defaultValue,
396
- tooltip: input.tooltip,
397
- options: input.options,
398
- order: input.order
399
- })),
400
- outputs: definition.outputs.map(output => ({
401
- name: output.name,
402
- label: output.label,
403
- type: output.type,
404
- description: output.description,
405
- order: output.order
406
- })),
407
- activities: definition.activities.map(activity => ({
408
- id: activity.id,
409
- name: activity.name,
410
- type: activity.type,
411
- label: activity.label,
412
- description: activity.description,
413
- position: activity.position,
414
- inputs: activity.inputs,
415
- outputs: activity.outputs,
416
- configuration: activity.configuration
417
- })),
418
- connections: definition.connections.map(conn => ({
419
- id: conn.id,
420
- from: conn.from,
421
- to: conn.to,
422
- label: conn.label,
423
- condition: conn.condition
424
- }))
425
- };
426
- }
427
- /**
428
- * Generate recommendations for the subflow
429
- */
430
- generateRecommendations(definition) {
431
- const recommendations = [];
432
- // Input recommendations
433
- if (definition.inputs.length > 5) {
434
- recommendations.push('Consider grouping related input parameters into objects');
435
- }
436
- // Activity recommendations
437
- if (definition.activities.length > 10) {
438
- recommendations.push('Consider breaking this subflow into smaller, more focused subflows');
439
- }
440
- // Error handling recommendations
441
- if (definition.errorHandling.length === 0) {
442
- recommendations.push('Add error handling for better robustness');
443
- }
444
- // Documentation recommendations
445
- if (!definition.metadata.documentation || definition.metadata.documentation.length < 100) {
446
- recommendations.push('Add comprehensive documentation for better maintainability');
447
- }
448
- // Testing recommendations
449
- recommendations.push('Create test cases to verify subflow functionality');
450
- recommendations.push('Consider adding validation activities for input parameters');
451
- return recommendations;
452
- }
453
- /**
454
- * Initialize subflow templates
455
- */
456
- initializeTemplates() {
457
- // Approval template
458
- this.templates.set('approval', {
459
- name: 'Approval Process',
460
- description: 'Standard approval workflow template',
461
- category: 'Approval',
462
- complexity: flow_subflow_decision_engine_js_1.ComplexityLevel.MEDIUM,
463
- baseInputs: [
464
- {
465
- name: 'record',
466
- label: 'Record',
467
- type: 'reference',
468
- required: true,
469
- description: 'Record to approve',
470
- category: 'Data',
471
- order: 1
472
- },
473
- {
474
- name: 'approvers',
475
- label: 'Approvers',
476
- type: 'string',
477
- required: true,
478
- description: 'List of approvers',
479
- category: 'Configuration',
480
- order: 2
481
- }
482
- ],
483
- baseOutputs: [
484
- {
485
- name: 'approval_state',
486
- label: 'Approval State',
487
- type: 'string',
488
- description: 'Final approval state',
489
- category: 'Result',
490
- order: 1
491
- }
492
- ],
493
- baseActivities: [],
494
- baseConnections: [],
495
- customizationPoints: ['approval_logic', 'notification_template', 'timeout_handling']
496
- });
497
- // Notification template
498
- this.templates.set('notification', {
499
- name: 'Notification Sender',
500
- description: 'Multi-channel notification template',
501
- category: 'Communication',
502
- complexity: flow_subflow_decision_engine_js_1.ComplexityLevel.LOW,
503
- baseInputs: [
504
- {
505
- name: 'recipients',
506
- label: 'Recipients',
507
- type: 'string',
508
- required: true,
509
- description: 'Notification recipients',
510
- category: 'Configuration',
511
- order: 1
512
- },
513
- {
514
- name: 'message',
515
- label: 'Message',
516
- type: 'string',
517
- required: true,
518
- description: 'Notification message',
519
- category: 'Content',
520
- order: 2
521
- }
522
- ],
523
- baseOutputs: [
524
- {
525
- name: 'sent_successfully',
526
- label: 'Sent Successfully',
527
- type: 'boolean',
528
- description: 'Whether notification was sent',
529
- category: 'Result',
530
- order: 1
531
- }
532
- ],
533
- baseActivities: [],
534
- baseConnections: [],
535
- customizationPoints: ['message_template', 'delivery_method', 'retry_logic']
536
- });
537
- }
538
- // Helper methods
539
- sanitizeName(name) {
540
- return name.toLowerCase().replace(/[^a-z0-9_]/g, '_').replace(/^_+|_+$/g, '');
541
- }
542
- determineCategory(candidate) {
543
- if (candidate.name.toLowerCase().includes('approval'))
544
- return 'Approval';
545
- if (candidate.name.toLowerCase().includes('notification'))
546
- return 'Communication';
547
- if (candidate.name.toLowerCase().includes('data'))
548
- return 'Data Processing';
549
- if (candidate.name.toLowerCase().includes('integration'))
550
- return 'Integration';
551
- return 'Utility';
552
- }
553
- findMatchingTemplate(candidate) {
554
- const nameKey = candidate.name.toLowerCase();
555
- for (const [key, template] of this.templates) {
556
- if (nameKey.includes(key)) {
557
- return template;
558
- }
559
- }
560
- return undefined;
561
- }
562
- generateTags(candidate) {
563
- const tags = [];
564
- tags.push(candidate.complexity.toLowerCase());
565
- tags.push(candidate.reusability.toLowerCase());
566
- tags.push('auto-generated');
567
- return tags;
568
- }
569
- generateDocumentation(candidate) {
570
- return `
571
- # ${candidate.name}
572
-
573
- ## Description
574
- ${candidate.description}
575
-
576
- ## Reason for Creation
577
- ${candidate.reason}
578
-
579
- ## Complexity Level
580
- ${candidate.complexity}
581
-
582
- ## Reusability Level
583
- ${candidate.reusability}
584
-
585
- ## Actions
586
- ${candidate.actions.map(action => `- ${action}`).join('\n')}
587
-
588
- ## Usage
589
- This subflow can be used in any flow that requires ${candidate.name.toLowerCase()} functionality.
590
-
591
- ## Inputs
592
- ${candidate.inputs.map(input => `- **${input.name}** (${input.type}): ${input.description}`).join('\n')}
593
-
594
- ## Outputs
595
- ${candidate.outputs.map(output => `- **${output.name}** (${output.type}): ${output.description}`).join('\n')}
596
- `.trim();
597
- }
598
- generateInputLabel(name) {
599
- return name.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
600
- }
601
- generateOutputLabel(name) {
602
- return name.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
603
- }
604
- categorizeInput(input) {
605
- if (input.type === 'reference')
606
- return 'Data';
607
- if (input.name.includes('config') || input.name.includes('setting'))
608
- return 'Configuration';
609
- if (input.name.includes('message') || input.name.includes('content'))
610
- return 'Content';
611
- return 'General';
612
- }
613
- categorizeOutput(output) {
614
- if (output.name.includes('result') || output.name.includes('success'))
615
- return 'Result';
616
- if (output.name.includes('data') || output.name.includes('record'))
617
- return 'Data';
618
- if (output.name.includes('status') || output.name.includes('state'))
619
- return 'Status';
620
- return 'General';
621
- }
622
- generatePlaceholder(input) {
623
- switch (input.type) {
624
- case 'string': return `Enter ${input.name}`;
625
- case 'number': return '0';
626
- case 'boolean': return 'true';
627
- default: return '';
628
- }
629
- }
630
- generateInputOptions(input) {
631
- if (input.name.includes('priority')) {
632
- return ['1 - Critical', '2 - High', '3 - Medium', '4 - Low'];
633
- }
634
- if (input.name.includes('state')) {
635
- return ['New', 'In Progress', 'Completed', 'Cancelled'];
636
- }
637
- return undefined;
638
- }
639
- findInputDependencies(input, allInputs) {
640
- // Simple dependency detection based on naming patterns
641
- const dependencies = [];
642
- if (input.name.includes('_type') || input.name.includes('_method')) {
643
- const baseNames = allInputs.map(i => i.name).filter(name => name !== input.name && input.name.includes(name.split('_')[0]));
644
- dependencies.push(...baseNames);
645
- }
646
- return dependencies;
647
- }
648
- generateOutputFormat(output) {
649
- switch (output.type) {
650
- case 'string': return 'text';
651
- case 'number': return 'numeric';
652
- case 'boolean': return 'true/false';
653
- case 'object': return 'json';
654
- default: return 'text';
655
- }
656
- }
657
- buildEndOutputs(outputs) {
658
- const endOutputs = {};
659
- outputs.forEach(output => {
660
- endOutputs[output.name] = `\${subflow.${output.name}}`;
661
- });
662
- return endOutputs;
663
- }
664
- generateConnectionLabel(action) {
665
- return action.charAt(0).toUpperCase() + action.slice(1);
666
- }
667
- mapActionToActivityType(action) {
668
- const actionMap = {
669
- 'approve': 'approval',
670
- 'reject': 'approval',
671
- 'notify': 'notification',
672
- 'send': 'notification',
673
- 'create': 'create_record',
674
- 'update': 'update_record',
675
- 'delete': 'delete_record',
676
- 'validate': 'script',
677
- 'process': 'script',
678
- 'transform': 'script',
679
- 'integrate': 'rest',
680
- 'schedule': 'timer',
681
- 'assign': 'assignment',
682
- 'escalate': 'escalation',
683
- 'complete': 'script',
684
- 'cancel': 'script',
685
- 'retry': 'script',
686
- 'log': 'log',
687
- 'track': 'script',
688
- 'monitor': 'script'
689
- };
690
- return actionMap[action] || 'script';
691
- }
692
- generateActivityName(action) {
693
- return action.charAt(0).toUpperCase() + action.slice(1);
694
- }
695
- generateActivityLabel(action) {
696
- return action.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
697
- }
698
- generateActivityDescription(action) {
699
- return `Execute ${action} operation`;
700
- }
701
- generateActivityInputs(action) {
702
- const inputs = {};
703
- // Common inputs for all activities
704
- inputs.record = '${subflow.record}';
705
- // Action-specific inputs
706
- switch (action) {
707
- case 'approve':
708
- case 'reject':
709
- inputs.approvers = '${subflow.approvers}';
710
- break;
711
- case 'notify':
712
- case 'send':
713
- inputs.recipients = '${subflow.recipients}';
714
- inputs.message = '${subflow.message}';
715
- break;
716
- case 'create':
717
- case 'update':
718
- inputs.table = '${subflow.table}';
719
- inputs.data = '${subflow.data}';
720
- break;
721
- }
722
- return inputs;
723
- }
724
- generateActivityOutputs(action) {
725
- const outputs = {};
726
- // Common outputs
727
- outputs.success = '${step.success}';
728
- // Action-specific outputs
729
- switch (action) {
730
- case 'approve':
731
- case 'reject':
732
- outputs.approval_state = '${step.approval_state}';
733
- outputs.approved_by = '${step.approved_by}';
734
- break;
735
- case 'notify':
736
- case 'send':
737
- outputs.notification_sent = '${step.notification_sent}';
738
- break;
739
- case 'create':
740
- outputs.created_record = '${step.created_record}';
741
- break;
742
- case 'update':
743
- outputs.updated_record = '${step.updated_record}';
744
- break;
745
- }
746
- return outputs;
747
- }
748
- generateActivityConfiguration(action) {
749
- const config = {};
750
- switch (action) {
751
- case 'approve':
752
- config.approval_type = 'sequential';
753
- config.timeout = '24 hours';
754
- break;
755
- case 'notify':
756
- config.notification_type = 'email';
757
- break;
758
- case 'create':
759
- config.insert_mode = 'single';
760
- break;
761
- }
762
- return config;
763
- }
764
- generateActivityErrorHandling(action) {
765
- const errorHandling = [];
766
- // Common error handling
767
- errorHandling.push({
768
- condition: 'step.success === false',
769
- action: 'stop',
770
- parameters: {
771
- message: `Failed to execute ${action}`
772
- }
773
- });
774
- // Action-specific error handling
775
- if (action === 'approve') {
776
- errorHandling.push({
777
- condition: 'step.timeout === true',
778
- action: 'escalate',
779
- parameters: {
780
- escalation_group: 'managers'
781
- }
782
- });
783
- }
784
- return errorHandling;
785
- }
786
- delay(ms) {
787
- return new Promise(resolve => setTimeout(resolve, ms));
788
- }
789
- }
790
- exports.SubflowCreationHandler = SubflowCreationHandler;
791
- //# sourceMappingURL=subflow-creation-handler.js.map