snow-flow 3.0.8 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/claude-flow.bat +0 -0
  2. package/claude-flow.ps1 +0 -0
  3. package/dist/mcp/servicenow-automation-mcp.js +0 -0
  4. package/dist/mcp/servicenow-deployment-mcp.js +0 -0
  5. package/dist/mcp/servicenow-integration-mcp.js +0 -0
  6. package/dist/mcp/servicenow-mcp-server.js +0 -0
  7. package/dist/mcp/servicenow-operations-mcp.js +0 -0
  8. package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
  9. package/dist/mcp/servicenow-progressive-indexer.js +0 -0
  10. package/dist/mcp/servicenow-reporting-analytics-mcp.js +133 -19
  11. package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
  12. package/dist/mcp/servicenow-update-set-mcp.js +0 -0
  13. package/dist/mcp/start-all-mcp-servers.js +0 -0
  14. package/dist/mcp/start-servicenow-mcp.js +0 -0
  15. package/dist/utils/snow-oauth.js +53 -16
  16. package/memory/agents/README.md +1 -1
  17. package/memory/claude-flow-data.json +1 -1
  18. package/memory/sessions/README.md +1 -1
  19. package/package.json +2 -2
  20. package/.mcp.json +0 -22
  21. package/claude-flow.config.json +0 -20
  22. package/dist/agents/app-creator.agent.d.ts +0 -55
  23. package/dist/agents/app-creator.agent.js +0 -1292
  24. package/dist/agents/base/base-snow-agent.d.ts +0 -75
  25. package/dist/agents/base/base-snow-agent.js +0 -169
  26. package/dist/agents/base-snow-agent.d.ts +0 -63
  27. package/dist/agents/base-snow-agent.js +0 -296
  28. package/dist/agents/coordinator.d.ts +0 -200
  29. package/dist/agents/coordinator.js +0 -777
  30. package/dist/agents/flow-builder-agent.d.ts +0 -18
  31. package/dist/agents/flow-builder-agent.js +0 -197
  32. package/dist/agents/queen-403-handler.d.ts +0 -47
  33. package/dist/agents/queen-403-handler.js +0 -175
  34. package/dist/agents/queen-agent-example.d.ts +0 -23
  35. package/dist/agents/queen-agent-example.js +0 -240
  36. package/dist/agents/queen-agent.test.d.ts +0 -6
  37. package/dist/agents/script-generator.agent.d.ts +0 -32
  38. package/dist/agents/script-generator.agent.js +0 -772
  39. package/dist/agents/script-writer-agent.d.ts +0 -22
  40. package/dist/agents/script-writer-agent.js +0 -695
  41. package/dist/agents/security-agent.d.ts +0 -23
  42. package/dist/agents/security-agent.js +0 -619
  43. package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
  44. package/dist/agents/specialists/automation-specialist.agent.js +0 -204
  45. package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
  46. package/dist/agents/specialists/data-specialist.agent.js +0 -484
  47. package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
  48. package/dist/agents/specialists/integration-specialist.agent.js +0 -725
  49. package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
  50. package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
  51. package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
  52. package/dist/agents/specialists/security-specialist.agent.js +0 -309
  53. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
  54. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
  55. package/dist/agents/teams/base-team.d.ts +0 -72
  56. package/dist/agents/teams/base-team.js +0 -253
  57. package/dist/agents/teams/team-types.d.ts +0 -265
  58. package/dist/agents/teams/team-types.js +0 -3
  59. package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
  60. package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
  61. package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
  62. package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
  63. package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
  64. package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
  65. package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
  66. package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
  67. package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
  68. package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
  69. package/dist/agents/test-agent.d.ts +0 -26
  70. package/dist/agents/test-agent.js +0 -734
  71. package/dist/agents/test-agents.d.ts +0 -7
  72. package/dist/agents/test-agents.js +0 -64
  73. package/dist/agents/ui-builder.agent.d.ts +0 -50
  74. package/dist/agents/ui-builder.agent.js +0 -1539
  75. package/dist/agents/widget-builder.agent.d.ts +0 -32
  76. package/dist/agents/widget-builder.agent.js +0 -439
  77. package/dist/agents/widget-creator-agent.d.ts +0 -18
  78. package/dist/agents/widget-creator-agent.js +0 -498
  79. package/dist/agents/workflow-designer.agent.d.ts +0 -31
  80. package/dist/agents/workflow-designer.agent.js +0 -583
  81. package/dist/api/error-handling.d.ts +0 -325
  82. package/dist/api/error-handling.js +0 -1488
  83. package/dist/api/flow-designer-api.d.ts +0 -167
  84. package/dist/api/flow-designer-api.js +0 -554
  85. package/dist/api/natural-language-mapper.d.ts +0 -124
  86. package/dist/api/natural-language-mapper.js +0 -501
  87. package/dist/api/performance-optimizer.d.ts +0 -240
  88. package/dist/api/performance-optimizer.js +0 -706
  89. package/dist/api/transaction-manager.d.ts +0 -189
  90. package/dist/api/transaction-manager.js +0 -576
  91. package/dist/assembly/team-assembler.d.ts +0 -140
  92. package/dist/assembly/team-assembler.js +0 -502
  93. package/dist/benchmark-performance.d.ts +0 -41
  94. package/dist/benchmark-performance.js +0 -230
  95. package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
  96. package/dist/cli/snow-flow-cli-integration.js +0 -396
  97. package/dist/coordination/coordination-engine.d.ts +0 -41
  98. package/dist/coordination/coordination-engine.js +0 -324
  99. package/dist/coordination/coordination.test.d.ts +0 -6
  100. package/dist/coordination/example.d.ts +0 -31
  101. package/dist/coordination/example.js +0 -394
  102. package/dist/coordination/execution-patterns.d.ts +0 -43
  103. package/dist/coordination/execution-patterns.js +0 -507
  104. package/dist/coordination/factory.d.ts +0 -94
  105. package/dist/coordination/factory.js +0 -433
  106. package/dist/coordination/index.d.ts +0 -71
  107. package/dist/coordination/index.js +0 -135
  108. package/dist/coordination/progress-monitor.d.ts +0 -71
  109. package/dist/coordination/progress-monitor.js +0 -505
  110. package/dist/coordination/quality-gates.d.ts +0 -124
  111. package/dist/coordination/quality-gates.js +0 -577
  112. package/dist/coordination/shared-memory.d.ts +0 -39
  113. package/dist/coordination/shared-memory.js +0 -289
  114. package/dist/coordination/task-dependencies.d.ts +0 -50
  115. package/dist/coordination/task-dependencies.js +0 -407
  116. package/dist/coordination/team-coordinator.d.ts +0 -59
  117. package/dist/coordination/team-coordinator.js +0 -550
  118. package/dist/coordination/types.d.ts +0 -152
  119. package/dist/coordination/types.js +0 -3
  120. package/dist/mcp/mcp-wrapper.d.ts +0 -8
  121. package/dist/mcp/mcp-wrapper.js +0 -77
  122. package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
  123. package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
  124. package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
  125. package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
  126. package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
  127. package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
  128. package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
  129. package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
  130. package/dist/mcp/singleton-check.js +0 -31
  131. package/dist/mcp/test-simple-mcp.d.ts +0 -6
  132. package/dist/mcp/test-simple-mcp.js +0 -63
  133. package/dist/memory/hierarchical-memory-system.d.ts +0 -90
  134. package/dist/memory/hierarchical-memory-system.js +0 -400
  135. package/dist/memory/index.d.ts +0 -9
  136. package/dist/memory/index.js +0 -20
  137. package/dist/memory/mcp-integration-example.d.ts +0 -6
  138. package/dist/memory/mcp-integration-example.js +0 -281
  139. package/dist/memory/memory-client.d.ts +0 -199
  140. package/dist/memory/memory-client.js +0 -364
  141. package/dist/memory/memory-manager.d.ts +0 -29
  142. package/dist/memory/memory-manager.js +0 -280
  143. package/dist/memory/memory-operations.d.ts +0 -179
  144. package/dist/memory/memory-operations.js +0 -691
  145. package/dist/memory/memory-system.d.ts +0 -153
  146. package/dist/memory/memory-system.js +0 -651
  147. package/dist/memory/memory-test.d.ts +0 -6
  148. package/dist/memory/memory-test.js +0 -161
  149. package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
  150. package/dist/memory/snow-flow-memory-patterns.js +0 -200
  151. package/dist/memory/snow-memory.d.ts +0 -54
  152. package/dist/memory/snow-memory.js +0 -301
  153. package/dist/memory/swarm-memory.d.ts +0 -135
  154. package/dist/memory/swarm-memory.js +0 -378
  155. package/dist/optimization/flow-performance-optimizer.js +0 -723
  156. package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
  157. package/dist/orchestration/discovery/service-discovery.js +0 -808
  158. package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
  159. package/dist/orchestration/distributed-orchestrator.js +0 -712
  160. package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
  161. package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
  162. package/dist/orchestration/flow-update-orchestrator.js +0 -648
  163. package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
  164. package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
  165. package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
  166. package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
  167. package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
  168. package/dist/orchestration/state/distributed-state-manager.js +0 -716
  169. package/dist/orchestrator/flow-composer.d.ts +0 -105
  170. package/dist/orchestrator/flow-composer.js +0 -404
  171. package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
  172. package/dist/orchestrator/flow-pattern-templates.js +0 -908
  173. package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
  174. package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
  175. package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
  176. package/dist/orchestrator/flow-validation-engine.js +0 -913
  177. package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
  178. package/dist/orchestrator/snow-orchestrator.js +0 -235
  179. package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
  180. package/dist/orchestrator/subflow-creation-handler.js +0 -791
  181. package/dist/patterns/adaptive-patterns.d.ts +0 -140
  182. package/dist/patterns/adaptive-patterns.js +0 -549
  183. package/dist/queen/advanced-integration-test.d.ts +0 -48
  184. package/dist/queen/advanced-integration-test.js +0 -473
  185. package/dist/queen/integration-example.d.ts +0 -82
  186. package/dist/queen/integration-example.js +0 -219
  187. package/dist/queen/integration-test.d.ts +0 -72
  188. package/dist/queen/integration-test.js +0 -563
  189. package/dist/queen/mock-mcp-client.d.ts +0 -71
  190. package/dist/queen/mock-mcp-client.js +0 -317
  191. package/dist/queen/run-integration-tests.d.ts +0 -9
  192. package/dist/queen/run-integration-tests.js +0 -27
  193. package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
  194. package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
  195. package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
  196. package/dist/sparc/coordinators/team-coordinator.js +0 -402
  197. package/dist/sparc/modes/team-modes.d.ts +0 -33
  198. package/dist/sparc/modes/team-modes.js +0 -399
  199. package/dist/sparc/teams/application-team.d.ts +0 -73
  200. package/dist/sparc/teams/application-team.js +0 -463
  201. package/dist/sparc/teams/flow-team.d.ts +0 -67
  202. package/dist/sparc/teams/flow-team.js +0 -373
  203. package/dist/sparc/teams/widget-team.d.ts +0 -61
  204. package/dist/sparc/teams/widget-team.js +0 -280
  205. package/dist/specialists/app-specialists.d.ts +0 -93
  206. package/dist/specialists/app-specialists.js +0 -1639
  207. package/dist/specialists/base-specialist.d.ts +0 -19
  208. package/dist/specialists/base-specialist.js +0 -54
  209. package/dist/specialists/flow-specialists.d.ts +0 -113
  210. package/dist/specialists/flow-specialists.js +0 -1787
  211. package/dist/specialists/individual-specialists.d.ts +0 -67
  212. package/dist/specialists/individual-specialists.js +0 -632
  213. package/dist/specialists/widget-specialists.d.ts +0 -70
  214. package/dist/specialists/widget-specialists.js +0 -1264
  215. package/dist/src/utils/agent-detector.js +0 -655
  216. package/dist/teams/adaptive-team.d.ts +0 -81
  217. package/dist/teams/adaptive-team.js +0 -1153
  218. package/dist/teams/application-team.d.ts +0 -30
  219. package/dist/teams/application-team.js +0 -547
  220. package/dist/teams/base-team.d.ts +0 -55
  221. package/dist/teams/base-team.js +0 -243
  222. package/dist/teams/flow-team.d.ts +0 -28
  223. package/dist/teams/flow-team.js +0 -525
  224. package/dist/teams/widget-team.d.ts +0 -26
  225. package/dist/teams/widget-team.js +0 -459
  226. package/dist/templates/flow-template-system.js +0 -625
  227. package/dist/test-fetch-incidents.d.ts +0 -2
  228. package/dist/test-fetch-incidents.js +0 -84
  229. package/dist/test-incident-access.d.ts +0 -2
  230. package/dist/test-incident-access.js +0 -72
  231. package/dist/test-iphone-flow.js +0 -189
  232. package/dist/test-limit-problem.d.ts +0 -2
  233. package/dist/test-limit-problem.js +0 -60
  234. package/dist/test-ml-batch-fix.d.ts +0 -2
  235. package/dist/test-ml-batch-fix.js +0 -104
  236. package/dist/test-ml-batch.d.ts +0 -2
  237. package/dist/test-ml-batch.js +0 -87
  238. package/dist/test-ml-query.d.ts +0 -2
  239. package/dist/test-ml-query.js +0 -100
  240. package/dist/test-ml-training-fix.d.ts +0 -12
  241. package/dist/test-ml-training-fix.js +0 -113
  242. package/dist/test-ml-training.d.ts +0 -2
  243. package/dist/test-ml-training.js +0 -32
  244. package/dist/test-operations-query.d.ts +0 -2
  245. package/dist/test-operations-query.js +0 -84
  246. package/dist/test-performance-query.d.ts +0 -2
  247. package/dist/test-performance-query.js +0 -52
  248. package/dist/test-singleton-protection.d.ts +0 -8
  249. package/dist/test-singleton-protection.js +0 -110
  250. package/dist/test-smart-limits.d.ts +0 -13
  251. package/dist/test-smart-limits.js +0 -100
  252. package/dist/test-snow-query-incidents.d.ts +0 -2
  253. package/dist/test-snow-query-incidents.js +0 -66
  254. package/dist/test-universal-query.d.ts +0 -2
  255. package/dist/test-universal-query.js +0 -106
  256. package/dist/testing/flow-testing-automation.js +0 -641
  257. package/dist/utils/complete-flow-xml-generator.js +0 -1285
  258. package/dist/utils/file-storage-fallback.d.ts +0 -62
  259. package/dist/utils/file-storage-fallback.js +0 -289
  260. package/dist/utils/flow-api-discovery.d.ts +0 -151
  261. package/dist/utils/flow-api-discovery.js +0 -439
  262. package/dist/utils/flow-examples.js +0 -720
  263. package/dist/utils/flow-structure-builder.js +0 -677
  264. package/dist/utils/flow-xml-generator.d.ts +0 -41
  265. package/dist/utils/flow-xml-generator.js +0 -258
  266. package/dist/utils/improved-flow-xml-generator.js +0 -820
  267. package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
  268. package/dist/utils/mcp-process-manager.backup.js +0 -220
  269. package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
  270. package/dist/utils/mcp-singleton-enforcer.js +0 -201
  271. package/dist/utils/mcp-timeout-fix.d.ts +0 -53
  272. package/dist/utils/mcp-timeout-fix.js +0 -221
  273. package/dist/utils/migrate-claude-flow.d.ts +0 -22
  274. package/dist/utils/migrate-claude-flow.js +0 -120
  275. package/dist/utils/scope-utils.d.ts +0 -72
  276. package/dist/utils/scope-utils.js +0 -386
  277. package/dist/utils/snow-oauth-old.d.ts +0 -65
  278. package/dist/utils/snow-oauth-old.js +0 -345
  279. package/dist/utils/xml-first-flow-generator.js +0 -513
  280. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
  281. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
  282. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
  283. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
  284. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
  285. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
  286. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
  287. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
  288. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
  289. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
  290. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
  291. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
  292. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
  293. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
  294. package/reports/swarm-auto-centralized-1752649029776.json +0 -13
  295. package/src/memory/README.md +0 -240
