snow-flow 2.0.2 → 2.0.3

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 (173) hide show
  1. package/{.claude/mcp-config.json → .mcp.json} +13 -12
  2. package/.releaserc.json +47 -0
  3. package/README.md +6 -0
  4. package/package.json +1 -1
  5. package/.claude/claude-settings.json +0 -15
  6. package/.claude/commands/analysis/README.md +0 -9
  7. package/.claude/commands/automation/README.md +0 -9
  8. package/.claude/commands/github/README.md +0 -11
  9. package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
  10. package/.claude/commands/hooks/README.md +0 -11
  11. package/.claude/commands/monitoring/README.md +0 -9
  12. package/.claude/commands/optimization/README.md +0 -9
  13. package/.claude/commands/training/README.md +0 -9
  14. package/.claude/commands/workflows/README.md +0 -9
  15. package/.claude/config.json +0 -36
  16. package/.claude/helpers/github-setup.sh +0 -28
  17. package/.claude/helpers/quick-start.sh +0 -19
  18. package/.claude/helpers/setup-mcp.sh +0 -18
  19. package/.claude/settings.json +0 -114
  20. package/.claude/settings.local.json +0 -33
  21. package/.claude-flow/metrics/agent-metrics.json +0 -1
  22. package/.claude-flow/metrics/performance.json +0 -9
  23. package/.claude-flow/metrics/system-metrics.json +0 -15986
  24. package/.claude-flow/metrics/task-metrics.json +0 -10
  25. package/.roo/README.md +0 -402
  26. package/.roo/mcp-list.txt +0 -257
  27. package/.roo/mcp.json +0 -32
  28. package/.roo/workflows/basic-tdd.json +0 -32
  29. package/.roomodes +0 -201
  30. package/CLAUDE.md +0 -393
  31. package/bin/snow-flow.js +0 -3
  32. package/dist/cli.js.bak +0 -2052
  33. package/dist/config/snow-flow-config.d.ts +0 -1492
  34. package/dist/config/snow-flow-config.js +0 -938
  35. package/scripts/create-env.js +0 -91
  36. package/scripts/postinstall.js +0 -30
  37. package/scripts/register-mcp-servers.js +0 -210
  38. package/scripts/reset-mcp-servers.js +0 -246
  39. package/scripts/setup-mcp.js +0 -106
  40. package/scripts/update-version.js +0 -31
  41. package/src/agents/README.md +0 -192
  42. package/src/agents/base-agent.ts +0 -251
  43. package/src/agents/coordinator.ts +0 -971
  44. package/src/agents/index.ts +0 -18
  45. package/src/agents/queen-403-handler.ts +0 -230
  46. package/src/agents/queen-agent.ts +0 -1399
  47. package/src/agents/script-writer-agent.ts +0 -769
  48. package/src/agents/security-agent.ts +0 -726
  49. package/src/agents/widget-creator-agent.ts +0 -568
  50. package/src/api/error-handling.ts +0 -1758
  51. package/src/api/natural-language-mapper.ts +0 -630
  52. package/src/api/performance-optimizer.ts +0 -891
  53. package/src/api/transaction-manager.ts +0 -754
  54. package/src/cli/deploy-artifact.ts +0 -304
  55. package/src/cli/snow-flow-cli-integration.ts +0 -434
  56. package/src/cli.ts +0 -4455
  57. package/src/cli.ts.bak +0 -5616
  58. package/src/compliance/advanced-compliance-system.ts +0 -1268
  59. package/src/compliance/index.ts +0 -19
  60. package/src/config/snow-flow-config.ts +0 -1019
  61. package/src/documentation/index.ts +0 -16
  62. package/src/documentation/self-documenting-system.ts +0 -1421
  63. package/src/dynamic-version.ts +0 -44
  64. package/src/healing/index.ts +0 -20
  65. package/src/healing/self-healing-system.ts +0 -1435
  66. package/src/health/README.md +0 -161
  67. package/src/health/system-health.ts +0 -995
  68. package/src/index.ts +0 -60
  69. package/src/intelligence/acl-analyzer.ts +0 -377
  70. package/src/intelligence/auto-resolution-engine.ts +0 -643
  71. package/src/intelligence/gap-analysis-engine.ts +0 -488
  72. package/src/intelligence/manual-instructions-generator.ts +0 -744
  73. package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
  74. package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
  75. package/src/intelligence/performance-recommendations-engine.ts +0 -1223
  76. package/src/intelligence/requirements-analyzer.ts +0 -1148
  77. package/src/intelligence/task-analyzer.ts +0 -628
  78. package/src/managers/scope-manager.ts +0 -555
  79. package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
  80. package/src/mcp/base-mcp-server.ts +0 -660
  81. package/src/mcp/http-transport-wrapper.ts +0 -426
  82. package/src/mcp/service-discovery-client.ts +0 -312
  83. package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
  84. package/src/mcp/servicenow-automation-mcp.ts +0 -838
  85. package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
  86. package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
  87. package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
  88. package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
  89. package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
  90. package/src/mcp/servicenow-integration-mcp.ts +0 -819
  91. package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
  92. package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
  93. package/src/mcp/servicenow-mcp-server.ts +0 -728
  94. package/src/mcp/servicenow-memory-mcp.ts +0 -474
  95. package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
  96. package/src/mcp/servicenow-operations-mcp.ts +0 -3384
  97. package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
  98. package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
  99. package/src/mcp/servicenow-progressive-indexer.ts +0 -370
  100. package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
  101. package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
  102. package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
  103. package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
  104. package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
  105. package/src/mcp/servicenow-update-set-mcp.ts +0 -811
  106. package/src/mcp/shared/agent-context-provider.ts +0 -365
  107. package/src/mcp/shared/base-mcp-server.ts +0 -2463
  108. package/src/mcp/shared/mcp-memory-manager.ts +0 -540
  109. package/src/mcp/shared/mcp-resource-manager.ts +0 -367
  110. package/src/mcp/snow-flow-mcp.ts +0 -911
  111. package/src/mcp/start-all-mcp-servers.ts +0 -102
  112. package/src/mcp/start-servicenow-mcp.ts +0 -67
  113. package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
  114. package/src/monitoring/performance-tracker.ts +0 -777
  115. package/src/optimization/cost-optimization-engine.ts +0 -1125
  116. package/src/optimization/index.ts +0 -10
  117. package/src/queen/README.md +0 -403
  118. package/src/queen/agent-factory.ts +0 -574
  119. package/src/queen/index.ts +0 -94
  120. package/src/queen/mcp-execution-bridge.ts +0 -681
  121. package/src/queen/neural-learning.ts +0 -319
  122. package/src/queen/parallel-agent-engine.ts +0 -848
  123. package/src/queen/queen-memory-system.ts +0 -490
  124. package/src/queen/queen-memory.ts +0 -456
  125. package/src/queen/servicenow-queen.ts +0 -1029
  126. package/src/queen/types.ts +0 -87
  127. package/src/rollback/smart-rollback-system.ts +0 -866
  128. package/src/schemas/deployment.schema.json +0 -58
  129. package/src/schemas/flow.schema.json +0 -79
  130. package/src/schemas/widget.schema.json +0 -72
  131. package/src/snow-flow-system.ts +0 -541
  132. package/src/sparc/sparc-help.ts +0 -49
  133. package/src/sparc/team-sparc.ts +0 -88
  134. package/src/strategies/global-scope-strategy.ts +0 -736
  135. package/src/templates/base/application.template.json +0 -45
  136. package/src/templates/base/business_rule.template.json +0 -33
  137. package/src/templates/base/script_include.template.json +0 -18
  138. package/src/templates/base/table.template.json +0 -64
  139. package/src/templates/base/widget.template.json +0 -25
  140. package/src/templates/patterns/composite.incident-management.template.json +0 -140
  141. package/src/templates/patterns/widget.dashboard.template.json +0 -238
  142. package/src/templates/patterns/widget.datatable.template.json +0 -292
  143. package/src/testing/integration-test-suite.ts +0 -1276
  144. package/src/types/index.ts +0 -183
  145. package/src/types/neo4j-driver.d.ts +0 -23
  146. package/src/types/servicenow.types.ts +0 -307
  147. package/src/types/snow-flow.types.ts +0 -186
  148. package/src/types/todo.types.ts +0 -70
  149. package/src/utils/action-type-cache.ts +0 -286
  150. package/src/utils/agent-detector.ts +0 -573
  151. package/src/utils/artifact-tracker.ts +0 -379
  152. package/src/utils/dependency-detector.ts +0 -233
  153. package/src/utils/deployment-metadata-handler.ts +0 -518
  154. package/src/utils/error-recovery.ts +0 -680
  155. package/src/utils/logger.ts +0 -60
  156. package/src/utils/mcp-auth-middleware.ts +0 -262
  157. package/src/utils/mcp-config-manager.ts +0 -270
  158. package/src/utils/mcp-server-manager.ts +0 -446
  159. package/src/utils/mcp-tool-registry.ts +0 -298
  160. package/src/utils/migrate-snow-flow.ts +0 -98
  161. package/src/utils/oauth-html-templates.ts +0 -188
  162. package/src/utils/scope-utils.ts +0 -443
  163. package/src/utils/servicenow-client.ts +0 -3321
  164. package/src/utils/servicenow-id-generator.ts +0 -181
  165. package/src/utils/snow-memory-manager.ts +0 -605
  166. package/src/utils/snow-oauth.ts +0 -797
  167. package/src/utils/template-engine.ts +0 -463
  168. package/src/utils/theme-manager.ts +0 -295
  169. package/src/utils/unified-auth-store.ts +0 -222
  170. package/src/utils/update-set-importer.ts +0 -422
  171. package/src/utils/update-set-xml-packager.ts +0 -371
  172. package/src/utils/widget-template-generator.ts +0 -1744
  173. package/src/version.ts +0 -1950
