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,140 +0,0 @@
1
- /**
2
- * Adaptive Coordination Patterns - Different execution strategies for dynamic teams
3
- */
4
- import { BaseSnowAgent } from '../agents/base/base-snow-agent.js';
5
- export interface AdaptiveTeam {
6
- id: string;
7
- specialists: Map<string, BaseSnowAgent>;
8
- coordinator: any;
9
- taskAnalysis: any;
10
- executionPlan: ExecutionPlan;
11
- createdAt: Date;
12
- }
13
- export interface ExecutionPlan {
14
- strategy: 'sequential' | 'parallel' | 'hybrid';
15
- steps: ExecutionStep[];
16
- parallelTasks: ParallelTask[];
17
- dependencies: TaskDependency[];
18
- estimatedDuration: number;
19
- }
20
- export interface ExecutionStep {
21
- id: string;
22
- agent: string;
23
- task: any;
24
- dependencies: string[];
25
- estimatedTime: number;
26
- retryPolicy?: RetryPolicy;
27
- }
28
- export interface ParallelTask {
29
- id: string;
30
- agent: string;
31
- task: any;
32
- canRunInParallel: boolean;
33
- priority?: 'low' | 'medium' | 'high';
34
- }
35
- export interface TaskDependency {
36
- prerequisite: string;
37
- dependent: string;
38
- type: 'data' | 'completion' | 'approval';
39
- transferData?: boolean;
40
- }
41
- export interface RetryPolicy {
42
- maxRetries: number;
43
- baseDelay: number;
44
- backoffMultiplier: number;
45
- maxDelay: number;
46
- }
47
- export interface ExecutionResult {
48
- success: boolean;
49
- results: Map<string, any>;
50
- errors: Map<string, Error>;
51
- executionTime: number;
52
- totalSteps: number;
53
- completedSteps: number;
54
- failedSteps: number;
55
- metadata: Record<string, any>;
56
- }
57
- export interface CoordinationContext {
58
- sharedData: Map<string, any>;
59
- executionState: Map<string, ExecutionStepState>;
60
- errorHandling: ErrorHandlingConfig;
61
- monitoring: MonitoringConfig;
62
- }
63
- export interface ExecutionStepState {
64
- status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
65
- startTime?: Date;
66
- endTime?: Date;
67
- result?: any;
68
- error?: Error;
69
- retryCount: number;
70
- }
71
- export interface ErrorHandlingConfig {
72
- strategy: 'fail_fast' | 'continue_on_error' | 'retry_failed';
73
- maxRetries: number;
74
- escalationPath: string[];
75
- notificationChannels: string[];
76
- }
77
- export interface MonitoringConfig {
78
- trackProgress: boolean;
79
- logLevel: 'minimal' | 'detailed' | 'debug';
80
- metricsCollection: boolean;
81
- realTimeUpdates: boolean;
82
- }
83
- export declare class AdaptivePatterns {
84
- private logger;
85
- private activeExecutions;
86
- constructor();
87
- /**
88
- * Execute tasks sequentially with dependency management
89
- */
90
- executeSequentialPattern(team: AdaptiveTeam, plan: ExecutionPlan): Promise<ExecutionResult>;
91
- /**
92
- * Execute tasks in parallel where possible
93
- */
94
- executeParallelPattern(team: AdaptiveTeam, plan: ExecutionPlan): Promise<ExecutionResult>;
95
- /**
96
- * Execute hybrid pattern - combination of sequential and parallel
97
- */
98
- executeHybridPattern(team: AdaptiveTeam, plan: ExecutionPlan): Promise<ExecutionResult>;
99
- /**
100
- * Initialize coordination context
101
- */
102
- private initializeContext;
103
- /**
104
- * Topological sort for dependency resolution
105
- */
106
- private topologicalSort;
107
- /**
108
- * Check if step dependencies are satisfied
109
- */
110
- private areDependenciesSatisfied;
111
- /**
112
- * Prepare input data for step execution
113
- */
114
- private prepareInputData;
115
- /**
116
- * Execute step with retry logic
117
- */
118
- private executeStepWithRetry;
119
- /**
120
- * Update step execution state
121
- */
122
- private updateStepState;
123
- /**
124
- * Group parallel tasks by priority
125
- */
126
- private groupTasksByPriority;
127
- /**
128
- * Serialize context for result metadata
129
- */
130
- private serializeContext;
131
- /**
132
- * Cleanup context resources
133
- */
134
- private cleanupContext;
135
- /**
136
- * Get current execution status for monitoring
137
- */
138
- getExecutionStatus(teamId: string): any;
139
- }
140
- //# sourceMappingURL=adaptive-patterns.d.ts.map
@@ -1,549 +0,0 @@
1
- "use strict";
2
- /**
3
- * Adaptive Coordination Patterns - Different execution strategies for dynamic teams
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AdaptivePatterns = void 0;
7
- const logger_js_1 = require("../utils/logger.js");
8
- class AdaptivePatterns {
9
- constructor() {
10
- this.activeExecutions = new Map();
11
- this.logger = new logger_js_1.Logger('AdaptivePatterns');
12
- }
13
- /**
14
- * Execute tasks sequentially with dependency management
15
- */
16
- async executeSequentialPattern(team, plan) {
17
- this.logger.info('Executing sequential pattern', {
18
- teamId: team.id,
19
- stepCount: plan.steps.length
20
- });
21
- const startTime = Date.now();
22
- const context = this.initializeContext(team, plan);
23
- const results = new Map();
24
- const errors = new Map();
25
- let completedSteps = 0;
26
- let failedSteps = 0;
27
- try {
28
- // Execute steps in order, respecting dependencies
29
- const sortedSteps = this.topologicalSort(plan.steps, plan.dependencies);
30
- for (const step of sortedSteps) {
31
- try {
32
- // Check if dependencies are satisfied
33
- if (!this.areDependenciesSatisfied(step, context)) {
34
- throw new Error(`Dependencies not satisfied for step ${step.id}`);
35
- }
36
- // Update step state
37
- this.updateStepState(context, step.id, 'running');
38
- // Execute the step
39
- const specialist = team.specialists.get(step.agent);
40
- if (!specialist) {
41
- throw new Error(`Specialist ${step.agent} not found in team`);
42
- }
43
- // Prepare input data from previous steps and shared context
44
- const inputData = this.prepareInputData(step, context);
45
- this.logger.info('Executing step', {
46
- stepId: step.id,
47
- agent: step.agent,
48
- dependencies: step.dependencies
49
- });
50
- const stepResult = await this.executeStepWithRetry(specialist, step, inputData);
51
- // Store results and update context
52
- results.set(step.id, stepResult);
53
- context.sharedData.set(step.id, stepResult);
54
- this.updateStepState(context, step.id, 'completed', stepResult);
55
- completedSteps++;
56
- this.logger.info('Step completed successfully', { stepId: step.id });
57
- }
58
- catch (error) {
59
- failedSteps++;
60
- const stepError = error;
61
- errors.set(step.id, stepError);
62
- this.updateStepState(context, step.id, 'failed', undefined, stepError);
63
- this.logger.error('Step execution failed', {
64
- stepId: step.id,
65
- error: stepError.message
66
- });
67
- // Handle error based on strategy
68
- if (context.errorHandling.strategy === 'fail_fast') {
69
- throw stepError;
70
- }
71
- // For 'continue_on_error', we continue to next step
72
- }
73
- }
74
- const executionTime = Date.now() - startTime;
75
- return {
76
- success: failedSteps === 0,
77
- results,
78
- errors,
79
- executionTime,
80
- totalSteps: plan.steps.length,
81
- completedSteps,
82
- failedSteps,
83
- metadata: {
84
- strategy: 'sequential',
85
- teamId: team.id,
86
- context: this.serializeContext(context)
87
- }
88
- };
89
- }
90
- catch (error) {
91
- const executionTime = Date.now() - startTime;
92
- this.logger.error('Sequential execution failed', error);
93
- return {
94
- success: false,
95
- results,
96
- errors,
97
- executionTime,
98
- totalSteps: plan.steps.length,
99
- completedSteps,
100
- failedSteps,
101
- metadata: {
102
- strategy: 'sequential',
103
- teamId: team.id,
104
- fatalError: error.message
105
- }
106
- };
107
- }
108
- finally {
109
- this.cleanupContext(team.id);
110
- }
111
- }
112
- /**
113
- * Execute tasks in parallel where possible
114
- */
115
- async executeParallelPattern(team, plan) {
116
- this.logger.info('Executing parallel pattern', {
117
- teamId: team.id,
118
- parallelTaskCount: plan.parallelTasks.length
119
- });
120
- const startTime = Date.now();
121
- const context = this.initializeContext(team, plan);
122
- const results = new Map();
123
- const errors = new Map();
124
- try {
125
- // Group tasks by priority
126
- const taskGroups = this.groupTasksByPriority(plan.parallelTasks);
127
- let completedSteps = 0;
128
- let failedSteps = 0;
129
- // Execute each priority group in parallel
130
- for (const [priority, tasks] of taskGroups) {
131
- this.logger.info('Executing priority group', { priority, taskCount: tasks.length });
132
- const promises = tasks.map(async (task) => {
133
- try {
134
- const specialist = team.specialists.get(task.agent);
135
- if (!specialist) {
136
- throw new Error(`Specialist ${task.agent} not found`);
137
- }
138
- this.updateStepState(context, task.id, 'running');
139
- const inputData = this.prepareInputData(task, context);
140
- const result = await specialist.execute({
141
- id: task.id,
142
- type: 'custom',
143
- description: JSON.stringify(task.task),
144
- priority: 'medium',
145
- status: 'in_progress',
146
- assignedAgent: task.agent,
147
- dependencies: [],
148
- createdAt: new Date(),
149
- metadata: task.task
150
- }, inputData);
151
- results.set(task.id, result);
152
- context.sharedData.set(task.id, result);
153
- this.updateStepState(context, task.id, 'completed', result);
154
- return { taskId: task.id, success: true, result };
155
- }
156
- catch (error) {
157
- const taskError = error;
158
- errors.set(task.id, taskError);
159
- this.updateStepState(context, task.id, 'failed', undefined, taskError);
160
- return { taskId: task.id, success: false, error: taskError };
161
- }
162
- });
163
- // Wait for all tasks in this priority group to complete
164
- const groupResults = await Promise.allSettled(promises);
165
- groupResults.forEach((result, index) => {
166
- if (result.status === 'fulfilled') {
167
- if (result.value.success) {
168
- completedSteps++;
169
- }
170
- else {
171
- failedSteps++;
172
- }
173
- }
174
- else {
175
- failedSteps++;
176
- const taskId = tasks[index].id;
177
- errors.set(taskId, new Error(result.reason));
178
- }
179
- });
180
- // Check if we should continue based on error handling strategy
181
- if (failedSteps > 0 && context.errorHandling.strategy === 'fail_fast') {
182
- break;
183
- }
184
- }
185
- const executionTime = Date.now() - startTime;
186
- return {
187
- success: failedSteps === 0,
188
- results,
189
- errors,
190
- executionTime,
191
- totalSteps: plan.parallelTasks.length,
192
- completedSteps,
193
- failedSteps,
194
- metadata: {
195
- strategy: 'parallel',
196
- teamId: team.id,
197
- priorityGroups: taskGroups.size
198
- }
199
- };
200
- }
201
- catch (error) {
202
- const executionTime = Date.now() - startTime;
203
- this.logger.error('Parallel execution failed', error);
204
- return {
205
- success: false,
206
- results,
207
- errors,
208
- executionTime,
209
- totalSteps: plan.parallelTasks.length,
210
- completedSteps: 0,
211
- failedSteps: plan.parallelTasks.length,
212
- metadata: {
213
- strategy: 'parallel',
214
- teamId: team.id,
215
- fatalError: error.message
216
- }
217
- };
218
- }
219
- finally {
220
- this.cleanupContext(team.id);
221
- }
222
- }
223
- /**
224
- * Execute hybrid pattern - combination of sequential and parallel
225
- */
226
- async executeHybridPattern(team, plan) {
227
- this.logger.info('Executing hybrid pattern', {
228
- teamId: team.id,
229
- sequentialSteps: plan.steps.length,
230
- parallelTasks: plan.parallelTasks.length
231
- });
232
- const startTime = Date.now();
233
- const context = this.initializeContext(team, plan);
234
- const allResults = new Map();
235
- const allErrors = new Map();
236
- let totalCompleted = 0;
237
- let totalFailed = 0;
238
- try {
239
- // Phase 1: Execute sequential steps that have dependencies
240
- if (plan.steps.length > 0) {
241
- this.logger.info('Executing sequential phase');
242
- const sequentialResult = await this.executeSequentialPattern(team, {
243
- ...plan,
244
- parallelTasks: [] // Only sequential for this phase
245
- });
246
- // Merge results
247
- sequentialResult.results.forEach((value, key) => allResults.set(key, value));
248
- sequentialResult.errors.forEach((value, key) => allErrors.set(key, value));
249
- totalCompleted += sequentialResult.completedSteps;
250
- totalFailed += sequentialResult.failedSteps;
251
- // Check if we should continue
252
- if (!sequentialResult.success && context.errorHandling.strategy === 'fail_fast') {
253
- throw new Error('Sequential phase failed, aborting hybrid execution');
254
- }
255
- }
256
- // Phase 2: Execute parallel tasks that can run independently
257
- if (plan.parallelTasks.length > 0) {
258
- this.logger.info('Executing parallel phase');
259
- const parallelResult = await this.executeParallelPattern(team, {
260
- ...plan,
261
- steps: [] // Only parallel for this phase
262
- });
263
- // Merge results
264
- parallelResult.results.forEach((value, key) => allResults.set(key, value));
265
- parallelResult.errors.forEach((value, key) => allErrors.set(key, value));
266
- totalCompleted += parallelResult.completedSteps;
267
- totalFailed += parallelResult.failedSteps;
268
- }
269
- const executionTime = Date.now() - startTime;
270
- const totalSteps = plan.steps.length + plan.parallelTasks.length;
271
- return {
272
- success: totalFailed === 0,
273
- results: allResults,
274
- errors: allErrors,
275
- executionTime,
276
- totalSteps,
277
- completedSteps: totalCompleted,
278
- failedSteps: totalFailed,
279
- metadata: {
280
- strategy: 'hybrid',
281
- teamId: team.id,
282
- phases: ['sequential', 'parallel'],
283
- sequentialSteps: plan.steps.length,
284
- parallelTasks: plan.parallelTasks.length
285
- }
286
- };
287
- }
288
- catch (error) {
289
- const executionTime = Date.now() - startTime;
290
- this.logger.error('Hybrid execution failed', error);
291
- return {
292
- success: false,
293
- results: allResults,
294
- errors: allErrors,
295
- executionTime,
296
- totalSteps: plan.steps.length + plan.parallelTasks.length,
297
- completedSteps: totalCompleted,
298
- failedSteps: totalFailed,
299
- metadata: {
300
- strategy: 'hybrid',
301
- teamId: team.id,
302
- fatalError: error.message
303
- }
304
- };
305
- }
306
- finally {
307
- this.cleanupContext(team.id);
308
- }
309
- }
310
- /**
311
- * Initialize coordination context
312
- */
313
- initializeContext(team, plan) {
314
- const context = {
315
- sharedData: new Map(),
316
- executionState: new Map(),
317
- errorHandling: {
318
- strategy: 'continue_on_error',
319
- maxRetries: 3,
320
- escalationPath: ['team-lead', 'manager'],
321
- notificationChannels: ['email']
322
- },
323
- monitoring: {
324
- trackProgress: true,
325
- logLevel: 'detailed',
326
- metricsCollection: true,
327
- realTimeUpdates: true
328
- }
329
- };
330
- // Initialize step states
331
- plan.steps.forEach(step => {
332
- context.executionState.set(step.id, {
333
- status: 'pending',
334
- retryCount: 0
335
- });
336
- });
337
- plan.parallelTasks.forEach(task => {
338
- context.executionState.set(task.id, {
339
- status: 'pending',
340
- retryCount: 0
341
- });
342
- });
343
- this.activeExecutions.set(team.id, context);
344
- return context;
345
- }
346
- /**
347
- * Topological sort for dependency resolution
348
- */
349
- topologicalSort(steps, dependencies) {
350
- const graph = new Map();
351
- const inDegree = new Map();
352
- // Initialize graph
353
- steps.forEach(step => {
354
- graph.set(step.id, []);
355
- inDegree.set(step.id, 0);
356
- });
357
- // Build dependency graph
358
- dependencies.forEach(dep => {
359
- const prereqList = graph.get(dep.prerequisite) || [];
360
- prereqList.push(dep.dependent);
361
- graph.set(dep.prerequisite, prereqList);
362
- const currentDegree = inDegree.get(dep.dependent) || 0;
363
- inDegree.set(dep.dependent, currentDegree + 1);
364
- });
365
- // Topological sort using Kahn's algorithm
366
- const queue = [];
367
- const result = [];
368
- // Find nodes with no incoming edges
369
- inDegree.forEach((degree, stepId) => {
370
- if (degree === 0) {
371
- queue.push(stepId);
372
- }
373
- });
374
- while (queue.length > 0) {
375
- const currentId = queue.shift();
376
- const currentStep = steps.find(s => s.id === currentId);
377
- if (currentStep) {
378
- result.push(currentStep);
379
- }
380
- const neighbors = graph.get(currentId) || [];
381
- neighbors.forEach(neighborId => {
382
- const newDegree = (inDegree.get(neighborId) || 0) - 1;
383
- inDegree.set(neighborId, newDegree);
384
- if (newDegree === 0) {
385
- queue.push(neighborId);
386
- }
387
- });
388
- }
389
- return result;
390
- }
391
- /**
392
- * Check if step dependencies are satisfied
393
- */
394
- areDependenciesSatisfied(step, context) {
395
- return step.dependencies.every(depId => {
396
- const depState = context.executionState.get(depId);
397
- return depState && depState.status === 'completed';
398
- });
399
- }
400
- /**
401
- * Prepare input data for step execution
402
- */
403
- prepareInputData(step, context) {
404
- const inputData = {
405
- sharedContext: Object.fromEntries(context.sharedData),
406
- stepConfig: step.task
407
- };
408
- // Add dependency outputs if this is a sequential step
409
- if ('dependencies' in step) {
410
- step.dependencies.forEach(depId => {
411
- const depResult = context.sharedData.get(depId);
412
- if (depResult) {
413
- inputData[`${depId}_output`] = depResult;
414
- }
415
- });
416
- }
417
- return inputData;
418
- }
419
- /**
420
- * Execute step with retry logic
421
- */
422
- async executeStepWithRetry(specialist, step, inputData) {
423
- const retryPolicy = step.retryPolicy || {
424
- maxRetries: 3,
425
- baseDelay: 1000,
426
- backoffMultiplier: 2,
427
- maxDelay: 10000
428
- };
429
- let lastError = null;
430
- for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt++) {
431
- try {
432
- const result = await specialist.execute({
433
- id: step.id,
434
- type: 'custom',
435
- description: JSON.stringify(step.task),
436
- priority: 'medium',
437
- status: 'in_progress',
438
- assignedAgent: step.agent,
439
- dependencies: step.dependencies,
440
- createdAt: new Date(),
441
- metadata: step.task
442
- }, inputData);
443
- return result;
444
- }
445
- catch (error) {
446
- lastError = error;
447
- if (attempt < retryPolicy.maxRetries) {
448
- const delay = Math.min(retryPolicy.baseDelay * Math.pow(retryPolicy.backoffMultiplier, attempt), retryPolicy.maxDelay);
449
- this.logger.warn('Step execution failed, retrying', {
450
- stepId: step.id,
451
- attempt: attempt + 1,
452
- delay,
453
- error: lastError.message
454
- });
455
- await new Promise(resolve => setTimeout(resolve, delay));
456
- }
457
- }
458
- }
459
- throw lastError || new Error('Step execution failed after all retries');
460
- }
461
- /**
462
- * Update step execution state
463
- */
464
- updateStepState(context, stepId, status, result, error) {
465
- const currentState = context.executionState.get(stepId);
466
- if (currentState) {
467
- currentState.status = status;
468
- if (status === 'running') {
469
- currentState.startTime = new Date();
470
- }
471
- else if (status === 'completed' || status === 'failed') {
472
- currentState.endTime = new Date();
473
- currentState.result = result;
474
- currentState.error = error;
475
- }
476
- context.executionState.set(stepId, currentState);
477
- }
478
- }
479
- /**
480
- * Group parallel tasks by priority
481
- */
482
- groupTasksByPriority(tasks) {
483
- const groups = new Map();
484
- tasks.forEach(task => {
485
- const priority = task.priority || 'medium';
486
- const group = groups.get(priority) || [];
487
- group.push(task);
488
- groups.set(priority, group);
489
- });
490
- // Return in priority order: high, medium, low
491
- const orderedGroups = new Map();
492
- ['high', 'medium', 'low'].forEach(priority => {
493
- if (groups.has(priority)) {
494
- orderedGroups.set(priority, groups.get(priority));
495
- }
496
- });
497
- return orderedGroups;
498
- }
499
- /**
500
- * Serialize context for result metadata
501
- */
502
- serializeContext(context) {
503
- return {
504
- sharedDataKeys: Array.from(context.sharedData.keys()),
505
- executionStates: Object.fromEntries(Array.from(context.executionState.entries()).map(([key, state]) => [
506
- key,
507
- {
508
- status: state.status,
509
- retryCount: state.retryCount,
510
- hasResult: !!state.result,
511
- hasError: !!state.error
512
- }
513
- ])),
514
- errorHandling: context.errorHandling,
515
- monitoring: context.monitoring
516
- };
517
- }
518
- /**
519
- * Cleanup context resources
520
- */
521
- cleanupContext(teamId) {
522
- this.activeExecutions.delete(teamId);
523
- this.logger.info('Context cleaned up', { teamId });
524
- }
525
- /**
526
- * Get current execution status for monitoring
527
- */
528
- getExecutionStatus(teamId) {
529
- const context = this.activeExecutions.get(teamId);
530
- if (!context) {
531
- return null;
532
- }
533
- return {
534
- teamId,
535
- activeSteps: Array.from(context.executionState.entries())
536
- .filter(([_, state]) => state.status === 'running')
537
- .map(([id, _]) => id),
538
- completedSteps: Array.from(context.executionState.entries())
539
- .filter(([_, state]) => state.status === 'completed')
540
- .length,
541
- failedSteps: Array.from(context.executionState.entries())
542
- .filter(([_, state]) => state.status === 'failed')
543
- .length,
544
- sharedDataSize: context.sharedData.size
545
- };
546
- }
547
- }
548
- exports.AdaptivePatterns = AdaptivePatterns;
549
- //# sourceMappingURL=adaptive-patterns.js.map