snow-flow 2.0.4 → 2.0.6

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 (74) hide show
  1. package/dist/config/snow-flow-config.d.ts +1492 -0
  2. package/dist/config/snow-flow-config.js +938 -0
  3. package/dist/coordination/coordination-engine.d.ts +41 -0
  4. package/dist/coordination/coordination-engine.js +324 -0
  5. package/dist/coordination/coordination.test.d.ts +6 -0
  6. package/dist/coordination/example.d.ts +31 -0
  7. package/dist/coordination/example.js +394 -0
  8. package/dist/coordination/execution-patterns.d.ts +43 -0
  9. package/dist/coordination/execution-patterns.js +507 -0
  10. package/dist/coordination/factory.d.ts +94 -0
  11. package/dist/coordination/factory.js +433 -0
  12. package/dist/coordination/index.d.ts +71 -0
  13. package/dist/coordination/index.js +135 -0
  14. package/dist/coordination/progress-monitor.d.ts +71 -0
  15. package/dist/coordination/progress-monitor.js +505 -0
  16. package/dist/coordination/quality-gates.d.ts +124 -0
  17. package/dist/coordination/quality-gates.js +577 -0
  18. package/dist/coordination/shared-memory.d.ts +39 -0
  19. package/dist/coordination/shared-memory.js +289 -0
  20. package/dist/coordination/task-dependencies.d.ts +50 -0
  21. package/dist/coordination/task-dependencies.js +407 -0
  22. package/dist/coordination/team-coordinator.d.ts +59 -0
  23. package/dist/coordination/team-coordinator.js +550 -0
  24. package/dist/coordination/types.d.ts +152 -0
  25. package/dist/coordination/types.js +3 -0
  26. package/dist/memory/hierarchical-memory-system.d.ts +90 -0
  27. package/dist/memory/hierarchical-memory-system.js +400 -0
  28. package/dist/memory/index.d.ts +9 -0
  29. package/dist/memory/index.js +20 -0
  30. package/dist/memory/mcp-integration-example.d.ts +6 -0
  31. package/dist/memory/mcp-integration-example.js +281 -0
  32. package/dist/memory/memory-client.d.ts +199 -0
  33. package/dist/memory/memory-client.js +364 -0
  34. package/dist/memory/memory-manager.d.ts +29 -0
  35. package/dist/memory/memory-manager.js +280 -0
  36. package/dist/memory/memory-operations.d.ts +179 -0
  37. package/dist/memory/memory-operations.js +691 -0
  38. package/dist/memory/memory-system.d.ts +152 -0
  39. package/dist/memory/memory-system.js +632 -0
  40. package/dist/memory/memory-test.d.ts +6 -0
  41. package/dist/memory/memory-test.js +161 -0
  42. package/dist/memory/servicenow-artifact-indexer.d.ts +119 -0
  43. package/dist/memory/servicenow-artifact-indexer.js +560 -0
  44. package/dist/memory/snow-flow-memory-patterns.d.ts +213 -0
  45. package/dist/memory/snow-flow-memory-patterns.js +200 -0
  46. package/dist/memory/snow-memory.d.ts +54 -0
  47. package/dist/memory/snow-memory.js +301 -0
  48. package/dist/memory/swarm-memory.d.ts +135 -0
  49. package/dist/memory/swarm-memory.js +378 -0
  50. package/memory/claude-flow-data.json +5 -0
  51. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
  52. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
  53. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
  54. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
  55. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
  56. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
  57. package/memory/sessions/README.md +32 -0
  58. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
  59. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
  60. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
  61. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
  62. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
  63. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
  64. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
  65. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
  66. package/package.json +1 -1
  67. package/reports/swarm-auto-centralized-1752649029776.json +13 -0
  68. package/scripts/postinstall.js +30 -0
  69. package/scripts/update-version.js +31 -0
  70. package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
  71. package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
  72. package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
  73. package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
  74. package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskDependencyGraph = void 0;