@@ -1,848 +0,0 @@
1
- /**
2
- * Intelligent Parallel Agent Engine
3
- * Automatically detects parallelizable work and spawns optimized agent teams
4
- * Integrates with Queen Agent for enhanced multi-agent coordination
5
- */
6
-
7
- import { EventEmitter } from 'eventemitter3';
8
- import { TodoItem, TodoStatus } from '../types/todo.types';
9
- import { Agent, AgentType, ServiceNowTask } from './types';
10
- import { QueenMemorySystem } from './queen-memory';
11
- import { Logger } from '../utils/logger';
12
- import * as crypto from 'crypto';
13
-
14
- export interface ParallelizationOpportunity {
15
- id: string;
16
- type: 'independent_tasks' | 'specialized_breakdown' | 'load_distribution' | 'capability_split';
17
- todos: string[]; // Todo IDs that can be parallelized
18
- suggestedAgents: AgentType[];
19
- estimatedSpeedup: number; // Multiplier (e.g., 2.5x faster)
20
- confidence: number; // 0-1 confidence in parallelization success
21
- dependencies: string[]; // Todo IDs these depend on
22
- blockers: string[]; // What prevents parallelization
23
- }
24
-
25
- export interface AgentWorkload {
26
- agentId: string;
27
- agentType: AgentType;
28
- assignedTodos: string[];
29
- estimatedDuration: number; // minutes
30
- utilization: number; // 0-1 how busy this agent is
31
- capabilities: string[];
32
- specializations: string[];
33
- }
34
-
35
- export interface ParallelExecutionPlan {
36
- planId: string;
37
- opportunities: ParallelizationOpportunity[];
38
- agentTeam: AgentWorkload[];
39
- executionStrategy: 'wave_based' | 'concurrent' | 'pipeline' | 'hybrid';
40
- estimatedCompletion: number; // minutes
41
- maxParallelism: number; // Max concurrent agents
42
- failureRecovery: 'retry' | 'reassign' | 'fallback';
43
- }
44
-
45
- export interface CapabilityMap {
46
- [todoPattern: string]: {
47
- primaryCapability: string;
48
- requiredAgentTypes: AgentType[];
49
- parallelizable: boolean;
50
- estimatedDuration: number;
51
- dependencies: string[];
52
- };
53
- }
54
-
55
- export class ParallelAgentEngine extends EventEmitter {
56
- private memory: QueenMemorySystem;
57
- private capabilityMap: CapabilityMap;
58
- private activeExecutionPlans: Map<string, ParallelExecutionPlan>;
59
- private agentWorkloads: Map<string, AgentWorkload>;
60
- private parallelizationHistory: Map<string, { success: boolean; speedup: number; }>;
61
- private logger = new Logger('ParallelAgentEngine');
62
-
63
- constructor(memory: QueenMemorySystem) {
64
- super();
65
- this.memory = memory;
66
- this.activeExecutionPlans = new Map();
67
- this.agentWorkloads = new Map();
68
- this.parallelizationHistory = new Map();
69
-
70
- this.initializeCapabilityMap();
71
- this.setupLearningSystem();
72
- }
73
-
74
- /**
75
- * Main entry point: Analyze todos and detect parallelization opportunities
76
- */
77
- async detectParallelizationOpportunities(
78
- todos: TodoItem[],
79
- objectiveType: ServiceNowTask['type'],
80
- currentAgents: Agent[]
81
- ): Promise<ParallelizationOpportunity[]> {
82
- this.logger.info('🧠 Analyzing parallelization opportunities', {
83
- todoCount: todos.length,
84
- objectiveType,
85
- currentAgentCount: currentAgents.length
86
- });
87
-
88
- const opportunities: ParallelizationOpportunity[] = [];
89
-
90
- // 1. Detect independent tasks (can run simultaneously)
91
- const independentOpportunity = await this.detectIndependentTasks(todos);
92
- if (independentOpportunity) opportunities.push(independentOpportunity);
93
-
94
- // 2. Detect specialized breakdown opportunities (split complex task)
95
- const specializedOpportunity = await this.detectSpecializedBreakdown(todos, objectiveType);
96
- if (specializedOpportunity) opportunities.push(specializedOpportunity);
97
-
98
- // 3. Detect load distribution opportunities (same type, multiple agents)
99
- const loadOpportunity = await this.detectLoadDistribution(todos, currentAgents);
100
- if (loadOpportunity) opportunities.push(loadOpportunity);
101
-
102
- // 4. Detect capability split opportunities (different skills needed)
103
- const capabilityOpportunity = await this.detectCapabilitySplit(todos);
104
- if (capabilityOpportunity) opportunities.push(capabilityOpportunity);
105
-
106
- // 🚀 ENHANCED: More lenient filtering to ensure parallel execution happens
107
- const rankedOpportunities = opportunities
108
- .filter(opp => opp.confidence > 0.5 && opp.estimatedSpeedup > 1.1) // Lower thresholds
109
- .sort((a, b) => (b.confidence * b.estimatedSpeedup) - (a.confidence * a.estimatedSpeedup));
110
-
111
- this.logger.info(`🎯 Found ${rankedOpportunities.length} high-confidence parallelization opportunities`, {
112
- totalOpportunities: opportunities.length,
113
- rankedCount: rankedOpportunities.length,
114
- averageConfidence: rankedOpportunities.reduce((sum, opp) => sum + opp.confidence, 0) / rankedOpportunities.length || 0
115
- });
116
-
117
- // Store opportunities for learning
118
- await this.storeOpportunities(todos, rankedOpportunities);
119
-
120
- return rankedOpportunities;
121
- }
122
-
123
- /**
124
- * Create optimal execution plan based on opportunities
125
- */
126
- async createExecutionPlan(
127
- opportunities: ParallelizationOpportunity[],
128
- todos: TodoItem[],
129
- maxAgents: number = 8
130
- ): Promise<ParallelExecutionPlan> {
131
- const planId = this.generateId('plan');
132
-
133
- // Calculate optimal agent team
134
- const agentTeam = await this.calculateOptimalTeam(opportunities, todos, maxAgents);
135
-
136
- // Determine execution strategy
137
- const strategy = this.determineExecutionStrategy(opportunities, agentTeam);
138
-
139
- // Estimate completion time
140
- const estimatedCompletion = this.estimateCompletionTime(agentTeam, strategy);
141
-
142
- const plan: ParallelExecutionPlan = {
143
- planId,
144
- opportunities,
145
- agentTeam,
146
- executionStrategy: strategy,
147
- estimatedCompletion,
148
- maxParallelism: Math.min(agentTeam.length, maxAgents),
149
- failureRecovery: 'reassign'
150
- };
151
-
152
- this.activeExecutionPlans.set(planId, plan);
153
-
154
- this.logger.info(`📋 Created execution plan ${planId}`, {
155
- planId,
156
- strategy,
157
- teamSize: agentTeam.length,
158
- estimatedCompletion,
159
- maxParallelism: plan.maxParallelism,
160
- opportunityCount: opportunities.length
161
- });
162
-
163
- return plan;
164
- }
165
-
166
- /**
167
- * Execute parallel plan and coordinate agents
168
- */
169
- async executeParallelPlan(
170
- plan: ParallelExecutionPlan,
171
- spawnAgentCallback: (type: AgentType, specialization?: string) => Promise<Agent>
172
- ): Promise<{
173
- spawnedAgents: Agent[];
174
- executionDetails: {
175
- totalAgentsSpawned: number;
176
- parallelWorkflows: number;
177
- estimatedSpeedup: string;
178
- };
179
- }> {
180
- this.logger.info(`🚀 Executing parallel plan ${plan.planId}`, {
181
- planId: plan.planId,
182
- strategy: plan.executionStrategy,
183
- agentTeamSize: plan.agentTeam.length,
184
- maxParallelism: plan.maxParallelism
185
- });
186
-
187
- const spawnedAgents: Agent[] = [];
188
-
189
- // Spawn agents based on plan
190
- for (const workload of plan.agentTeam) {
191
- if (workload.agentId === 'new') {
192
- // Spawn new agent with specialization
193
- const specialization = this.determineAgentSpecialization(workload);
194
- const agent = await spawnAgentCallback(workload.agentType, specialization);
195
- spawnedAgents.push(agent);
196
-
197
- // Update workload with actual agent ID
198
- workload.agentId = agent.id;
199
- this.agentWorkloads.set(agent.id, workload);
200
- }
201
- }
202
-
203
- // Set up parallel coordination
204
- await this.setupParallelCoordination(plan, spawnedAgents);
205
-
206
- // Calculate speedup
207
- const sequentialTime = plan.agentTeam.reduce((sum, w) => sum + w.estimatedDuration, 0);
208
- const parallelTime = plan.estimatedCompletion;
209
- const actualSpeedup = sequentialTime / parallelTime;
210
-
211
- this.emit('parallel_execution_started', {
212
- planId: plan.planId,
213
- agentCount: spawnedAgents.length,
214
- estimatedSpeedup: actualSpeedup
215
- });
216
-
217
- return {
218
- spawnedAgents,
219
- executionDetails: {
220
- totalAgentsSpawned: spawnedAgents.length,
221
- parallelWorkflows: plan.opportunities.length,
222
- estimatedSpeedup: `${actualSpeedup.toFixed(1)}x faster`
223
- }
224
- };
225
- }
226
-
227
- /**
228
- * Detect independent tasks that can run in parallel
229
- */
230
- private async detectIndependentTasks(todos: TodoItem[]): Promise<ParallelizationOpportunity | null> {
231
- const independentGroups: string[][] = [];
232
- const processed = new Set<string>();
233
-
234
- for (const todo of todos) {
235
- if (processed.has(todo.id)) continue;
236
-
237
- const group = [todo.id];
238
- processed.add(todo.id);
239
-
240
- // Find todos that can run with this one
241
- for (const otherTodo of todos) {
242
- if (processed.has(otherTodo.id)) continue;
243
-
244
- if (this.areTasksIndependent(todo, otherTodo)) {
245
- group.push(otherTodo.id);
246
- processed.add(otherTodo.id);
247
- }
248
- }
249
-
250
- if (group.length > 1) {
251
- independentGroups.push(group);
252
- }
253
- }
254
-
255
- if (independentGroups.length === 0) return null;
256
-
257
- // Find the largest independent group
258
- const largestGroup = independentGroups.reduce((max, group) =>
259
- group.length > max.length ? group : max
260
- );
261
-
262
- return {
263
- id: this.generateId('independent'),
264
- type: 'independent_tasks',
265
- todos: largestGroup,
266
- suggestedAgents: this.suggestAgentsForTodos(largestGroup, todos),
267
- estimatedSpeedup: largestGroup.length * 0.8, // Account for coordination overhead
268
- confidence: 0.9, // High confidence for independent tasks
269
- dependencies: [],
270
- blockers: []
271
- };
272
- }
273
-
274
- /**
275
- * Detect opportunities to break down complex tasks into specialized agents
276
- */
277
- private async detectSpecializedBreakdown(
278
- todos: TodoItem[],
279
- objectiveType: ServiceNowTask['type']
280
- ): Promise<ParallelizationOpportunity | null> {
281
- // 🚀 ENHANCED: More intelligent detection of tasks that benefit from specialization
282
- const canBenefitFromSpecialization = todos.filter(todo => {
283
- const content = todo.content.toLowerCase();
284
-
285
- // Widget development indicators
286
- if (content.includes('widget') || content.includes('portal') || content.includes('ui')) {
287
- return true;
288
- }
289
-
290
- // Development indicators
291
- if (content.includes('develop') || content.includes('create') || content.includes('build')) {
292
- return true;
293
- }
294
-
295
- // Multiple component indicators
296
- if (content.includes('and') || content.includes('with') || content.includes('including')) {
297
- return true;
298
- }
299
-
300
- // Complex task indicators
301
- if (todo.priority === 'high' || todo.priority === 'medium') {
302
- return true;
303
- }
304
-
305
- // Any development-related task benefits from specialization
306
- if (content.includes('test') || content.includes('style') || content.includes('script')) {
307
- return true;
308
- }
309
-
310
- return false;
311
- });
312
-
313
- // 🚀 Be more aggressive - even single development tasks benefit from parallel specialists
314
- if (canBenefitFromSpecialization.length === 0 && todos.length > 0) {
315
- // If no specific indicators, but we have todos, still try to parallelize
316
- canBenefitFromSpecialization.push(...todos.slice(0, Math.min(3, todos.length)));
317
- }
318
-
319
- if (canBenefitFromSpecialization.length === 0) return null;
320
-
321
- // 🚀 ENHANCED: More specialized agent teams with specific roles
322
- const breakdownMap = {
323
- 'widget': [
324
- 'widget-creator', // HTML structure specialist
325
- 'css-specialist', // Styling and responsive design specialist
326
- 'backend-specialist', // Server script specialist
327
- 'frontend-specialist', // Client script specialist
328
- 'integration-specialist', // API integration specialist
329
- 'ui-ux-specialist', // User experience specialist
330
- 'performance-specialist', // Performance optimization
331
- 'accessibility-specialist', // Accessibility compliance
332
- 'tester' // Testing specialist
333
- ],
334
- 'flow': [
335
- 'flow-builder', // Flow structure specialist
336
- 'trigger-specialist', // Trigger configuration specialist
337
- 'action-specialist', // Action development specialist
338
- 'integration-specialist', // External system integration
339
- 'approval-specialist', // Approval process specialist
340
- 'notification-specialist', // Notification configuration
341
- 'error-handler', // Error handling specialist
342
- 'tester' // Flow testing specialist
343
- ],
344
- 'application': [
345
- 'app-architect', // Application architecture
346
- 'widget-creator', // UI components
347
- 'css-specialist', // Styling specialist
348
- 'flow-builder', // Business logic flows
349
- 'script-writer', // Script includes and business rules
350
- 'security-specialist', // Security implementation
351
- 'integration-specialist', // System integration
352
- 'performance-specialist', // Performance optimization
353
- 'documentation-specialist', // Documentation
354
- 'tester' // Comprehensive testing
355
- ],
356
- 'script': [
357
- 'script-writer', // Core script development
358
- 'api-specialist', // API integration specialist
359
- 'performance-specialist', // Code optimization
360
- 'security-specialist', // Security review
361
- 'documentation-specialist', // Code documentation
362
- 'tester' // Script testing
363
- ],
364
- 'integration': [
365
- 'integration-specialist', // Core integration
366
- 'api-specialist', // API development
367
- 'transform-specialist', // Data transformation
368
- 'error-handler', // Error handling
369
- 'monitoring-specialist', // Integration monitoring
370
- 'security-specialist', // Security implementation
371
- 'tester' // Integration testing
372
- ]
373
- };
374
-
375
- // Select appropriate specialists based on task
376
- let suggestedAgents = breakdownMap[objectiveType] || breakdownMap['widget'];
377
-
378
- // 🚀 Limit to reasonable number but ensure good coverage
379
- const maxSpecialists = Math.min(8, Math.max(4, canBenefitFromSpecialization.length * 2));
380
- suggestedAgents = suggestedAgents.slice(0, maxSpecialists);
381
-
382
- const todoIds = canBenefitFromSpecialization.map(t => t.id);
383
-
384
- return {
385
- id: this.generateId('specialized'),
386
- type: 'specialized_breakdown',
387
- todos: todoIds,
388
- suggestedAgents: suggestedAgents as AgentType[],
389
- estimatedSpeedup: Math.min(3.5, 1.5 + (suggestedAgents.length * 0.3)), // More realistic speedup
390
- confidence: 0.85, // Higher confidence for specialization benefits
391
- dependencies: [],
392
- blockers: []
393
- };
394
- }
395
-
396
- /**
397
- * Detect load distribution opportunities (same work type, multiple agents)
398
- */
399
- private async detectLoadDistribution(
400
- todos: TodoItem[],
401
- currentAgents: Agent[]
402
- ): Promise<ParallelizationOpportunity | null> {
403
- // Group todos by capability requirement
404
- const todoGroups = new Map<string, string[]>();
405
-
406
- for (const todo of todos) {
407
- const capability = this.inferTodoCapability(todo);
408
- if (!todoGroups.has(capability)) {
409
- todoGroups.set(capability, []);
410
- }
411
- todoGroups.get(capability)!.push(todo.id);
412
- }
413
-
414
- // Find groups with multiple todos that can be distributed
415
- for (const [capability, todoIds] of todoGroups) {
416
- if (todoIds.length >= 3) { // Worth distributing if 3+ similar tasks
417
- const agentType = this.capabilityToAgentType(capability);
418
-
419
- return {
420
- id: this.generateId('load'),
421
- type: 'load_distribution',
422
- todos: todoIds,
423
- suggestedAgents: [agentType, agentType, agentType], // Multiple agents of same type
424
- estimatedSpeedup: Math.min(todoIds.length, 3) * 0.75, // Account for coordination
425
- confidence: 0.85,
426
- dependencies: [],
427
- blockers: []
428
- };
429
- }
430
- }
431
-
432
- return null;
433
- }
434
-
435
- /**
436
- * Detect capability split opportunities (different skills for different parts)
437
- */
438
- private async detectCapabilitySplit(todos: TodoItem[]): Promise<ParallelizationOpportunity | null> {
439
- const capabilityGroups = new Map<string, string[]>();
440
-
441
- // Group todos by required capabilities
442
- for (const todo of todos) {
443
- const capabilities = this.analyzeTodoCapabilities(todo);
444
- for (const capability of capabilities) {
445
- if (!capabilityGroups.has(capability)) {
446
- capabilityGroups.set(capability, []);
447
- }
448
- capabilityGroups.get(capability)!.push(todo.id);
449
- }
450
- }
451
-
452
- // If we have multiple capability groups, we can split
453
- if (capabilityGroups.size >= 2) {
454
- const allTodos = Array.from(new Set(
455
- Array.from(capabilityGroups.values()).flat()
456
- ));
457
-
458
- const agentTypes = Array.from(capabilityGroups.keys())
459
- .map(cap => this.capabilityToAgentType(cap));
460
-
461
- return {
462
- id: this.generateId('capability'),
463
- type: 'capability_split',
464
- todos: allTodos,
465
- suggestedAgents: agentTypes as AgentType[],
466
- estimatedSpeedup: 1.8,
467
- confidence: 0.75,
468
- dependencies: [],
469
- blockers: []
470
- };
471
- }
472
-
473
- return null;
474
- }
475
-
476
- /**
477
- * Calculate optimal agent team for execution plan
478
- */
479
- private async calculateOptimalTeam(
480
- opportunities: ParallelizationOpportunity[],
481
- todos: TodoItem[],
482
- maxAgents: number
483
- ): Promise<AgentWorkload[]> {
484
- const team: AgentWorkload[] = [];
485
- const usedAgentTypes = new Set<AgentType>();
486
-
487
- for (const opportunity of opportunities) {
488
- for (const agentType of opportunity.suggestedAgents) {
489
- if (team.length >= maxAgents) break;
490
-
491
- // Avoid duplicate agent types unless it's load distribution
492
- if (usedAgentTypes.has(agentType) && opportunity.type !== 'load_distribution') {
493
- continue;
494
- }
495
-
496
- const workload: AgentWorkload = {
497
- agentId: 'new', // Will be assigned when spawned
498
- agentType,
499
- assignedTodos: opportunity.todos.filter(todoId =>
500
- this.todoRequiresAgentType(todoId, agentType, todos)
501
- ),
502
- estimatedDuration: this.estimateTodoDuration(opportunity.todos, todos),
503
- utilization: 0.8, // Start at 80% utilization
504
- capabilities: this.getAgentCapabilities(agentType),
505
- specializations: this.getAgentSpecializations(agentType, opportunity.type)
506
- };
507
-
508
- team.push(workload);
509
- usedAgentTypes.add(agentType);
510
- }
511
- }
512
-
513
- return team;
514
- }
515
-
516
- /**
517
- * Determine execution strategy based on opportunities and team
518
- */
519
- private determineExecutionStrategy(
520
- opportunities: ParallelizationOpportunity[],
521
- agentTeam: AgentWorkload[]
522
- ): 'wave_based' | 'concurrent' | 'pipeline' | 'hybrid' {
523
- const hasIndependent = opportunities.some(o => o.type === 'independent_tasks');
524
- const hasSpecialized = opportunities.some(o => o.type === 'specialized_breakdown');
525
- const hasLoadDistribution = opportunities.some(o => o.type === 'load_distribution');
526
-
527
- if (hasIndependent && hasSpecialized) {
528
- return 'hybrid'; // Mix of parallel and sequential
529
- } else if (hasLoadDistribution) {
530
- return 'concurrent'; // All agents work simultaneously
531
- } else if (hasSpecialized) {
532
- return 'pipeline'; // Sequential handoffs between specialists
533
- } else {
534
- return 'wave_based'; // Waves of parallel execution
535
- }
536
- }
537
-
538
- /**
539
- * Estimate completion time for agent team
540
- */
541
- private estimateCompletionTime(
542
- agentTeam: AgentWorkload[],
543
- strategy: 'wave_based' | 'concurrent' | 'pipeline' | 'hybrid'
544
- ): number {
545
- const coordinationOverhead = agentTeam.length * 2; // 2 minutes per agent for coordination
546
-
547
- switch (strategy) {
548
- case 'concurrent':
549
- return Math.max(...agentTeam.map(w => w.estimatedDuration)) + coordinationOverhead;
550
-
551
- case 'pipeline':
552
- return agentTeam.reduce((sum, w) => sum + w.estimatedDuration, 0) * 0.7 + coordinationOverhead;
553
-
554
- case 'wave_based':
555
- const avgDuration = agentTeam.reduce((sum, w) => sum + w.estimatedDuration, 0) / agentTeam.length;
556
- return avgDuration * 1.5 + coordinationOverhead;
557
-
558
- case 'hybrid':
559
- return agentTeam.reduce((sum, w) => sum + w.estimatedDuration, 0) * 0.6 + coordinationOverhead;
560
-
561
- default:
562
- return Math.max(...agentTeam.map(w => w.estimatedDuration)) + coordinationOverhead;
563
- }
564
- }
565
-
566
- /**
567
- * Set up coordination between parallel agents
568
- */
569
- private async setupParallelCoordination(
570
- plan: ParallelExecutionPlan,
571
- agents: Agent[]
572
- ): Promise<void> {
573
- // Store coordination plan in memory for agents to access
574
- await this.memory.store(`parallel_coordination_${plan.planId}`, {
575
- planId: plan.planId,
576
- strategy: plan.executionStrategy,
577
- agentTeam: plan.agentTeam,
578
- sharedContext: {
579
- objectiveId: plan.planId,
580
- coordinationMode: 'parallel',
581
- checkpoints: this.createCoordinationCheckpoints(plan),
582
- failureRecovery: plan.failureRecovery
583
- },
584
- timestamp: new Date().toISOString()
585
- });
586
-
587
- // Set up shared memory spaces for agent coordination
588
- for (let i = 0; i < agents.length; i++) {
589
- const agent = agents[i];
590
- const workload = plan.agentTeam[i];
591
-
592
- await this.memory.store(`agent_workload_${agent.id}`, {
593
- agentId: agent.id,
594
- assignedTodos: workload.assignedTodos,
595
- specializations: workload.specializations,
596
- coordinationKey: `parallel_coordination_${plan.planId}`,
597
- peerAgents: agents.filter(a => a.id !== agent.id).map(a => a.id),
598
- timestamp: new Date().toISOString()
599
- });
600
- }
601
- }
602
-
603
- /**
604
- * Utility methods
605
- */
606
-
607
- private areTasksIndependent(todo1: TodoItem, todo2: TodoItem): boolean {
608
- // Check if tasks have no direct dependencies
609
- const todo1Keywords = todo1.content.toLowerCase().split(' ');
610
- const todo2Keywords = todo2.content.toLowerCase().split(' ');
611
-
612
- // Tasks are independent if they don't share critical keywords
613
- const sharedCriticalKeywords = ['deploy', 'test', 'validate', 'create table', 'configure'].filter(keyword =>
614
- todo1.content.toLowerCase().includes(keyword) && todo2.content.toLowerCase().includes(keyword)
615
- );
616
-
617
- return sharedCriticalKeywords.length === 0;
618
- }
619
-
620
- private suggestAgentsForTodos(todoIds: string[], todos: TodoItem[]): AgentType[] {
621
- const agents: AgentType[] = [];
622
- const todoContents = todoIds.map(id => todos.find(t => t.id === id)?.content || '');
623
-
624
- for (const content of todoContents) {
625
- const agentType = this.inferBestAgentType(content);
626
- if (!agents.includes(agentType)) {
627
- agents.push(agentType);
628
- }
629
- }
630
-
631
- return agents;
632
- }
633
-
634
- private inferTodoCapability(todo: TodoItem): string {
635
- const content = todo.content.toLowerCase();
636
- if (content.includes('widget') || content.includes('template')) return 'widget_development';
637
- if (content.includes('flow') || content.includes('workflow')) return 'flow_creation';
638
- if (content.includes('script') || content.includes('code')) return 'scripting';
639
- if (content.includes('test') || content.includes('validate')) return 'testing';
640
- if (content.includes('deploy') || content.includes('configuration')) return 'deployment';
641
- return 'general_development';
642
- }
643
-
644
- private capabilityToAgentType(capability: string): AgentType {
645
- const mapping: { [key: string]: AgentType } = {
646
- 'widget_development': 'widget-creator',
647
- 'flow_creation': 'flow-builder',
648
- 'scripting': 'script-writer',
649
- 'testing': 'tester',
650
- 'deployment': 'app-architect',
651
- 'general_development': 'script-writer'
652
- };
653
-
654
- return mapping[capability] || 'script-writer';
655
- }
656
-
657
- private analyzeTodoCapabilities(todo: TodoItem): string[] {
658
- const content = todo.content.toLowerCase();
659
- const capabilities: string[] = [];
660
-
661
- if (content.includes('widget') || content.includes('ui')) capabilities.push('widget_development');
662
- if (content.includes('script') || content.includes('code')) capabilities.push('scripting');
663
- if (content.includes('flow') || content.includes('workflow')) capabilities.push('flow_creation');
664
- if (content.includes('test') || content.includes('validate')) capabilities.push('testing');
665
- if (content.includes('deploy') || content.includes('install')) capabilities.push('deployment');
666
- if (content.includes('integrate') || content.includes('api')) capabilities.push('integration');
667
-
668
- return capabilities.length > 0 ? capabilities : ['general_development'];
669
- }
670
-
671
- private todoRequiresAgentType(todoId: string, agentType: AgentType, todos: TodoItem[]): boolean {
672
- const todo = todos.find(t => t.id === todoId);
673
- if (!todo) return false;
674
-
675
- const requiredType = this.inferBestAgentType(todo.content);
676
- return requiredType === agentType;
677
- }
678
-
679
- private inferBestAgentType(content: string): AgentType {
680
- const lower = content.toLowerCase();
681
- if (lower.includes('widget') || lower.includes('template')) return 'widget-creator';
682
- if (lower.includes('flow') || lower.includes('workflow')) return 'flow-builder';
683
- if (lower.includes('script') || lower.includes('business rule')) return 'script-writer';
684
- if (lower.includes('test') || lower.includes('validate')) return 'tester';
685
- if (lower.includes('integrate') || lower.includes('api')) return 'integration-specialist';
686
- if (lower.includes('catalog') || lower.includes('item')) return 'catalog-manager';
687
- if (lower.includes('research') || lower.includes('analyze')) return 'researcher';
688
- return 'script-writer';
689
- }
690
-
691
- private estimateTodoDuration(todoIds: string[], todos: TodoItem[]): number {
692
- let totalDuration = 0;
693
-
694
- for (const todoId of todoIds) {
695
- const todo = todos.find(t => t.id === todoId);
696
- if (!todo) continue;
697
-
698
- // Estimate based on content complexity
699
- const words = todo.content.split(' ').length;
700
- const baseDuration = 15; // 15 minutes base
701
- const complexityMultiplier = todo.priority === 'high' ? 1.5 : 1.0;
702
-
703
- totalDuration += baseDuration + (words * 2) * complexityMultiplier;
704
- }
705
-
706
- return Math.max(10, totalDuration); // Minimum 10 minutes
707
- }
708
-
709
- private getAgentCapabilities(agentType: AgentType): string[] {
710
- const capabilityMap: { [key: string]: string[] } = {
711
- 'widget-creator': ['html_generation', 'css_styling', 'javascript_development'],
712
- 'flow-builder': ['flow_design', 'trigger_configuration', 'action_creation'],
713
- 'script-writer': ['glide_scripting', 'business_logic', 'error_handling'],
714
- 'app-architect': ['system_design', 'architecture_planning', 'integration'],
715
- 'integration-specialist': ['rest_api', 'soap_services', 'data_transformation'],
716
- 'catalog-manager': ['catalog_creation', 'variable_management', 'workflow_linking'],
717
- 'researcher': ['requirement__analysis', 'feasibility_study', 'solution_research'],
718
- 'tester': ['test_planning', 'test_execution', 'mock_data_creation']
719
- };
720
-
721
- return capabilityMap[agentType] || ['general_development'];
722
- }
723
-
724
- private getAgentSpecializations(agentType: AgentType, opportunityType: string): string[] {
725
- const specializationMap: { [key: string]: { [key: string]: string[] } } = {
726
- 'independent_tasks': {
727
- 'widget-creator': ['parallel_ui_development', 'component_isolation'],
728
- 'script-writer': ['parallel_scripting', 'independent_logic'],
729
- 'tester': ['parallel_testing', 'test_isolation']
730
- },
731
- 'specialized_breakdown': {
732
- 'widget-creator': ['ui_specialist', 'template_expert'],
733
- 'script-writer': ['logic_specialist', 'performance_expert'],
734
- 'flow-builder': ['workflow_specialist', 'integration_expert']
735
- },
736
- 'load_distribution': {
737
- 'widget-creator': ['high_throughput_ui', 'batch_processing'],
738
- 'script-writer': ['concurrent_scripting', 'load_handling'],
739
- 'tester': ['bulk_testing', 'parallel_validation']
740
- }
741
- };
742
-
743
- return specializationMap[opportunityType]?.[agentType] || ['general_specialist'];
744
- }
745
-
746
- private determineAgentSpecialization(workload: AgentWorkload): string {
747
- return workload.specializations[0] || 'general';
748
- }
749
-
750
- private createCoordinationCheckpoints(plan: ParallelExecutionPlan): string[] {
751
- return [
752
- 'initialization_complete',
753
- 'halfway_milestone',
754
- 'integration_ready',
755
- 'testing_phase',
756
- 'deployment_ready'
757
- ];
758
- }
759
-
760
- private async storeOpportunities(
761
- todos: TodoItem[],
762
- opportunities: ParallelizationOpportunity[]
763
- ): Promise<void> {
764
- await this.memory.store(`parallelization_analysis_${Date.now()}`, {
765
- todoCount: todos.length,
766
- opportunitiesFound: opportunities.length,
767
- opportunities: opportunities.map(opp => ({
768
- type: opp.type,
769
- confidence: opp.confidence,
770
- estimatedSpeedup: opp.estimatedSpeedup,
771
- agentCount: opp.suggestedAgents.length
772
- })),
773
- timestamp: new Date().toISOString()
774
- });
775
- }
776
-
777
- private setupLearningSystem(): void {
778
- this.on('parallel_execution_completed', async (data: {
779
- planId: string;
780
- actualSpeedup: number;
781
- success: boolean;
782
- }) => {
783
- // Store execution results for learning
784
- this.parallelizationHistory.set(data.planId, {
785
- success: data.success,
786
- speedup: data.actualSpeedup
787
- });
788
-
789
- await this.memory.store(`execution_result_${data.planId}`, {
790
- planId: data.planId,
791
- actualSpeedup: data.actualSpeedup,
792
- success: data.success,
793
- timestamp: new Date().toISOString()
794
- });
795
- });
796
- }
797
-
798
- private initializeCapabilityMap(): void {
799
- this.capabilityMap = {
800
- 'widget.*template': {
801
- primaryCapability: 'template_development',
802
- requiredAgentTypes: ['widget-creator'],
803
- parallelizable: true,
804
- estimatedDuration: 20,
805
- dependencies: []
806
- },
807
- 'server.*script': {
808
- primaryCapability: 'server_development',
809
- requiredAgentTypes: ['script-writer'],
810
- parallelizable: true,
811
- estimatedDuration: 25,
812
- dependencies: ['template_development']
813
- },
814
- 'client.*script': {
815
- primaryCapability: 'client_development',
816
- requiredAgentTypes: ['script-writer'],
817
- parallelizable: true,
818
- estimatedDuration: 20,
819
- dependencies: ['template_development']
820
- },
821
- 'css.*style': {
822
- primaryCapability: 'styling',
823
- requiredAgentTypes: ['widget-creator'],
824
- parallelizable: true,
825
- estimatedDuration: 15,
826
- dependencies: ['template_development']
827
- },
828
- 'test.*validate': {
829
- primaryCapability: 'testing',
830
- requiredAgentTypes: ['tester'],
831
- parallelizable: false,
832
- estimatedDuration: 30,
833
- dependencies: ['server_development', 'client_development', 'styling']
834
- },
835
- 'deploy': {
836
- primaryCapability: 'deployment',
837
- requiredAgentTypes: ['app-architect'],
838
- parallelizable: false,
839
- estimatedDuration: 10,
840
- dependencies: ['testing']
841
- }
842
- };
843
- }
844
-
845
- private generateId(prefix: string): string {
846
- return `${prefix}_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`;
847
- }
848
- }