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.
- package/{.claude/mcp-config.json ā .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- package/src/version.ts +0 -1950
package/src/snow-flow-system.ts
DELETED
|
@@ -1,541 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snow-Flow Main Integration Layer
|
|
3
|
-
* Coordinates all subsystems: Agents, Memory, MCPs, and ServiceNow
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { EventEmitter } from 'events';
|
|
7
|
-
import { SnowFlowConfig, ISnowFlowConfig } from './config/snow-flow-config';
|
|
8
|
-
import { ServiceNowQueen } from './queen/servicenow-queen';
|
|
9
|
-
import { MemorySystem } from './memory/memory-system';
|
|
10
|
-
import { MCPServerManager } from './utils/mcp-server-manager';
|
|
11
|
-
import { PerformanceTracker } from './monitoring/performance-tracker';
|
|
12
|
-
import { SystemHealth } from './health/system-health';
|
|
13
|
-
import { ErrorRecovery } from './utils/error-recovery';
|
|
14
|
-
import { Logger } from './utils/logger';
|
|
15
|
-
import Database from 'better-sqlite3';
|
|
16
|
-
import path from 'path';
|
|
17
|
-
import os from 'os';
|
|
18
|
-
|
|
19
|
-
export interface SwarmSession {
|
|
20
|
-
id: string;
|
|
21
|
-
objective: string;
|
|
22
|
-
startedAt: Date;
|
|
23
|
-
status: 'initializing' | 'active' | 'completing' | 'completed' | 'failed';
|
|
24
|
-
queenAgentId: string;
|
|
25
|
-
activeAgents: Map<string, AgentInfo>;
|
|
26
|
-
completedTasks: number;
|
|
27
|
-
totalTasks: number;
|
|
28
|
-
errors: Error[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface AgentInfo {
|
|
32
|
-
id: string;
|
|
33
|
-
type: string;
|
|
34
|
-
status: 'spawned' | 'active' | 'blocked' | 'completed' | 'failed';
|
|
35
|
-
assignedTasks: string[];
|
|
36
|
-
progress: number;
|
|
37
|
-
lastActivity: Date;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class SnowFlowSystem extends EventEmitter {
|
|
41
|
-
private config: SnowFlowConfig;
|
|
42
|
-
private queen?: ServiceNowQueen;
|
|
43
|
-
private memory?: MemorySystem;
|
|
44
|
-
private mcpManager?: MCPServerManager;
|
|
45
|
-
private performanceTracker?: PerformanceTracker;
|
|
46
|
-
private systemHealth?: SystemHealth;
|
|
47
|
-
private errorRecovery: ErrorRecovery;
|
|
48
|
-
private logger: Logger;
|
|
49
|
-
private sessions: Map<string, SwarmSession> = new Map();
|
|
50
|
-
private initialized = false;
|
|
51
|
-
|
|
52
|
-
constructor(config?: Partial<ISnowFlowConfig>) {
|
|
53
|
-
super();
|
|
54
|
-
this.config = new SnowFlowConfig(config);
|
|
55
|
-
this.logger = new Logger('SnowFlowSystem');
|
|
56
|
-
this.errorRecovery = new ErrorRecovery(this.logger);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Initialize the entire Snow-Flow system
|
|
61
|
-
*/
|
|
62
|
-
async initialize(): Promise<void> {
|
|
63
|
-
if (this.initialized) {
|
|
64
|
-
this.logger.info('System already initialized');
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
this.logger.info('Initializing Snow-Flow System...');
|
|
70
|
-
|
|
71
|
-
// 1. Initialize Memory System
|
|
72
|
-
await this.initializeMemory();
|
|
73
|
-
|
|
74
|
-
// 2. Initialize MCP Servers
|
|
75
|
-
await this.initializeMCPServers();
|
|
76
|
-
|
|
77
|
-
// 3. Initialize Queen Agent System
|
|
78
|
-
await this.initializeQueen();
|
|
79
|
-
|
|
80
|
-
// 4. Initialize Performance Tracking
|
|
81
|
-
await this.initializePerformanceTracking();
|
|
82
|
-
|
|
83
|
-
// 5. Initialize System Health Monitoring
|
|
84
|
-
await this.initializeHealthMonitoring();
|
|
85
|
-
|
|
86
|
-
this.initialized = true;
|
|
87
|
-
this.emit('system:initialized');
|
|
88
|
-
this.logger.info('Snow-Flow System initialized successfully');
|
|
89
|
-
|
|
90
|
-
} catch (error) {
|
|
91
|
-
this.logger.error('System initialization failed:', error);
|
|
92
|
-
await this.errorRecovery.handleCriticalError(error as Error, {
|
|
93
|
-
operation: 'system_initialization',
|
|
94
|
-
fallbackStrategies: ['retry_initialization', 'partial_initialization']
|
|
95
|
-
});
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Initialize Memory System with SQLite
|
|
102
|
-
*/
|
|
103
|
-
private async initializeMemory(): Promise<void> {
|
|
104
|
-
this.logger.info('Initializing Memory System...');
|
|
105
|
-
|
|
106
|
-
const dbPath = path.join(
|
|
107
|
-
os.homedir(),
|
|
108
|
-
'.snow-flow',
|
|
109
|
-
'memory',
|
|
110
|
-
'snow-flow.db'
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
this.memory = new MemorySystem({
|
|
114
|
-
dbPath,
|
|
115
|
-
schema: { version: '1.0.0', autoMigrate: true, ...(this.config.memory.schema || {}) },
|
|
116
|
-
ttl: { default: 86400000, session: 3600000, artifact: 86400000, metric: 3600000, ...(this.config.memory.ttl || {}) }
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
await this.memory.initialize();
|
|
120
|
-
this.emit('memory:initialized');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Initialize MCP Server Manager
|
|
125
|
-
*/
|
|
126
|
-
private async initializeMCPServers(): Promise<void> {
|
|
127
|
-
this.logger.info('Initializing MCP Servers...');
|
|
128
|
-
|
|
129
|
-
this.mcpManager = new MCPServerManager(JSON.stringify(this.config.mcp));
|
|
130
|
-
|
|
131
|
-
// Start all required MCP servers
|
|
132
|
-
const servers = [
|
|
133
|
-
'servicenow-deployment',
|
|
134
|
-
'servicenow-intelligent',
|
|
135
|
-
'servicenow-operations',
|
|
136
|
-
'servicenow-platform-development',
|
|
137
|
-
'servicenow-integration',
|
|
138
|
-
'servicenow-automation',
|
|
139
|
-
'servicenow-security-compliance',
|
|
140
|
-
'servicenow-reporting-analytics',
|
|
141
|
-
'servicenow-graph-memory',
|
|
142
|
-
'servicenow-update-set'
|
|
143
|
-
];
|
|
144
|
-
|
|
145
|
-
for (const server of servers) {
|
|
146
|
-
try {
|
|
147
|
-
await this.mcpManager.startServer(server);
|
|
148
|
-
this.logger.info(`Started MCP server: ${server}`);
|
|
149
|
-
} catch (error) {
|
|
150
|
-
this.logger.error(`Failed to start MCP server ${server}:`, error);
|
|
151
|
-
// Continue with other servers even if one fails
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
this.emit('mcp:initialized');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Initialize Queen Agent System
|
|
160
|
-
*/
|
|
161
|
-
private async initializeQueen(): Promise<void> {
|
|
162
|
-
this.logger.info('Initializing Queen Agent System...');
|
|
163
|
-
|
|
164
|
-
if (!this.memory || !this.mcpManager) {
|
|
165
|
-
throw new Error('Memory and MCP must be initialized before Queen');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.queen = new ServiceNowQueen({
|
|
169
|
-
memoryPath: this.config.memory?.dbPath,
|
|
170
|
-
maxConcurrentAgents: (this.config.agents?.queen as any)?.maxConcurrentAgents || 5,
|
|
171
|
-
learningRate: (this.config.agents?.queen as any)?.learningRate || 0.1,
|
|
172
|
-
debugMode: (this.config as any).debugMode || false,
|
|
173
|
-
autoPermissions: (this.config.agents?.queen as any)?.autoPermissions || false
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// ServiceNowQueen is ready to use after construction
|
|
177
|
-
// No initialize method or event handlers available
|
|
178
|
-
|
|
179
|
-
this.emit('queen:initialized');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Initialize Performance Tracking
|
|
184
|
-
*/
|
|
185
|
-
private async initializePerformanceTracking(): Promise<void> {
|
|
186
|
-
this.logger.info('Initializing Performance Tracking...');
|
|
187
|
-
|
|
188
|
-
if (!this.memory) {
|
|
189
|
-
throw new Error('Memory must be initialized before Performance Tracking');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
this.performanceTracker = new PerformanceTracker({
|
|
193
|
-
memory: this.memory,
|
|
194
|
-
config: { sampleRate: 100, metricsRetention: 86400000, aggregationInterval: 60000, ...(this.config.monitoring.performance || {}) }
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
await this.performanceTracker.initialize();
|
|
198
|
-
|
|
199
|
-
// Set up performance monitoring
|
|
200
|
-
this.performanceTracker.on('metric:recorded', (metric) => {
|
|
201
|
-
this.emit('performance:metric', metric);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
this.emit('performance:initialized');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Initialize System Health Monitoring
|
|
209
|
-
*/
|
|
210
|
-
private async initializeHealthMonitoring(): Promise<void> {
|
|
211
|
-
this.logger.info('Initializing System Health Monitoring...');
|
|
212
|
-
|
|
213
|
-
if (!this.memory || !this.mcpManager) {
|
|
214
|
-
throw new Error('Memory and MCP must be initialized before Health Monitoring');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
this.systemHealth = new SystemHealth({
|
|
218
|
-
memory: this.memory,
|
|
219
|
-
mcpManager: this.mcpManager,
|
|
220
|
-
config: {
|
|
221
|
-
checks: { memory: true, mcp: true, servicenow: true, queen: true },
|
|
222
|
-
thresholds: { memoryUsage: 85, responseTime: 5000, queueSize: 100, cpuUsage: 80, errorRate: 5 }
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
await this.systemHealth.initialize();
|
|
227
|
-
|
|
228
|
-
// Set up health monitoring
|
|
229
|
-
this.systemHealth.on('health:check', (status) => {
|
|
230
|
-
this.emit('health:status', status);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// Start periodic health checks
|
|
234
|
-
await this.systemHealth.startMonitoring();
|
|
235
|
-
|
|
236
|
-
this.emit('health:initialized');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Execute a swarm objective
|
|
241
|
-
*/
|
|
242
|
-
async executeSwarm(objective: string, options: SwarmOptions = {}): Promise<SwarmResult> {
|
|
243
|
-
if (!this.initialized) {
|
|
244
|
-
throw new Error('System not initialized. Call initialize() first.');
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const sessionId = this.generateSessionId();
|
|
248
|
-
const session: SwarmSession = {
|
|
249
|
-
id: sessionId,
|
|
250
|
-
objective,
|
|
251
|
-
startedAt: new Date(),
|
|
252
|
-
status: 'initializing',
|
|
253
|
-
queenAgentId: '',
|
|
254
|
-
activeAgents: new Map(),
|
|
255
|
-
completedTasks: 0,
|
|
256
|
-
totalTasks: 0,
|
|
257
|
-
errors: []
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
this.sessions.set(sessionId, session);
|
|
261
|
-
|
|
262
|
-
try {
|
|
263
|
-
// Track swarm execution
|
|
264
|
-
await this.performanceTracker?.startOperation('swarm_execution', {
|
|
265
|
-
sessionId,
|
|
266
|
-
objective
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// Execute objective using Queen's main method
|
|
270
|
-
const queenResult = await this.queen!.executeObjective(objective);
|
|
271
|
-
const _analysis = {
|
|
272
|
-
complexity: 0.5,
|
|
273
|
-
type: 'unknown',
|
|
274
|
-
estimatedDuration: 30000,
|
|
275
|
-
queenId: 'main-queen',
|
|
276
|
-
estimatedTasks: 1
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
session.queenAgentId = _analysis.queenId;
|
|
280
|
-
session.totalTasks = _analysis.estimatedTasks;
|
|
281
|
-
session.status = 'active';
|
|
282
|
-
|
|
283
|
-
// Execute swarm with Queen coordination (MCP-FIRST workflow)
|
|
284
|
-
console.log(`šØ SWARM EXECUTING WITH MCP-FIRST WORKFLOW`);
|
|
285
|
-
console.log(`šÆ Objective: ${objective}`);
|
|
286
|
-
|
|
287
|
-
const executionResult = await this.queen!.executeObjective(objective);
|
|
288
|
-
|
|
289
|
-
// Update session with swarm-specific progress tracking
|
|
290
|
-
session.completedTasks = 1; // Queen completed the objective
|
|
291
|
-
session.status = 'completed' as any;
|
|
292
|
-
this.emit('swarm:progress', {
|
|
293
|
-
sessionId,
|
|
294
|
-
progress: {
|
|
295
|
-
completed: 1,
|
|
296
|
-
total: 1,
|
|
297
|
-
status: 'completed',
|
|
298
|
-
mcpFirst: true,
|
|
299
|
-
realServiceNow: true
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
session.status = 'completed';
|
|
304
|
-
await this.performanceTracker?.endOperation('swarm_execution', {
|
|
305
|
-
success: true
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
return {
|
|
309
|
-
sessionId,
|
|
310
|
-
success: true,
|
|
311
|
-
artifacts: queenResult.artifacts || [],
|
|
312
|
-
summary: queenResult.deploymentResult || queenResult,
|
|
313
|
-
metrics: await this.performanceTracker?.getSessionMetrics(sessionId) || {}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
} catch (error) {
|
|
317
|
-
session.status = 'failed';
|
|
318
|
-
session.errors.push(error as Error);
|
|
319
|
-
|
|
320
|
-
await this.performanceTracker?.endOperation('swarm_execution', {
|
|
321
|
-
success: false,
|
|
322
|
-
error: (error as Error).message
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Attempt recovery
|
|
326
|
-
const recovery = await this.errorRecovery.attemptSwarmRecovery(sessionId, error as Error);
|
|
327
|
-
|
|
328
|
-
if (recovery.success) {
|
|
329
|
-
return recovery.result as SwarmResult;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
throw error;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Get system status
|
|
338
|
-
*/
|
|
339
|
-
async getStatus(): Promise<SystemStatus> {
|
|
340
|
-
if (!this.initialized) {
|
|
341
|
-
return {
|
|
342
|
-
initialized: false,
|
|
343
|
-
status: 'not_initialized',
|
|
344
|
-
components: {}
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const healthStatus = await this.systemHealth!.getFullStatus();
|
|
349
|
-
const activeSessions = Array.from(this.sessions.values())
|
|
350
|
-
.filter(s => s.status === 'active');
|
|
351
|
-
|
|
352
|
-
return {
|
|
353
|
-
initialized: true,
|
|
354
|
-
status: healthStatus.healthy ? 'healthy' : 'degraded',
|
|
355
|
-
components: {
|
|
356
|
-
memory: healthStatus.components.memory,
|
|
357
|
-
mcp: healthStatus.components.mcp,
|
|
358
|
-
queen: healthStatus.components.queen,
|
|
359
|
-
performance: healthStatus.components.performance
|
|
360
|
-
},
|
|
361
|
-
activeSessions: activeSessions.length,
|
|
362
|
-
metrics: {
|
|
363
|
-
totalSessions: this.sessions.size,
|
|
364
|
-
successRate: await this.calculateSuccessRate(),
|
|
365
|
-
averageExecutionTime: await this.calculateAverageExecutionTime()
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Shutdown the system gracefully
|
|
372
|
-
*/
|
|
373
|
-
async shutdown(): Promise<void> {
|
|
374
|
-
this.logger.info('Shutting down Snow-Flow System...');
|
|
375
|
-
|
|
376
|
-
try {
|
|
377
|
-
// Complete active sessions
|
|
378
|
-
for (const session of this.sessions.values()) {
|
|
379
|
-
if (session.status === 'active') {
|
|
380
|
-
await this.gracefullyCompleteSession(session.id);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// Shutdown components in reverse order
|
|
385
|
-
await this.systemHealth?.stopMonitoring();
|
|
386
|
-
await this.performanceTracker?.shutdown();
|
|
387
|
-
await this.queen?.shutdown();
|
|
388
|
-
// Use available shutdown method
|
|
389
|
-
if (this.mcpManager && typeof (this.mcpManager as any).shutdownAll === 'function') {
|
|
390
|
-
await (this.mcpManager as any).shutdownAll();
|
|
391
|
-
} else if (this.mcpManager && typeof (this.mcpManager as any).shutdown === 'function') {
|
|
392
|
-
await (this.mcpManager as any).shutdown();
|
|
393
|
-
}
|
|
394
|
-
await this.memory?.close();
|
|
395
|
-
|
|
396
|
-
this.initialized = false;
|
|
397
|
-
this.emit('system:shutdown');
|
|
398
|
-
this.logger.info('Snow-Flow System shutdown complete');
|
|
399
|
-
|
|
400
|
-
} catch (error) {
|
|
401
|
-
this.logger.error('Error during shutdown:', error);
|
|
402
|
-
throw error;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Get session information
|
|
408
|
-
*/
|
|
409
|
-
getSession(sessionId: string): SwarmSession | undefined {
|
|
410
|
-
return this.sessions.get(sessionId);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* List all sessions
|
|
415
|
-
*/
|
|
416
|
-
listSessions(filter?: { status?: string }): SwarmSession[] {
|
|
417
|
-
const sessions = Array.from(this.sessions.values());
|
|
418
|
-
|
|
419
|
-
if (filter?.status) {
|
|
420
|
-
return sessions.filter(s => s.status === filter.status);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return sessions;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Get memory system instance
|
|
428
|
-
*/
|
|
429
|
-
getMemory(): MemorySystem | undefined {
|
|
430
|
-
return this.memory;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Get MCP manager instance
|
|
435
|
-
*/
|
|
436
|
-
getMCPManager(): MCPServerManager | undefined {
|
|
437
|
-
return this.mcpManager;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Private helper methods
|
|
442
|
-
*/
|
|
443
|
-
private generateSessionId(): string {
|
|
444
|
-
return `swarm_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
private updateAgentInfo(session: SwarmSession, update: any): void {
|
|
448
|
-
const agent = session.activeAgents.get(update.agentId) || {
|
|
449
|
-
id: update.agentId,
|
|
450
|
-
type: update.agentType,
|
|
451
|
-
status: 'spawned',
|
|
452
|
-
assignedTasks: [],
|
|
453
|
-
progress: 0,
|
|
454
|
-
lastActivity: new Date()
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
Object.assign(agent, update);
|
|
458
|
-
session.activeAgents.set(update.agentId, agent);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
private async gracefullyCompleteSession(sessionId: string): Promise<void> {
|
|
462
|
-
const session = this.sessions.get(sessionId);
|
|
463
|
-
if (!session) return;
|
|
464
|
-
|
|
465
|
-
this.logger.info(`Gracefully completing session ${sessionId}`);
|
|
466
|
-
|
|
467
|
-
// Notify all active agents to wrap up
|
|
468
|
-
for (const agent of session.activeAgents.values()) {
|
|
469
|
-
if (agent.status === 'active') {
|
|
470
|
-
// Use available shutdown method
|
|
471
|
-
// await this.queen?.shutdown(); // No per-agent shutdown available
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// Wait for agents to complete (max 30 seconds)
|
|
476
|
-
const timeout = setTimeout(() => {
|
|
477
|
-
session.status = 'completed';
|
|
478
|
-
}, 30000);
|
|
479
|
-
|
|
480
|
-
while (session.status === 'active') {
|
|
481
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
482
|
-
|
|
483
|
-
const activeAgents = Array.from(session.activeAgents.values())
|
|
484
|
-
.filter(a => a.status === 'active');
|
|
485
|
-
|
|
486
|
-
if (activeAgents.length === 0) {
|
|
487
|
-
session.status = 'completed';
|
|
488
|
-
clearTimeout(timeout);
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
private async calculateSuccessRate(): Promise<number> {
|
|
495
|
-
const sessions = Array.from(this.sessions.values());
|
|
496
|
-
const completed = sessions.filter(s => s.status === 'completed').length;
|
|
497
|
-
const total = sessions.filter(s => ['completed', 'failed'].includes(s.status)).length;
|
|
498
|
-
|
|
499
|
-
return total > 0 ? (completed / total) * 100 : 0;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
private async calculateAverageExecutionTime(): Promise<number> {
|
|
503
|
-
const metrics = await this.performanceTracker?.getAggregateMetrics('swarm_execution');
|
|
504
|
-
return metrics?.averageDuration || 0;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Type definitions
|
|
509
|
-
export interface SwarmOptions {
|
|
510
|
-
strategy?: 'research' | 'development' | '_analysis' | 'testing' | 'optimization' | 'maintenance';
|
|
511
|
-
mode?: 'centralized' | 'distributed' | 'hierarchical' | 'mesh' | 'hybrid';
|
|
512
|
-
maxAgents?: number;
|
|
513
|
-
parallel?: boolean;
|
|
514
|
-
monitor?: boolean;
|
|
515
|
-
autoPermissions?: boolean;
|
|
516
|
-
smartDiscovery?: boolean;
|
|
517
|
-
liveTesting?: boolean;
|
|
518
|
-
autoDeploy?: boolean;
|
|
519
|
-
autoRollback?: boolean;
|
|
520
|
-
sharedMemory?: boolean;
|
|
521
|
-
progressMonitoring?: boolean;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
export interface SwarmResult {
|
|
525
|
-
sessionId: string;
|
|
526
|
-
success: boolean;
|
|
527
|
-
artifacts: any[];
|
|
528
|
-
summary: string;
|
|
529
|
-
metrics: any;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
export interface SystemStatus {
|
|
533
|
-
initialized: boolean;
|
|
534
|
-
status: string;
|
|
535
|
-
components: Record<string, any>;
|
|
536
|
-
activeSessions?: number;
|
|
537
|
-
metrics?: any;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// Export singleton instance
|
|
541
|
-
export const snowFlowSystem = new SnowFlowSystem();
|
package/src/sparc/sparc-help.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SPARC Help System - Provides guidance to working functionality
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export function displayTeamHelp(): void {
|
|
6
|
-
console.log(`
|
|
7
|
-
šÆ SPARC Team Development - Available Now!
|
|
8
|
-
|
|
9
|
-
The SPARC team functionality you're looking for is available through the SWARM system:
|
|
10
|
-
|
|
11
|
-
š” INSTEAD OF SPARC COMMANDS, USE:
|
|
12
|
-
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
13
|
-
ā ā
WORKING ALTERNATIVES (Use These!) ā
|
|
14
|
-
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
15
|
-
ā snow-flow swarm "create incident dashboard widget" ā
|
|
16
|
-
ā snow-flow swarm "build approval workflow for equipment" ā
|
|
17
|
-
ā snow-flow swarm "develop mobile app with authentication" ā
|
|
18
|
-
ā snow-flow queen "create ServiceNow integration" ā
|
|
19
|
-
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
20
|
-
|
|
21
|
-
š SWARM FEATURES (What you get automatically):
|
|
22
|
-
⢠š§ Multi-Agent Coordination: Automatic spawning of specialized agents
|
|
23
|
-
⢠šÆ Smart Discovery: Finds existing artifacts to prevent duplication
|
|
24
|
-
⢠š Live Testing: Real-time testing on your ServiceNow instance
|
|
25
|
-
⢠š Update Set Management: Automatic change tracking
|
|
26
|
-
⢠š Auto-Deployment: Direct deployment to ServiceNow when ready
|
|
27
|
-
⢠š”ļø Error Recovery: Automatic rollback on failures
|
|
28
|
-
|
|
29
|
-
š§ SWARM OPTIONS:
|
|
30
|
-
⢠--strategy: research, development, _analysis, testing, optimization
|
|
31
|
-
⢠--mode: centralized, distributed, hierarchical, mesh, hybrid
|
|
32
|
-
⢠--max-agents: Control team size (default: 5)
|
|
33
|
-
⢠--parallel: Enable parallel execution
|
|
34
|
-
⢠--monitor: Real-time progress monitoring
|
|
35
|
-
|
|
36
|
-
š EXAMPLES:
|
|
37
|
-
⢠Widget Team: snow-flow swarm "create dashboard with charts" --strategy development
|
|
38
|
-
⢠Flow Team: snow-flow swarm "approval workflow with notifications" --mode hierarchical
|
|
39
|
-
⢠Full App: snow-flow swarm "mobile ITSM solution" --max-agents 8 --monitor
|
|
40
|
-
|
|
41
|
-
šÆ GET STARTED:
|
|
42
|
-
1. snow-flow auth login # Authenticate with ServiceNow
|
|
43
|
-
2. snow-flow swarm "your objective" # Everything else is automatic!
|
|
44
|
-
3. snow-flow status # Check system health
|
|
45
|
-
|
|
46
|
-
The swarm system provides all the team coordination, specialist roles, and
|
|
47
|
-
quality gates that SPARC was designed to deliver - and it's working now!
|
|
48
|
-
`);
|
|
49
|
-
}
|
package/src/sparc/team-sparc.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SPARC Team Executor - Redirects to Working Functionality
|
|
3
|
-
* Provides helpful guidance to users who try SPARC commands
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class TeamSparcExecutor {
|
|
7
|
-
static async execute(teamType: string, task: string, options: any = {}): Promise<any> {
|
|
8
|
-
console.log(`\nšÆ SPARC Team: ${teamType.toUpperCase()}`);
|
|
9
|
-
console.log(`š Task: ${task}\n`);
|
|
10
|
-
|
|
11
|
-
// Determine the best swarm strategy based on team type
|
|
12
|
-
const strategyMap: Record<string, string> = {
|
|
13
|
-
'widget': 'development',
|
|
14
|
-
'flow': 'development',
|
|
15
|
-
'app': 'development',
|
|
16
|
-
'application': 'development',
|
|
17
|
-
'adaptive': '_analysis'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const strategy = strategyMap[teamType.toLowerCase()] || 'development';
|
|
21
|
-
const swarmCommand = `snow-flow swarm "${task}"${strategy !== 'development' ? ` --strategy ${strategy}` : ''}${options.parallel ? ' --parallel' : ''}${options.monitor ? ' --monitor' : ''}`;
|
|
22
|
-
|
|
23
|
-
console.log(`ā
SPARC Team functionality is available through the SWARM system!\n`);
|
|
24
|
-
console.log(`š Run this command instead:\n`);
|
|
25
|
-
console.log(` ${swarmCommand}\n`);
|
|
26
|
-
console.log(`š” The SWARM system provides:`);
|
|
27
|
-
console.log(` ⢠Multi-agent team coordination (what SPARC was designed for)`);
|
|
28
|
-
console.log(` ⢠Specialist role assignment automatically`);
|
|
29
|
-
console.log(` ⢠Real-time progress monitoring`);
|
|
30
|
-
console.log(` ⢠Direct ServiceNow integration\n`);
|
|
31
|
-
console.log(`š For more options: snow-flow swarm --help`);
|
|
32
|
-
console.log(`š For detailed help: snow-flow sparc-help\n`);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
success: true,
|
|
36
|
-
message: 'SPARC functionality redirected to working SWARM system',
|
|
37
|
-
teamType,
|
|
38
|
-
task,
|
|
39
|
-
options,
|
|
40
|
-
recommendedCommand: swarmCommand,
|
|
41
|
-
redirectedTo: 'swarm'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static async executeSpecialist(specialistType: string, task: string, options: any = {}): Promise<any> {
|
|
46
|
-
console.log(`\nšØāš» SPARC ${specialistType.toUpperCase()} Specialist`);
|
|
47
|
-
console.log(`š Task: ${task}\n`);
|
|
48
|
-
|
|
49
|
-
// Map specialist types to swarm strategies
|
|
50
|
-
const specialistStrategyMap: Record<string, string> = {
|
|
51
|
-
'frontend': 'development',
|
|
52
|
-
'backend': 'development',
|
|
53
|
-
'security': '_analysis',
|
|
54
|
-
'database': 'development',
|
|
55
|
-
'process': 'development',
|
|
56
|
-
'trigger': 'development',
|
|
57
|
-
'data': '_analysis',
|
|
58
|
-
'logic': 'development',
|
|
59
|
-
'interface': 'development',
|
|
60
|
-
'uiux': 'development',
|
|
61
|
-
'platform': 'development'
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const strategy = specialistStrategyMap[specialistType.toLowerCase()] || 'development';
|
|
65
|
-
const swarmCommand = `snow-flow swarm "${task}" --strategy ${strategy}${options.monitor ? ' --monitor' : ''}${options.dryRun ? ' --dry-run' : ''}`;
|
|
66
|
-
|
|
67
|
-
console.log(`ā
SPARC Specialist functionality is available through the SWARM system!\n`);
|
|
68
|
-
console.log(`š Run this command instead:\n`);
|
|
69
|
-
console.log(` ${swarmCommand}\n`);
|
|
70
|
-
console.log(`š” The SWARM system automatically:`);
|
|
71
|
-
console.log(` ⢠Spawns ${specialistType} specialists when needed`);
|
|
72
|
-
console.log(` ⢠Coordinates with other specialists automatically`);
|
|
73
|
-
console.log(` ⢠Provides real-time progress monitoring`);
|
|
74
|
-
console.log(` ⢠Integrates directly with ServiceNow\n`);
|
|
75
|
-
console.log(`š For more options: snow-flow swarm --help`);
|
|
76
|
-
console.log(`š For detailed help: snow-flow sparc-help\n`);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
success: true,
|
|
80
|
-
message: 'SPARC specialist functionality redirected to working SWARM system',
|
|
81
|
-
specialistType,
|
|
82
|
-
task,
|
|
83
|
-
options,
|
|
84
|
-
recommendedCommand: swarmCommand,
|
|
85
|
-
redirectedTo: 'swarm'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|