@@ -1,53 +0,0 @@
1
- /**
2
- * Intelligent Task Distribution Engine
3
- *
4
- * Distributes tasks across external Claude Code instances using advanced algorithms
5
- * for optimal performance, load balancing, and resource utilization.
6
- */
7
- import { EventEmitter } from 'events';
8
- import { TaskSpecification, ClaudeCodeInstance, DistributionPlan, TaskRequirements } from '../interfaces/distributed-orchestration.interface.js';
9
- export declare class IntelligentTaskDistributor extends EventEmitter {
10
- private agentPool;
11
- private loadBalancers;
12
- private taskAnalyzer;
13
- private affinityManager;
14
- private performanceTracker;
15
- private costOptimizer;
16
- constructor();
17
- distributeTask(task: TaskSpecification): Promise<DistributionPlan>;
18
- findSuitableAgents(requirements: TaskRequirements): Promise<ClaudeCodeInstance[]>;
19
- private meetsCapabilityRequirements;
20
- private meetsResourceRequirements;
21
- private meetsConstraints;
22
- private isHealthy;
23
- private scoreAgent;
24
- private calculateCapabilityScore;
25
- private calculateCapabilityMatch;
26
- private calculatePerformanceScore;
27
- private calculateLoadScore;
28
- private calculateProximityScore;
29
- private calculateCostScore;
30
- private selectLoadBalancer;
31
- private createExecutionPlan;
32
- private identifyExecutionPhases;
33
- private generateFallbackPlan;
34
- private validateDistributionPlan;
35
- private initializeLoadBalancers;
36
- private stringSimilarity;
37
- private evaluateConstraint;
38
- private calculateReliabilityScore;
39
- private buildDependencyGraph;
40
- private topologicalSort;
41
- private calculateTotalDuration;
42
- private calculateParallelizationScore;
43
- private calculateResourceUsage;
44
- private validateResourceAllocation;
45
- private validateDeadlines;
46
- private validateCapabilities;
47
- private validateConstraints;
48
- }
49
- declare class TaskDistributionError extends Error {
50
- constructor(message: string);
51
- }
52
- export { TaskDistributionError };
53
- //# sourceMappingURL=task-distribution-engine.d.ts.map
@@ -1,586 +0,0 @@
1
- "use strict";
2
- /**
3
- * Intelligent Task Distribution Engine
4
- *
5
- * Distributes tasks across external Claude Code instances using advanced algorithms
6
- * for optimal performance, load balancing, and resource utilization.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TaskDistributionError = exports.IntelligentTaskDistributor = void 0;
10
- const events_1 = require("events");
11
- const distributed_orchestration_interface_js_1 = require("../interfaces/distributed-orchestration.interface.js");
12
- const logger_js_1 = require("../../utils/logger.js");
13
- class IntelligentTaskDistributor extends events_1.EventEmitter {
14
- constructor() {
15
- super();
16
- this.agentPool = new ExternalAgentPool();
17
- this.loadBalancers = this.initializeLoadBalancers();
18
- this.taskAnalyzer = new TaskAnalyzer();
19
- this.affinityManager = new AffinityManager();
20
- this.performanceTracker = new PerformanceTracker();
21
- this.costOptimizer = new CostOptimizer();
22
- }
23
- // ========================================
24
- // Main Distribution Logic
25
- // ========================================
26
- async distributeTask(task) {
27
- logger_js_1.logger.info(`🎯 Starting task distribution for: ${task.name}`, {
28
- taskId: task.id,
29
- type: task.type
30
- });
31
- try {
32
- // 1. Analyze task requirements and complexity
33
- const analysis = await this.taskAnalyzer.analyze(task);
34
- logger_js_1.logger.info(`📊 Task analysis completed`, {
35
- complexity: analysis.complexity,
36
- requiredCapabilities: analysis.requirements.capabilities.length,
37
- estimatedAgents: analysis.estimatedAgentCount
38
- });
39
- // 2. Find suitable agents based on capabilities
40
- const candidates = await this.findSuitableAgents(analysis.requirements);
41
- if (candidates.length === 0) {
42
- throw new TaskDistributionError(`No suitable agents found for task: ${task.id}`);
43
- }
44
- logger_js_1.logger.info(`🔍 Found ${candidates.length} suitable agents`);
45
- // 3. Apply load balancing to optimize distribution
46
- const loadBalancer = this.selectLoadBalancer(task, analysis);
47
- const loadBalancedAssignments = await loadBalancer.optimize(candidates, task);
48
- // 4. Apply affinity rules and constraints
49
- const affinityOptimized = await this.affinityManager.apply(loadBalancedAssignments, task.affinityRules || []);
50
- // 5. Optimize for cost if specified
51
- const costOptimized = await this.costOptimizer.optimize(affinityOptimized, task);
52
- // 6. Create execution plan with phases
53
- const executionPlan = await this.createExecutionPlan(costOptimized, analysis);
54
- // 7. Generate fallback plan
55
- const fallbackPlan = await this.generateFallbackPlan(task, candidates);
56
- const distributionPlan = {
57
- taskId: task.id,
58
- assignments: costOptimized,
59
- executionOrder: executionPlan.phases,
60
- estimated: {
61
- totalDuration: executionPlan.estimatedDuration,
62
- parallelization: executionPlan.parallelizationScore,
63
- resourceUsage: executionPlan.resourceUsage
64
- },
65
- fallbackPlan
66
- };
67
- // 8. Validate distribution plan
68
- await this.validateDistributionPlan(distributionPlan, task);
69
- logger_js_1.logger.info(`✅ Task distribution completed`, {
70
- taskId: task.id,
71
- assignments: distributionPlan.assignments.length,
72
- estimatedDuration: distributionPlan.estimated.totalDuration,
73
- parallelization: distributionPlan.estimated.parallelization
74
- });
75
- this.emit('task:distributed', { task, plan: distributionPlan });
76
- return distributionPlan;
77
- }
78
- catch (error) {
79
- logger_js_1.logger.error(`❌ Task distribution failed for: ${task.id}`, {
80
- error: error.message
81
- });
82
- this.emit('task:distribution_failed', { task, error });
83
- throw error;
84
- }
85
- }
86
- // ========================================
87
- // Agent Discovery and Matching
88
- // ========================================
89
- async findSuitableAgents(requirements) {
90
- const allAgents = await this.agentPool.getAvailableAgents();
91
- const suitableAgents = allAgents
92
- .filter(agent => this.meetsCapabilityRequirements(agent, requirements))
93
- .filter(agent => this.meetsResourceRequirements(agent, requirements))
94
- .filter(agent => this.meetsConstraints(agent, requirements))
95
- .filter(agent => this.isHealthy(agent));
96
- // Score and sort agents by suitability
97
- const scoredAgents = suitableAgents
98
- .map(agent => ({
99
- agent,
100
- score: this.scoreAgent(agent, requirements)
101
- }))
102
- .sort((a, b) => b.score - a.score)
103
- .map(item => item.agent);
104
- return scoredAgents;
105
- }
106
- meetsCapabilityRequirements(agent, requirements) {
107
- const agentCapabilities = agent.capabilities.flatMap(cap => cap.specialization);
108
- return requirements.capabilities.every(req => agentCapabilities.some(cap => cap.toLowerCase().includes(req.toLowerCase()) ||
109
- req.toLowerCase().includes(cap.toLowerCase())));
110
- }
111
- meetsResourceRequirements(agent, requirements) {
112
- for (const requirement of requirements.resources) {
113
- const agentResource = agent.capabilities.find(cap => cap.resourceRequirements.some(res => res.type === requirement.type));
114
- if (!agentResource && requirement.amount && requirement.amount > 0) {
115
- return false;
116
- }
117
- }
118
- return true;
119
- }
120
- meetsConstraints(agent, requirements) {
121
- for (const constraint of requirements.constraints) {
122
- if (!this.evaluateConstraint(agent, constraint)) {
123
- return false;
124
- }
125
- }
126
- return true;
127
- }
128
- isHealthy(agent) {
129
- return agent.status === distributed_orchestration_interface_js_1.InstanceStatus.ACTIVE || agent.status === distributed_orchestration_interface_js_1.InstanceStatus.IDLE;
130
- }
131
- // ========================================
132
- // Agent Scoring Algorithm
133
- // ========================================
134
- scoreAgent(agent, requirements) {
135
- let score = 0;
136
- // Capability match score (40% weight)
137
- const capabilityScore = this.calculateCapabilityScore(agent, requirements);
138
- score += capabilityScore * 0.4;
139
- // Performance score (25% weight)
140
- const performanceScore = this.calculatePerformanceScore(agent);
141
- score += performanceScore * 0.25;
142
- // Load score (20% weight) - inverse of current load
143
- const loadScore = this.calculateLoadScore(agent);
144
- score += loadScore * 0.2;
145
- // Geographic proximity score (10% weight)
146
- const proximityScore = this.calculateProximityScore(agent);
147
- score += proximityScore * 0.1;
148
- // Cost efficiency score (5% weight)
149
- const costScore = this.calculateCostScore(agent);
150
- score += costScore * 0.05;
151
- return Math.min(Math.max(score, 0), 1); // Normalize to 0-1
152
- }
153
- calculateCapabilityScore(agent, requirements) {
154
- const requiredCapabilities = requirements.capabilities;
155
- const agentCapabilities = agent.capabilities.flatMap(cap => cap.specialization);
156
- let matches = 0;
157
- for (const required of requiredCapabilities) {
158
- const bestMatch = agentCapabilities.find(agentCap => this.calculateCapabilityMatch(required, agentCap) > 0.7);
159
- if (bestMatch)
160
- matches++;
161
- }
162
- return requiredCapabilities.length > 0 ? matches / requiredCapabilities.length : 0;
163
- }
164
- calculateCapabilityMatch(required, available) {
165
- // Simple string similarity - in production, would use more sophisticated matching
166
- const similarity = this.stringSimilarity(required.toLowerCase(), available.toLowerCase());
167
- return similarity;
168
- }
169
- calculatePerformanceScore(agent) {
170
- const metrics = agent.metadata.performanceMetrics;
171
- // Normalize metrics to 0-1 scores
172
- const responseTimeScore = Math.max(0, 1 - (metrics.averageResponseTime / 10000)); // 10s max
173
- const throughputScore = Math.min(1, metrics.throughput / 100); // 100 tasks/hour max
174
- const errorRateScore = Math.max(0, 1 - (metrics.errorRate * 10)); // 10% max error rate
175
- const completionRateScore = metrics.taskCompletionRate;
176
- return (responseTimeScore + throughputScore + errorRateScore + completionRateScore) / 4;
177
- }
178
- calculateLoadScore(agent) {
179
- const currentTasks = this.performanceTracker.getCurrentTaskCount(agent.id);
180
- const maxTasks = agent.metadata.maxConcurrentTasks;
181
- return Math.max(0, 1 - (currentTasks / maxTasks));
182
- }
183
- calculateProximityScore(agent) {
184
- // Would calculate based on geographic distance, network latency, etc.
185
- // For now, return neutral score
186
- return 0.5;
187
- }
188
- calculateCostScore(agent) {
189
- // Would calculate based on compute costs, data transfer costs, etc.
190
- // For now, return neutral score
191
- return 0.5;
192
- }
193
- // ========================================
194
- // Load Balancer Selection
195
- // ========================================
196
- selectLoadBalancer(task, analysis) {
197
- // Select based on task characteristics
198
- if (analysis.complexity > 0.8) {
199
- return new CapabilityWeightedLoadBalancer(this.performanceTracker);
200
- }
201
- else if (analysis.hasGeographicRequirements) {
202
- return new GeographicAffinityLoadBalancer();
203
- }
204
- else if (analysis.estimatedAgentCount > 5) {
205
- return new AIOptimizedLoadBalancer(this.performanceTracker);
206
- }
207
- else {
208
- return new RoundRobinLoadBalancer();
209
- }
210
- }
211
- // ========================================
212
- // Execution Plan Creation
213
- // ========================================
214
- async createExecutionPlan(assignments, analysis) {
215
- const phases = await this.identifyExecutionPhases(assignments, analysis);
216
- const estimatedDuration = this.calculateTotalDuration(phases);
217
- const parallelizationScore = this.calculateParallelizationScore(phases);
218
- const resourceUsage = this.calculateResourceUsage(assignments);
219
- return {
220
- phases,
221
- estimatedDuration,
222
- parallelizationScore,
223
- resourceUsage
224
- };
225
- }
226
- async identifyExecutionPhases(assignments, analysis) {
227
- const phases = [];
228
- const dependencyGraph = this.buildDependencyGraph(assignments);
229
- // Topological sort to identify execution order
230
- const sortedLevels = this.topologicalSort(dependencyGraph);
231
- for (let level = 0; level < sortedLevels.length; level++) {
232
- const tasksAtLevel = sortedLevels[level];
233
- const canRunInParallel = tasksAtLevel.length > 1 && !analysis.hasStrictOrdering;
234
- phases.push({
235
- id: `phase_${level}`,
236
- type: canRunInParallel ? 'parallel' : 'sequential',
237
- tasks: tasksAtLevel.map(task => task.taskPortion.id),
238
- estimatedDuration: Math.max(...tasksAtLevel.map(t => t.estimatedEnd.getTime() - t.estimatedStart.getTime())),
239
- dependencies: level > 0 ? [`phase_${level - 1}`] : []
240
- });
241
- }
242
- return phases;
243
- }
244
- // ========================================
245
- // Fallback Planning
246
- // ========================================
247
- async generateFallbackPlan(task, availableAgents) {
248
- // Create a simpler, more conservative fallback plan
249
- const fallbackAgents = availableAgents
250
- .filter(agent => agent.status === distributed_orchestration_interface_js_1.InstanceStatus.ACTIVE)
251
- .sort((a, b) => this.calculateReliabilityScore(b) - this.calculateReliabilityScore(a))
252
- .slice(0, Math.min(3, availableAgents.length)); // Max 3 agents for fallback
253
- const loadBalancer = new RoundRobinLoadBalancer();
254
- const assignments = await loadBalancer.optimize(fallbackAgents, task);
255
- return {
256
- taskId: task.id,
257
- assignments,
258
- executionOrder: [{
259
- id: 'fallback_phase',
260
- type: 'sequential',
261
- tasks: assignments.map(a => a.taskPortion.id),
262
- estimatedDuration: Math.max(...assignments.map(a => a.estimatedEnd.getTime() - a.estimatedStart.getTime())),
263
- dependencies: []
264
- }],
265
- estimated: {
266
- totalDuration: Math.max(...assignments.map(a => a.estimatedEnd.getTime() - a.estimatedStart.getTime())),
267
- parallelization: 0.3, // Conservative parallelization
268
- resourceUsage: this.calculateResourceUsage(assignments)
269
- }
270
- };
271
- }
272
- // ========================================
273
- // Validation
274
- // ========================================
275
- async validateDistributionPlan(plan, task) {
276
- const validations = [
277
- this.validateResourceAllocation(plan, task),
278
- this.validateDeadlines(plan, task),
279
- this.validateCapabilities(plan, task),
280
- this.validateConstraints(plan, task)
281
- ];
282
- const results = await Promise.all(validations);
283
- const failures = results.filter(r => !r.valid);
284
- if (failures.length > 0) {
285
- throw new TaskDistributionError(`Distribution plan validation failed: ${failures.map(f => f.reason).join(', ')}`);
286
- }
287
- }
288
- // ========================================
289
- // Load Balancing Implementations
290
- // ========================================
291
- initializeLoadBalancers() {
292
- const balancers = new Map();
293
- balancers.set('round_robin', {
294
- name: 'round_robin',
295
- type: 'round_robin',
296
- parameters: {}
297
- });
298
- balancers.set('capability_weighted', {
299
- name: 'capability_weighted',
300
- type: 'capability_based',
301
- parameters: { weightFactor: 0.8 }
302
- });
303
- balancers.set('geographic_affinity', {
304
- name: 'geographic_affinity',
305
- type: 'geographic',
306
- parameters: { maxLatency: 100 }
307
- });
308
- return balancers;
309
- }
310
- // ========================================
311
- // Utility Methods
312
- // ========================================
313
- stringSimilarity(str1, str2) {
314
- // Simple Levenshtein distance-based similarity
315
- const len1 = str1.length;
316
- const len2 = str2.length;
317
- const matrix = Array(len2 + 1).fill(null).map(() => Array(len1 + 1).fill(null));
318
- for (let i = 0; i <= len1; i++)
319
- matrix[0][i] = i;
320
- for (let j = 0; j <= len2; j++)
321
- matrix[j][0] = j;
322
- for (let j = 1; j <= len2; j++) {
323
- for (let i = 1; i <= len1; i++) {
324
- const substitutionCost = str1[i - 1] === str2[j - 1] ? 0 : 1;
325
- matrix[j][i] = Math.min(matrix[j][i - 1] + 1, // deletion
326
- matrix[j - 1][i] + 1, // insertion
327
- matrix[j - 1][i - 1] + substitutionCost // substitution
328
- );
329
- }
330
- }
331
- const maxLen = Math.max(len1, len2);
332
- return maxLen === 0 ? 1 : (maxLen - matrix[len2][len1]) / maxLen;
333
- }
334
- evaluateConstraint(agent, constraint) {
335
- // Implementation would evaluate specific constraint types
336
- return true; // Simplified for now
337
- }
338
- calculateReliabilityScore(agent) {
339
- const metrics = agent.metadata.performanceMetrics;
340
- const healthScore = agent.healthcheck.consecutiveFailures === 0 ? 1 :
341
- Math.max(0, 1 - (agent.healthcheck.consecutiveFailures * 0.1));
342
- return (metrics.taskCompletionRate + healthScore) / 2;
343
- }
344
- buildDependencyGraph(assignments) {
345
- // Build dependency graph from task assignments
346
- // Implementation would create actual dependency relationships
347
- return new Map();
348
- }
349
- topologicalSort(graph) {
350
- // Topological sort implementation
351
- // Returns assignments grouped by execution level
352
- return [];
353
- }
354
- calculateTotalDuration(phases) {
355
- return phases.reduce((total, phase) => total + phase.estimatedDuration, 0);
356
- }
357
- calculateParallelizationScore(phases) {
358
- const parallelPhases = phases.filter(p => p.type === 'parallel').length;
359
- return phases.length > 0 ? parallelPhases / phases.length : 0;
360
- }
361
- calculateResourceUsage(assignments) {
362
- return {
363
- cpu: assignments.reduce((total, a) => total + (a.resourceAllocation.find(r => r.type === 'cpu')?.amount || 0), 0),
364
- memory: assignments.reduce((total, a) => total + (a.resourceAllocation.find(r => r.type === 'memory')?.amount || 0), 0),
365
- network: 0, // Would calculate network usage
366
- storage: 0, // Would calculate storage usage
367
- apiCalls: 0 // Would estimate API calls
368
- };
369
- }
370
- async validateResourceAllocation(plan, task) {
371
- // Validate that resource allocation is realistic
372
- return { valid: true };
373
- }
374
- async validateDeadlines(plan, task) {
375
- // Validate that deadlines can be met
376
- if (task.deadline) {
377
- const estimatedCompletion = new Date(Date.now() + plan.estimated.totalDuration);
378
- if (estimatedCompletion > task.deadline) {
379
- return {
380
- valid: false,
381
- reason: `Estimated completion (${estimatedCompletion}) exceeds deadline (${task.deadline})`
382
- };
383
- }
384
- }
385
- return { valid: true };
386
- }
387
- async validateCapabilities(plan, task) {
388
- // Validate that all required capabilities are covered
389
- const requiredCapabilities = task.requirements.capabilities;
390
- const assignedCapabilities = new Set();
391
- for (const assignment of plan.assignments) {
392
- const agent = await this.agentPool.getAgent(assignment.agentId);
393
- if (agent) {
394
- agent.capabilities.forEach(cap => {
395
- cap.specialization.forEach(spec => assignedCapabilities.add(spec));
396
- });
397
- }
398
- }
399
- const missingCapabilities = requiredCapabilities.filter(req => !Array.from(assignedCapabilities).some(assigned => assigned.toLowerCase().includes(req.toLowerCase())));
400
- if (missingCapabilities.length > 0) {
401
- return {
402
- valid: false,
403
- reason: `Missing required capabilities: ${missingCapabilities.join(', ')}`
404
- };
405
- }
406
- return { valid: true };
407
- }
408
- async validateConstraints(plan, task) {
409
- // Validate that all constraints are satisfied
410
- return { valid: true };
411
- }
412
- }
413
- exports.IntelligentTaskDistributor = IntelligentTaskDistributor;
414
- // ========================================
415
- // Supporting Classes
416
- // ========================================
417
- class ExternalAgentPool {
418
- constructor() {
419
- this.agents = new Map();
420
- }
421
- async getAvailableAgents() {
422
- return Array.from(this.agents.values())
423
- .filter(agent => agent.status === distributed_orchestration_interface_js_1.InstanceStatus.ACTIVE || agent.status === distributed_orchestration_interface_js_1.InstanceStatus.IDLE);
424
- }
425
- async getAgent(agentId) {
426
- return this.agents.get(agentId);
427
- }
428
- async addAgent(agent) {
429
- this.agents.set(agent.id, agent);
430
- }
431
- async removeAgent(agentId) {
432
- this.agents.delete(agentId);
433
- }
434
- }
435
- class TaskAnalyzer {
436
- async analyze(task) {
437
- const complexity = this.calculateComplexity(task);
438
- const estimatedAgentCount = this.estimateAgentCount(task, complexity);
439
- const hasGeographicRequirements = this.checkGeographicRequirements(task);
440
- const hasStrictOrdering = this.checkStrictOrdering(task);
441
- return {
442
- complexity,
443
- estimatedAgentCount,
444
- hasGeographicRequirements,
445
- hasStrictOrdering,
446
- requirements: task.requirements
447
- };
448
- }
449
- calculateComplexity(task) {
450
- let complexity = 0.3; // Base complexity
451
- // Factor in number of dependencies
452
- complexity += Math.min(task.dependencies.length * 0.1, 0.3);
453
- // Factor in number of required capabilities
454
- complexity += Math.min(task.requirements.capabilities.length * 0.05, 0.2);
455
- // Factor in resource requirements
456
- complexity += Math.min(task.requirements.resources.length * 0.1, 0.2);
457
- return Math.min(complexity, 1.0);
458
- }
459
- estimateAgentCount(task, complexity) {
460
- const baseAgents = 1;
461
- const complexityAgents = Math.ceil(complexity * 3);
462
- const capabilityAgents = Math.ceil(task.requirements.capabilities.length / 2);
463
- return Math.min(Math.max(baseAgents, complexityAgents, capabilityAgents), 8);
464
- }
465
- checkGeographicRequirements(task) {
466
- return task.requirements.constraints.some(constraint => constraint.type === 'resource' &&
467
- constraint.description.toLowerCase().includes('geographic'));
468
- }
469
- checkStrictOrdering(task) {
470
- return task.dependencies.length > 0 ||
471
- task.requirements.constraints.some(constraint => constraint.type === 'dependency');
472
- }
473
- }
474
- class AffinityManager {
475
- async apply(assignments, rules) {
476
- if (rules.length === 0)
477
- return assignments;
478
- let optimizedAssignments = [...assignments];
479
- for (const rule of rules) {
480
- optimizedAssignments = await this.applyAffinityRule(optimizedAssignments, rule);
481
- }
482
- return optimizedAssignments;
483
- }
484
- async applyAffinityRule(assignments, rule) {
485
- // Implementation would apply specific affinity rules
486
- // For now, return unchanged assignments
487
- return assignments;
488
- }
489
- }
490
- class PerformanceTracker {
491
- constructor() {
492
- this.taskCounts = new Map();
493
- }
494
- getCurrentTaskCount(agentId) {
495
- return this.taskCounts.get(agentId) || 0;
496
- }
497
- incrementTaskCount(agentId) {
498
- const current = this.getCurrentTaskCount(agentId);
499
- this.taskCounts.set(agentId, current + 1);
500
- }
501
- decrementTaskCount(agentId) {
502
- const current = this.getCurrentTaskCount(agentId);
503
- this.taskCounts.set(agentId, Math.max(0, current - 1));
504
- }
505
- }
506
- class CostOptimizer {
507
- async optimize(assignments, task) {
508
- // Implementation would optimize for cost efficiency
509
- // For now, return unchanged assignments
510
- return assignments;
511
- }
512
- }
513
- // ========================================
514
- // Load Balancer Implementations
515
- // ========================================
516
- class IntelligentLoadBalancer {
517
- }
518
- class RoundRobinLoadBalancer extends IntelligentLoadBalancer {
519
- async optimize(candidates, task) {
520
- const assignments = [];
521
- const agentCount = Math.min(candidates.length, 3); // Limit to 3 agents for round-robin
522
- for (let i = 0; i < agentCount; i++) {
523
- const agent = candidates[i];
524
- assignments.push({
525
- agentId: agent.id,
526
- taskPortion: {
527
- id: `portion_${i}`,
528
- parentTaskId: task.id,
529
- work: this.createWorkPortion(task, i, agentCount),
530
- inputs: task.requirements.inputs,
531
- expectedOutputs: task.outputs,
532
- dependencies: task.dependencies
533
- },
534
- priority: 1,
535
- estimatedStart: new Date(),
536
- estimatedEnd: new Date(Date.now() + (task.estimatedDuration || 300000)),
537
- resourceAllocation: []
538
- });
539
- }
540
- return assignments;
541
- }
542
- createWorkPortion(task, index, total) {
543
- return {
544
- type: task.type,
545
- portion: `${index + 1}/${total}`,
546
- description: `${task.description} (Part ${index + 1} of ${total})`
547
- };
548
- }
549
- }
550
- class CapabilityWeightedLoadBalancer extends IntelligentLoadBalancer {
551
- constructor(performanceTracker) {
552
- super();
553
- this.performanceTracker = performanceTracker;
554
- }
555
- async optimize(candidates, task) {
556
- // Implementation would weight assignments based on capabilities
557
- return new RoundRobinLoadBalancer().optimize(candidates, task);
558
- }
559
- }
560
- class GeographicAffinityLoadBalancer extends IntelligentLoadBalancer {
561
- async optimize(candidates, task) {
562
- // Implementation would optimize for geographic proximity
563
- return new RoundRobinLoadBalancer().optimize(candidates, task);
564
- }
565
- }
566
- class AIOptimizedLoadBalancer extends IntelligentLoadBalancer {
567
- constructor(performanceTracker) {
568
- super();
569
- this.performanceTracker = performanceTracker;
570
- }
571
- async optimize(candidates, task) {
572
- // Implementation would use ML models for optimization
573
- return new RoundRobinLoadBalancer().optimize(candidates, task);
574
- }
575
- }
576
- // ========================================
577
- // Error Classes
578
- // ========================================
579
- class TaskDistributionError extends Error {
580
- constructor(message) {
581
- super(message);
582
- this.name = 'TaskDistributionError';
583
- }
584
- }
585
- exports.TaskDistributionError = TaskDistributionError;
586
- //# sourceMappingURL=task-distribution-engine.js.map