4
+ const eventemitter3_1 = require("eventemitter3");
5
+ const logger_1 = require("../utils/logger");
6
+ class TaskDependencyGraph extends eventemitter3_1.EventEmitter {
7
+ constructor(sharedMemory, config) {
8
+ super();
9
+ this.nodes = new Map();
10
+ this.edges = new Map();
11
+ this.reverseEdges = new Map();
12
+ this.sharedMemory = sharedMemory;
13
+ this.config = config;
14
+ logger_1.logger.info('📊 Task Dependency Graph initialized');
15
+ }
16
+ addTask(taskId, agent, requirements, dependencies = []) {
17
+ try {
18
+ // Create task node
19
+ const node = {
20
+ id: taskId,
21
+ agent,
22
+ requirements,
23
+ status: 'pending',
24
+ result: null,
25
+ retryCount: 0
26
+ };
27
+ this.nodes.set(taskId, node);
28
+ this.edges.set(taskId, new Set(dependencies));
29
+ // Build reverse dependency graph for efficient querying
30
+ for (const dep of dependencies) {
31
+ if (!this.reverseEdges.has(dep)) {
32
+ this.reverseEdges.set(dep, new Set());
33
+ }
34
+ this.reverseEdges.get(dep).add(taskId);
35
+ }
36
+ logger_1.logger.debug('📝 Added task to dependency graph', {
37
+ taskId,
38
+ agentId: agent?.id,
39
+ dependencies: dependencies.length
40
+ });
41
+ this.emit('task:added', { taskId, dependencies });
42
+ }
43
+ catch (error) {
44
+ logger_1.logger.error('❌ Failed to add task to dependency graph', { taskId, error: error.message });
45
+ throw error;
46
+ }
47
+ }
48
+ async getReadyTasks() {
49
+ const ready = [];
50
+ for (const [taskId, node] of this.nodes) {
51
+ if (node.status === 'pending' && await this.areDependenciesComplete(taskId)) {
52
+ ready.push(node);
53
+ }
54
+ }
55
+ return ready;
56
+ }
57
+ async areDependenciesComplete(taskId) {
58
+ const dependencies = this.edges.get(taskId) || new Set();
59
+ for (const depId of dependencies) {
60
+ const depNode = this.nodes.get(depId);
61
+ if (!depNode || depNode.status !== 'completed') {
62
+ return false;
63
+ }
64
+ }
65
+ return true;
66
+ }
67
+ async executeTask(taskId) {
68
+ const node = this.nodes.get(taskId);
69
+ if (!node) {
70
+ throw new Error(`Task not found: ${taskId}`);
71
+ }
72
+ // Check if already executing or completed
73
+ if (node.status === 'in_progress' || node.status === 'completed') {
74
+ return node.result;
75
+ }
76
+ try {
77
+ logger_1.logger.info('🚀 Executing task', { taskId, agentId: node.agent?.id });
78
+ node.status = 'in_progress';
79
+ node.startTime = new Date();
80
+ this.emit('task:started', { taskId, agentId: node.agent?.id });
81
+ // Store task status in shared memory
82
+ await this.sharedMemory.store(`task_status_${taskId}`, {
83
+ status: 'in_progress',
84
+ startTime: node.startTime,
85
+ agentId: node.agent?.id
86
+ });
87
+ // Get dependency results
88
+ const dependencyResults = await this.getDependencyResults(taskId);
89
+ // Execute the task through the agent
90
+ const result = await this.executeTaskWithRetry(node, dependencyResults);
91
+ // Update node
92
+ node.status = 'completed';
93
+ node.result = result;
94
+ node.endTime = new Date();
95
+ // Store result in shared memory
96
+ await this.sharedMemory.store(`task_result_${taskId}`, result);
97
+ await this.sharedMemory.store(`task_status_${taskId}`, {
98
+ status: 'completed',
99
+ endTime: node.endTime,
100
+ duration: node.endTime.getTime() - node.startTime.getTime()
101
+ });
102
+ logger_1.logger.info('✅ Task completed successfully', {
103
+ taskId,
104
+ duration: node.endTime.getTime() - node.startTime.getTime()
105
+ });
106
+ this.emit('task:completed', { taskId, result });
107
+ return result;
108
+ }
109
+ catch (error) {
110
+ node.status = 'failed';
111
+ node.error = error;
112
+ node.endTime = new Date();
113
+ // Store error in shared memory
114
+ await this.sharedMemory.store(`task_error_${taskId}`, {
115
+ error: error.message,
116
+ timestamp: node.endTime
117
+ });
118
+ logger_1.logger.error('❌ Task execution failed', {
119
+ taskId,
120
+ error: error.message,
121
+ retryCount: node.retryCount
122
+ });
123
+ this.emit('task:failed', { taskId, error });
124
+ // Handle error recovery
125
+ if (this.config.enableRetries && node.retryCount < this.config.maxRetries) {
126
+ await this.scheduleRetry(taskId);
127
+ }
128
+ else {
129
+ await this.handleTaskFailure(taskId, error);
130
+ }
131
+ throw error;
132
+ }
133
+ }
134
+ async executeTaskWithRetry(node, dependencyResults) {
135
+ const maxRetries = this.config.enableRetries ? this.config.maxRetries : 0;
136
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
137
+ try {
138
+ if (attempt > 0) {
139
+ logger_1.logger.info('🔄 Retrying task execution', {
140
+ taskId: node.id,
141
+ attempt: attempt + 1,
142
+ maxRetries: maxRetries + 1
143
+ });
144
+ }
145
+ // Execute task through agent
146
+ const result = await this.executeAgentTask(node, dependencyResults);
147
+ return result;
148
+ }
149
+ catch (error) {
150
+ node.retryCount = attempt + 1;
151
+ if (attempt < maxRetries) {
152
+ // Wait before retry with exponential backoff
153
+ const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
154
+ await new Promise(resolve => setTimeout(resolve, delay));
155
+ }
156
+ else {
157
+ throw error;
158
+ }
159
+ }
160
+ }
161
+ }
162
+ async executeAgentTask(node, dependencyResults) {
163
+ // This would be the interface to the actual agent execution
164
+ // For now, we'll simulate agent task execution
165
+ if (!node.agent) {
166
+ throw new Error(`No agent assigned to task: ${node.id}`);
167
+ }
168
+ // Prepare task context
169
+ const taskContext = {
170
+ taskId: node.id,
171
+ requirements: node.requirements,
172
+ dependencies: dependencyResults,
173
+ sharedMemory: this.sharedMemory
174
+ };
175
+ // Simulate task execution (in real implementation, this would call the agent)
176
+ // TODO: Replace with actual agent task execution interface
177
+ return await this.simulateAgentExecution(node, taskContext);
178
+ }
179
+ async simulateAgentExecution(node, context) {
180
+ // Simulation of agent task execution
181
+ // In real implementation, this would interface with the actual agent system
182
+ const delay = Math.random() * 2000 + 1000; // 1-3 seconds
183
+ await new Promise(resolve => setTimeout(resolve, delay));
184
+ return {
185
+ taskId: node.id,
186
+ agentId: node.agent?.id,
187
+ outputs: node.requirements.outputs,
188
+ executionTime: delay,
189
+ timestamp: new Date()
190
+ };
191
+ }
192
+ async scheduleRetry(taskId) {
193
+ const node = this.nodes.get(taskId);
194
+ if (!node)
195
+ return;
196
+ node.status = 'pending';
197
+ logger_1.logger.info('⏰ Scheduled task retry', { taskId, retryCount: node.retryCount });
198
+ this.emit('task:retry_scheduled', { taskId, retryCount: node.retryCount });
199
+ }
200
+ async handleTaskFailure(taskId, error) {
201
+ logger_1.logger.error('💥 Task failed permanently', { taskId, error: error.message });
202
+ switch (this.config.errorRecoveryStrategy) {
203
+ case 'abort':
204
+ this.emit('graph:abort_requested', { failedTask: taskId, error });
205
+ break;
206
+ case 'continue':
207
+ // Mark dependent tasks as skipped
208
+ await this.markDependentTasksAsSkipped(taskId);
209
+ break;
210
+ case 'retry':
211
+ // Already handled in executeTaskWithRetry
212
+ break;
213
+ }
214
+ }
215
+ async markDependentTasksAsSkipped(failedTaskId) {
216
+ const dependents = this.reverseEdges.get(failedTaskId) || new Set();
217
+ for (const dependentId of dependents) {
218
+ const dependentNode = this.nodes.get(dependentId);
219
+ if (dependentNode && dependentNode.status === 'pending') {
220
+ dependentNode.status = 'cancelled';
221
+ logger_1.logger.warn('⏭️ Skipped dependent task due to failure', {
222
+ taskId: dependentId,
223
+ failedDependency: failedTaskId
224
+ });
225
+ // Recursively skip dependents
226
+ await this.markDependentTasksAsSkipped(dependentId);
227
+ }
228
+ }
229
+ }
230
+ async getDependencyResults(taskId) {
231
+ const dependencies = this.edges.get(taskId) || new Set();
232
+ const results = {};
233
+ for (const depId of dependencies) {
234
+ const depNode = this.nodes.get(depId);
235
+ if (depNode && depNode.status === 'completed') {
236
+ results[depId] = depNode.result;
237
+ }
238
+ }
239
+ return results;
240
+ }
241
+ async topologicalSort() {
242
+ const levels = [];
243
+ const visited = new Set();
244
+ const inDegree = new Map();
245
+ // Calculate in-degrees
246
+ for (const [taskId] of this.nodes) {
247
+ inDegree.set(taskId, (this.edges.get(taskId) || new Set()).size);
248
+ }
249
+ while (visited.size < this.nodes.size) {
250
+ const currentLevel = [];
251
+ // Find tasks with no dependencies
252
+ for (const [taskId] of this.nodes) {
253
+ if (!visited.has(taskId) && inDegree.get(taskId) === 0) {
254
+ currentLevel.push(taskId);
255
+ }
256
+ }
257
+ if (currentLevel.length === 0) {
258
+ const remaining = Array.from(this.nodes.keys()).filter(id => !visited.has(id));
259
+ throw new Error(`Circular dependency detected among tasks: ${remaining.join(', ')}`);
260
+ }
261
+ levels.push(currentLevel);
262
+ // Update in-degrees and mark as visited
263
+ for (const taskId of currentLevel) {
264
+ visited.add(taskId);
265
+ const dependents = this.reverseEdges.get(taskId) || new Set();
266
+ for (const dependent of dependents) {
267
+ const currentInDegree = inDegree.get(dependent) || 0;
268
+ inDegree.set(dependent, currentInDegree - 1);
269
+ }
270
+ }
271
+ }
272
+ return levels;
273
+ }
274
+ async validateGraph() {
275
+ try {
276
+ // Check for circular dependencies
277
+ await this.topologicalSort();
278
+ // Check that all dependencies exist
279
+ for (const [taskId, dependencies] of this.edges) {
280
+ for (const depId of dependencies) {
281
+ if (!this.nodes.has(depId)) {
282
+ throw new Error(`Task ${taskId} depends on non-existent task: ${depId}`);
283
+ }
284
+ }
285
+ }
286
+ logger_1.logger.info('✅ Task dependency graph validation passed');
287
+ }
288
+ catch (error) {
289
+ logger_1.logger.error('❌ Task dependency graph validation failed', { error: error.message });
290
+ throw error;
291
+ }
292
+ }
293
+ async generateExecutionPlan() {
294
+ const levels = await this.topologicalSort();
295
+ const phases = [];
296
+ for (let i = 0; i < levels.length; i++) {
297
+ const level = levels[i];
298
+ phases.push({
299
+ id: `phase_${i}`,
300
+ type: level.length > 1 ? 'parallel' : 'sequential',
301
+ tasks: level,
302
+ estimatedDuration: this.estimatePhaseDuration(level),
303
+ dependencies: i > 0 ? [`phase_${i - 1}`] : []
304
+ });
305
+ }
306
+ const criticalPath = this.findCriticalPath();
307
+ const parallelizationOpportunities = this.findParallelizationOpportunities(levels);
308
+ return {
309
+ phases,
310
+ totalEstimatedTime: phases.reduce((sum, phase) => sum + phase.estimatedDuration, 0),
311
+ criticalPath,
312
+ parallelizationOpportunities
313
+ };
314
+ }
315
+ estimatePhaseDuration(tasks) {
316
+ // Simple estimation - in practice this would be more sophisticated
317
+ return Math.max(...tasks.map(taskId => {
318
+ const node = this.nodes.get(taskId);
319
+ return node?.requirements.constraints?.find(c => c.type === 'time')?.value || 60000; // Default 1 minute
320
+ }));
321
+ }
322
+ findCriticalPath() {
323
+ // Simplified critical path calculation
324
+ // In practice, this would use more sophisticated algorithms
325
+ const levels = this.getTopologicalLevels();
326
+ return levels.flat();
327
+ }
328
+ getTopologicalLevels() {
329
+ try {
330
+ return this.topologicalSort();
331
+ }
332
+ catch {
333
+ return [];
334
+ }
335
+ }
336
+ findParallelizationOpportunities(levels) {
337
+ const opportunities = [];
338
+ for (const level of levels) {
339
+ if (level.length > 1) {
340
+ opportunities.push({
341
+ tasks: level,
342
+ estimatedSavings: (level.length - 1) * this.estimatePhaseDuration(level),
343
+ riskLevel: level.length > 3 ? 'high' : level.length > 1 ? 'medium' : 'low'
344
+ });
345
+ }
346
+ }
347
+ return opportunities;
348
+ }
349
+ // Query methods
350
+ getTotalTasks() {
351
+ return this.nodes.size;
352
+ }
353
+ getCompletedTasks() {
354
+ return Array.from(this.nodes.values()).filter(node => node.status === 'completed');
355
+ }
356
+ getFailedTasks() {
357
+ return Array.from(this.nodes.values()).filter(node => node.status === 'failed');
358
+ }
359
+ getInProgressTasks() {
360
+ return Array.from(this.nodes.values()).filter(node => node.status === 'in_progress');
361
+ }
362
+ getPendingTasks() {
363
+ return Array.from(this.nodes.values()).filter(node => node.status === 'pending');
364
+ }
365
+ getTask(taskId) {
366
+ return this.nodes.get(taskId);
367
+ }
368
+ getMaxParallelism() {
369
+ try {
370
+ const levels = this.getTopologicalLevels();
371
+ return Math.max(...levels.map(level => level.length));
372
+ }
373
+ catch {
374
+ return 1;
375
+ }
376
+ }
377
+ getComplexityScore() {
378
+ const totalTasks = this.getTotalTasks();
379
+ const totalDependencies = Array.from(this.edges.values())
380
+ .reduce((sum, deps) => sum + deps.size, 0);
381
+ // Complexity score between 0 and 1
382
+ return totalTasks > 0 ? Math.min(totalDependencies / (totalTasks * totalTasks), 1) : 0;
383
+ }
384
+ async getExecutionStats() {
385
+ const total = this.getTotalTasks();
386
+ const completed = this.getCompletedTasks();
387
+ const failed = this.getFailedTasks();
388
+ const inProgress = this.getInProgressTasks();
389
+ return {
390
+ totalTasks: total,
391
+ completedTasks: completed.length,
392
+ failedTasks: failed.length,
393
+ inProgressTasks: inProgress.length,
394
+ averageExecutionTime: completed.length > 0
395
+ ? completed.reduce((sum, task) => {
396
+ const duration = task.endTime && task.startTime
397
+ ? task.endTime.getTime() - task.startTime.getTime()
398
+ : 0;
399
+ return sum + duration;
400
+ }, 0) / completed.length
401
+ : 0,
402
+ totalRetries: Array.from(this.nodes.values()).reduce((sum, node) => sum + node.retryCount, 0)
403
+ };
404
+ }
405
+ }
406
+ exports.TaskDependencyGraph = TaskDependencyGraph;
407
+ //# sourceMappingURL=task-dependencies.js.map
@@ -0,0 +1,59 @@
1
+ import { TeamOptions } from '../teams/base-team.js';
2
+ export interface CoordinationOptions extends TeamOptions {
3
+ preferTeams?: boolean;
4
+ maxComplexity?: 'simple' | 'moderate' | 'complex';
5
+ timeConstraint?: string;
6
+ qualityLevel?: 'quick' | 'standard' | 'comprehensive';
7
+ }
8
+ export interface TaskAnalysis {
9
+ domain: string;
10
+ complexity: 'simple' | 'moderate' | 'complex';
11
+ scope: 'focused' | 'medium' | 'broad';
12
+ timeEstimate: string;
13
+ recommendedApproach: 'individual' | 'team' | 'adaptive';
14
+ confidence: number;
15
+ reasoning: string[];
16
+ }
17
+ export interface ExecutionResult {
18
+ approach: string;
19
+ executor: string;
20
+ result: any;
21
+ executionTime: number;
22
+ qualityMetrics: any;
23
+ recommendations: string[];
24
+ }
25
+ export declare class TeamCoordinator {
26
+ private options;
27
+ private taskHistory;
28
+ private performanceMetrics;
29
+ constructor(options?: CoordinationOptions);
30
+ coordinate(task: string): Promise<ExecutionResult>;
31
+ private analyzeTask;
32
+ private identifyDomain;
33
+ private assessComplexity;
34
+ private assessScope;
35
+ private estimateTime;
36
+ private determineOptimalApproach;
37
+ private shouldUseIndividualSpecialist;
38
+ private shouldUseSpecializedTeam;
39
+ private selectIndividualSpecialist;
40
+ private selectSpecializedTeam;
41
+ private executeWithIndividualSpecialist;
42
+ private logAnalysis;
43
+ private calculateExecutionQuality;
44
+ private assessCompleteness;
45
+ private assessAccuracy;
46
+ private assessEfficiency;
47
+ private parseTimeToMs;
48
+ private assessMaintainability;
49
+ private assessScalability;
50
+ private generateRecommendations;
51
+ private updatePerformanceMetrics;
52
+ getTaskHistory(): Map<string, TaskAnalysis>;
53
+ getPerformanceMetrics(): Map<string, any>;
54
+ getCoordinatorInsights(): any;
55
+ private getMostUsedApproach;
56
+ private getAverageConfidence;
57
+ private getCoordinatorRecommendations;
58
+ }
59
+ //# sourceMappingURL=team-coordinator.d.ts.map