snow-flow 3.0.9 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-flow.bat +0 -0
- package/claude-flow.ps1 +0 -0
- package/dist/mcp/intelligent-reporting-mcp.d.ts +7 -0
- package/dist/mcp/intelligent-reporting-mcp.js +379 -0
- package/dist/mcp/servicenow-automation-mcp.js +0 -0
- package/dist/mcp/servicenow-deployment-mcp.js +0 -0
- package/dist/mcp/servicenow-integration-mcp.js +0 -0
- package/dist/mcp/servicenow-mcp-server.js +0 -0
- package/dist/mcp/servicenow-operations-mcp.js +0 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
- package/dist/mcp/servicenow-progressive-indexer.js +0 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +280 -29
- package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
- package/dist/mcp/servicenow-update-set-mcp.js +0 -0
- package/dist/mcp/start-all-mcp-servers.js +0 -0
- package/dist/mcp/start-servicenow-mcp.js +0 -0
- package/dist/services/widget-deployment-service.d.ts +2 -1
- package/dist/services/widget-deployment-service.js +17 -16
- package/dist/utils/anti-mock-data-validator.d.ts +66 -0
- package/dist/utils/anti-mock-data-validator.js +316 -0
- package/dist/utils/servicenow-eventual-consistency.d.ts +120 -0
- package/dist/utils/servicenow-eventual-consistency.js +220 -0
- package/memory/agents/README.md +1 -1
- package/memory/claude-flow-data.json +1 -1
- package/memory/sessions/README.md +1 -1
- package/package.json +4 -3
- package/.mcp.json +0 -22
- package/claude-flow.config.json +0 -20
- package/dist/agents/app-creator.agent.d.ts +0 -55
- package/dist/agents/app-creator.agent.js +0 -1292
- package/dist/agents/base/base-snow-agent.d.ts +0 -75
- package/dist/agents/base/base-snow-agent.js +0 -169
- package/dist/agents/base-snow-agent.d.ts +0 -63
- package/dist/agents/base-snow-agent.js +0 -296
- package/dist/agents/coordinator.d.ts +0 -200
- package/dist/agents/coordinator.js +0 -777
- package/dist/agents/flow-builder-agent.d.ts +0 -18
- package/dist/agents/flow-builder-agent.js +0 -197
- package/dist/agents/queen-403-handler.d.ts +0 -47
- package/dist/agents/queen-403-handler.js +0 -175
- package/dist/agents/queen-agent-example.d.ts +0 -23
- package/dist/agents/queen-agent-example.js +0 -240
- package/dist/agents/queen-agent.test.d.ts +0 -6
- package/dist/agents/script-generator.agent.d.ts +0 -32
- package/dist/agents/script-generator.agent.js +0 -772
- package/dist/agents/script-writer-agent.d.ts +0 -22
- package/dist/agents/script-writer-agent.js +0 -695
- package/dist/agents/security-agent.d.ts +0 -23
- package/dist/agents/security-agent.js +0 -619
- package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
- package/dist/agents/specialists/automation-specialist.agent.js +0 -204
- package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
- package/dist/agents/specialists/data-specialist.agent.js +0 -484
- package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
- package/dist/agents/specialists/integration-specialist.agent.js +0 -725
- package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
- package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
- package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
- package/dist/agents/specialists/security-specialist.agent.js +0 -309
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
- package/dist/agents/teams/base-team.d.ts +0 -72
- package/dist/agents/teams/base-team.js +0 -253
- package/dist/agents/teams/team-types.d.ts +0 -265
- package/dist/agents/teams/team-types.js +0 -3
- package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
- package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
- package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
- package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
- package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
- package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
- package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
- package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
- package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
- package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
- package/dist/agents/test-agent.d.ts +0 -26
- package/dist/agents/test-agent.js +0 -734
- package/dist/agents/test-agents.d.ts +0 -7
- package/dist/agents/test-agents.js +0 -64
- package/dist/agents/ui-builder.agent.d.ts +0 -50
- package/dist/agents/ui-builder.agent.js +0 -1539
- package/dist/agents/widget-builder.agent.d.ts +0 -32
- package/dist/agents/widget-builder.agent.js +0 -439
- package/dist/agents/widget-creator-agent.d.ts +0 -18
- package/dist/agents/widget-creator-agent.js +0 -498
- package/dist/agents/workflow-designer.agent.d.ts +0 -31
- package/dist/agents/workflow-designer.agent.js +0 -583
- package/dist/api/error-handling.d.ts +0 -325
- package/dist/api/error-handling.js +0 -1488
- package/dist/api/flow-designer-api.d.ts +0 -167
- package/dist/api/flow-designer-api.js +0 -554
- package/dist/api/natural-language-mapper.d.ts +0 -124
- package/dist/api/natural-language-mapper.js +0 -501
- package/dist/api/performance-optimizer.d.ts +0 -240
- package/dist/api/performance-optimizer.js +0 -706
- package/dist/api/transaction-manager.d.ts +0 -189
- package/dist/api/transaction-manager.js +0 -576
- package/dist/assembly/team-assembler.d.ts +0 -140
- package/dist/assembly/team-assembler.js +0 -502
- package/dist/benchmark-performance.d.ts +0 -41
- package/dist/benchmark-performance.js +0 -230
- package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
- package/dist/cli/snow-flow-cli-integration.js +0 -396
- package/dist/coordination/coordination-engine.d.ts +0 -41
- package/dist/coordination/coordination-engine.js +0 -324
- package/dist/coordination/coordination.test.d.ts +0 -6
- package/dist/coordination/example.d.ts +0 -31
- package/dist/coordination/example.js +0 -394
- package/dist/coordination/execution-patterns.d.ts +0 -43
- package/dist/coordination/execution-patterns.js +0 -507
- package/dist/coordination/factory.d.ts +0 -94
- package/dist/coordination/factory.js +0 -433
- package/dist/coordination/index.d.ts +0 -71
- package/dist/coordination/index.js +0 -135
- package/dist/coordination/progress-monitor.d.ts +0 -71
- package/dist/coordination/progress-monitor.js +0 -505
- package/dist/coordination/quality-gates.d.ts +0 -124
- package/dist/coordination/quality-gates.js +0 -577
- package/dist/coordination/shared-memory.d.ts +0 -39
- package/dist/coordination/shared-memory.js +0 -289
- package/dist/coordination/task-dependencies.d.ts +0 -50
- package/dist/coordination/task-dependencies.js +0 -407
- package/dist/coordination/team-coordinator.d.ts +0 -59
- package/dist/coordination/team-coordinator.js +0 -550
- package/dist/coordination/types.d.ts +0 -152
- package/dist/coordination/types.js +0 -3
- package/dist/mcp/mcp-wrapper.d.ts +0 -8
- package/dist/mcp/mcp-wrapper.js +0 -77
- package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
- package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
- package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
- package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
- package/dist/mcp/singleton-check.js +0 -31
- package/dist/mcp/test-simple-mcp.d.ts +0 -6
- package/dist/mcp/test-simple-mcp.js +0 -63
- package/dist/memory/hierarchical-memory-system.d.ts +0 -90
- package/dist/memory/hierarchical-memory-system.js +0 -400
- package/dist/memory/index.d.ts +0 -9
- package/dist/memory/index.js +0 -20
- package/dist/memory/mcp-integration-example.d.ts +0 -6
- package/dist/memory/mcp-integration-example.js +0 -281
- package/dist/memory/memory-client.d.ts +0 -199
- package/dist/memory/memory-client.js +0 -364
- package/dist/memory/memory-manager.d.ts +0 -29
- package/dist/memory/memory-manager.js +0 -280
- package/dist/memory/memory-operations.d.ts +0 -179
- package/dist/memory/memory-operations.js +0 -691
- package/dist/memory/memory-system.d.ts +0 -153
- package/dist/memory/memory-system.js +0 -651
- package/dist/memory/memory-test.d.ts +0 -6
- package/dist/memory/memory-test.js +0 -161
- package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
- package/dist/memory/snow-flow-memory-patterns.js +0 -200
- package/dist/memory/snow-memory.d.ts +0 -54
- package/dist/memory/snow-memory.js +0 -301
- package/dist/memory/swarm-memory.d.ts +0 -135
- package/dist/memory/swarm-memory.js +0 -378
- package/dist/optimization/flow-performance-optimizer.js +0 -723
- package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
- package/dist/orchestration/discovery/service-discovery.js +0 -808
- package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
- package/dist/orchestration/distributed-orchestrator.js +0 -712
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
- package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
- package/dist/orchestration/flow-update-orchestrator.js +0 -648
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
- package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
- package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
- package/dist/orchestration/state/distributed-state-manager.js +0 -716
- package/dist/orchestrator/flow-composer.d.ts +0 -105
- package/dist/orchestrator/flow-composer.js +0 -404
- package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
- package/dist/orchestrator/flow-pattern-templates.js +0 -908
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
- package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
- package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
- package/dist/orchestrator/flow-validation-engine.js +0 -913
- package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
- package/dist/orchestrator/snow-orchestrator.js +0 -235
- package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
- package/dist/orchestrator/subflow-creation-handler.js +0 -791
- package/dist/patterns/adaptive-patterns.d.ts +0 -140
- package/dist/patterns/adaptive-patterns.js +0 -549
- package/dist/queen/advanced-integration-test.d.ts +0 -48
- package/dist/queen/advanced-integration-test.js +0 -473
- package/dist/queen/integration-example.d.ts +0 -82
- package/dist/queen/integration-example.js +0 -219
- package/dist/queen/integration-test.d.ts +0 -72
- package/dist/queen/integration-test.js +0 -563
- package/dist/queen/mock-mcp-client.d.ts +0 -71
- package/dist/queen/mock-mcp-client.js +0 -317
- package/dist/queen/run-integration-tests.d.ts +0 -9
- package/dist/queen/run-integration-tests.js +0 -27
- package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
- package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
- package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
- package/dist/sparc/coordinators/team-coordinator.js +0 -402
- package/dist/sparc/modes/team-modes.d.ts +0 -33
- package/dist/sparc/modes/team-modes.js +0 -399
- package/dist/sparc/teams/application-team.d.ts +0 -73
- package/dist/sparc/teams/application-team.js +0 -463
- package/dist/sparc/teams/flow-team.d.ts +0 -67
- package/dist/sparc/teams/flow-team.js +0 -373
- package/dist/sparc/teams/widget-team.d.ts +0 -61
- package/dist/sparc/teams/widget-team.js +0 -280
- package/dist/specialists/app-specialists.d.ts +0 -93
- package/dist/specialists/app-specialists.js +0 -1639
- package/dist/specialists/base-specialist.d.ts +0 -19
- package/dist/specialists/base-specialist.js +0 -54
- package/dist/specialists/flow-specialists.d.ts +0 -113
- package/dist/specialists/flow-specialists.js +0 -1787
- package/dist/specialists/individual-specialists.d.ts +0 -67
- package/dist/specialists/individual-specialists.js +0 -632
- package/dist/specialists/widget-specialists.d.ts +0 -70
- package/dist/specialists/widget-specialists.js +0 -1264
- package/dist/src/utils/agent-detector.js +0 -655
- package/dist/teams/adaptive-team.d.ts +0 -81
- package/dist/teams/adaptive-team.js +0 -1153
- package/dist/teams/application-team.d.ts +0 -30
- package/dist/teams/application-team.js +0 -547
- package/dist/teams/base-team.d.ts +0 -55
- package/dist/teams/base-team.js +0 -243
- package/dist/teams/flow-team.d.ts +0 -28
- package/dist/teams/flow-team.js +0 -525
- package/dist/teams/widget-team.d.ts +0 -26
- package/dist/teams/widget-team.js +0 -459
- package/dist/templates/flow-template-system.js +0 -625
- package/dist/test-fetch-incidents.d.ts +0 -2
- package/dist/test-fetch-incidents.js +0 -84
- package/dist/test-incident-access.d.ts +0 -2
- package/dist/test-incident-access.js +0 -72
- package/dist/test-iphone-flow.js +0 -189
- package/dist/test-limit-problem.d.ts +0 -2
- package/dist/test-limit-problem.js +0 -60
- package/dist/test-ml-batch-fix.d.ts +0 -2
- package/dist/test-ml-batch-fix.js +0 -104
- package/dist/test-ml-batch.d.ts +0 -2
- package/dist/test-ml-batch.js +0 -87
- package/dist/test-ml-query.d.ts +0 -2
- package/dist/test-ml-query.js +0 -100
- package/dist/test-ml-training-fix.d.ts +0 -12
- package/dist/test-ml-training-fix.js +0 -113
- package/dist/test-ml-training.d.ts +0 -2
- package/dist/test-ml-training.js +0 -32
- package/dist/test-operations-query.d.ts +0 -2
- package/dist/test-operations-query.js +0 -84
- package/dist/test-performance-query.d.ts +0 -2
- package/dist/test-performance-query.js +0 -52
- package/dist/test-singleton-protection.d.ts +0 -8
- package/dist/test-singleton-protection.js +0 -110
- package/dist/test-smart-limits.d.ts +0 -13
- package/dist/test-smart-limits.js +0 -100
- package/dist/test-snow-query-incidents.d.ts +0 -2
- package/dist/test-snow-query-incidents.js +0 -66
- package/dist/test-universal-query.d.ts +0 -2
- package/dist/test-universal-query.js +0 -106
- package/dist/testing/flow-testing-automation.js +0 -641
- package/dist/utils/complete-flow-xml-generator.js +0 -1285
- package/dist/utils/file-storage-fallback.d.ts +0 -62
- package/dist/utils/file-storage-fallback.js +0 -289
- package/dist/utils/flow-api-discovery.d.ts +0 -151
- package/dist/utils/flow-api-discovery.js +0 -439
- package/dist/utils/flow-examples.js +0 -720
- package/dist/utils/flow-structure-builder.js +0 -677
- package/dist/utils/flow-xml-generator.d.ts +0 -41
- package/dist/utils/flow-xml-generator.js +0 -258
- package/dist/utils/improved-flow-xml-generator.js +0 -820
- package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
- package/dist/utils/mcp-process-manager.backup.js +0 -220
- package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
- package/dist/utils/mcp-singleton-enforcer.js +0 -201
- package/dist/utils/mcp-timeout-fix.d.ts +0 -53
- package/dist/utils/mcp-timeout-fix.js +0 -221
- package/dist/utils/migrate-claude-flow.d.ts +0 -22
- package/dist/utils/migrate-claude-flow.js +0 -120
- package/dist/utils/scope-utils.d.ts +0 -72
- package/dist/utils/scope-utils.js +0 -386
- package/dist/utils/snow-oauth-old.d.ts +0 -65
- package/dist/utils/snow-oauth-old.js +0 -345
- package/dist/utils/xml-first-flow-generator.js +0 -513
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
- package/reports/swarm-auto-centralized-1752649029776.json +0 -13
- package/src/memory/README.md +0 -240
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MCPX (Model Context Protocol eXtended) Implementation
|
|
4
|
-
*
|
|
5
|
-
* Extends MCP with orchestration capabilities for distributed agent coordination
|
|
6
|
-
*/
|
|
7
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.MCPXProtocol = void 0;
|
|
12
|
-
const events_1 = require("events");
|
|
13
|
-
const ws_1 = __importDefault(require("ws"));
|
|
14
|
-
const distributed_orchestration_interface_js_1 = require("../interfaces/distributed-orchestration.interface.js");
|
|
15
|
-
const logger_js_1 = require("../../utils/logger.js");
|
|
16
|
-
class MCPXProtocol extends events_1.EventEmitter {
|
|
17
|
-
constructor(orchestrator, securityConfig) {
|
|
18
|
-
super();
|
|
19
|
-
this.orchestrator = orchestrator;
|
|
20
|
-
this.securityConfig = securityConfig;
|
|
21
|
-
this.connections = new Map();
|
|
22
|
-
this.messageHandlers = new Map();
|
|
23
|
-
this.responseCallbacks = new Map();
|
|
24
|
-
this.securityManager = new SecurityManager(securityConfig);
|
|
25
|
-
this.messageRouter = new MessageRouter();
|
|
26
|
-
this.setupMessageHandlers();
|
|
27
|
-
}
|
|
28
|
-
// ========================================
|
|
29
|
-
// Connection Management
|
|
30
|
-
// ========================================
|
|
31
|
-
async establishConnection(agent) {
|
|
32
|
-
logger_js_1.logger.info(`🔗 Establishing MCPX connection to agent: ${agent.id}`, { endpoint: agent.endpoint });
|
|
33
|
-
try {
|
|
34
|
-
// Create WebSocket connection
|
|
35
|
-
const ws = new ws_1.default(agent.endpoint + '/mcpx', {
|
|
36
|
-
headers: await this.securityManager.getAuthHeaders(agent)
|
|
37
|
-
});
|
|
38
|
-
// Setup connection handling
|
|
39
|
-
const connection = new Connection(agent.id, ws, this);
|
|
40
|
-
await this.setupConnection(connection);
|
|
41
|
-
// Protocol negotiation
|
|
42
|
-
const negotiationResult = await this.negotiateProtocol(connection);
|
|
43
|
-
if (!negotiationResult.success) {
|
|
44
|
-
throw new Error(`Protocol negotiation failed: ${negotiationResult.error}`);
|
|
45
|
-
}
|
|
46
|
-
this.connections.set(agent.id, ws);
|
|
47
|
-
this.emit('connection:established', { agentId: agent.id, connection });
|
|
48
|
-
logger_js_1.logger.info(`✅ MCPX connection established to agent: ${agent.id}`);
|
|
49
|
-
return connection;
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
logger_js_1.logger.error(`❌ Failed to establish connection to agent: ${agent.id}`, { error: error.message });
|
|
53
|
-
throw new MCPXConnectionError(`Connection failed: ${error.message}`, agent.id);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async maintainConnection(connection) {
|
|
57
|
-
const heartbeatInterval = setInterval(async () => {
|
|
58
|
-
try {
|
|
59
|
-
await this.sendHeartbeat(connection);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
logger_js_1.logger.warn(`💓 Heartbeat failed for connection: ${connection.agentId}`, { error: error.message });
|
|
63
|
-
clearInterval(heartbeatInterval);
|
|
64
|
-
await this.handleConnectionFailure(connection);
|
|
65
|
-
}
|
|
66
|
-
}, 30000); // 30 second heartbeat
|
|
67
|
-
connection.on('close', () => {
|
|
68
|
-
clearInterval(heartbeatInterval);
|
|
69
|
-
this.connections.delete(connection.agentId);
|
|
70
|
-
this.emit('connection:closed', { agentId: connection.agentId });
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async closeConnection(connectionId) {
|
|
74
|
-
const connection = this.connections.get(connectionId);
|
|
75
|
-
if (connection) {
|
|
76
|
-
connection.close();
|
|
77
|
-
this.connections.delete(connectionId);
|
|
78
|
-
logger_js_1.logger.info(`🔌 Closed connection to agent: ${connectionId}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// ========================================
|
|
82
|
-
// Protocol Negotiation
|
|
83
|
-
// ========================================
|
|
84
|
-
async negotiateProtocol(connection) {
|
|
85
|
-
const negotiationMessage = {
|
|
86
|
-
jsonrpc: '2.0',
|
|
87
|
-
id: this.generateMessageId(),
|
|
88
|
-
method: 'mcpx.negotiate',
|
|
89
|
-
params: {
|
|
90
|
-
version: '1.0',
|
|
91
|
-
capabilities: this.getSupportedCapabilities(),
|
|
92
|
-
extensions: ['orchestration', 'coordination', 'distribution']
|
|
93
|
-
},
|
|
94
|
-
timestamp: Date.now(),
|
|
95
|
-
source: this.orchestrator.getInstanceId(),
|
|
96
|
-
priority: 'high'
|
|
97
|
-
};
|
|
98
|
-
try {
|
|
99
|
-
const response = await this.sendMessage(connection, negotiationMessage, 10000);
|
|
100
|
-
if (response.success && response.result) {
|
|
101
|
-
const remoteCapabilities = response.result.capabilities;
|
|
102
|
-
const commonCapabilities = this.findCommonCapabilities(this.getSupportedCapabilities(), remoteCapabilities);
|
|
103
|
-
connection.setNegotiatedCapabilities(commonCapabilities);
|
|
104
|
-
return {
|
|
105
|
-
success: true,
|
|
106
|
-
version: response.result.version,
|
|
107
|
-
capabilities: commonCapabilities
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return {
|
|
112
|
-
success: false,
|
|
113
|
-
error: response.error?.message || 'Unknown negotiation error'
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
return {
|
|
119
|
-
success: false,
|
|
120
|
-
error: `Negotiation timeout or error: ${error.message}`
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// ========================================
|
|
125
|
-
// Message Handling
|
|
126
|
-
// ========================================
|
|
127
|
-
async sendOrchestrationCommand(targetInstance, command, payload, timeout = 30000) {
|
|
128
|
-
const connection = this.connections.get(targetInstance);
|
|
129
|
-
if (!connection) {
|
|
130
|
-
throw new MCPXConnectionError(`No connection to agent: ${targetInstance}`, targetInstance);
|
|
131
|
-
}
|
|
132
|
-
const message = {
|
|
133
|
-
jsonrpc: '2.0',
|
|
134
|
-
id: this.generateMessageId(),
|
|
135
|
-
method: command,
|
|
136
|
-
params: payload,
|
|
137
|
-
orchestration: this.getCurrentOrchestrationContext(),
|
|
138
|
-
timestamp: Date.now(),
|
|
139
|
-
source: this.orchestrator.getInstanceId(),
|
|
140
|
-
target: targetInstance,
|
|
141
|
-
priority: 'normal'
|
|
142
|
-
};
|
|
143
|
-
try {
|
|
144
|
-
const response = await this.sendMessageWithTimeout(connection, message, timeout);
|
|
145
|
-
this.logCommandExecution(command, targetInstance, payload, response);
|
|
146
|
-
return response;
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
logger_js_1.logger.error(`❌ MCPX command failed: ${command}`, {
|
|
150
|
-
target: targetInstance,
|
|
151
|
-
error: error.message
|
|
152
|
-
});
|
|
153
|
-
throw new MCPXCommandError(command, targetInstance, error.message);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async broadcastCommand(instances, command, payload, timeout = 30000) {
|
|
157
|
-
logger_js_1.logger.info(`📡 Broadcasting MCPX command: ${command}`, {
|
|
158
|
-
instances: instances.length,
|
|
159
|
-
command
|
|
160
|
-
});
|
|
161
|
-
const promises = instances.map(async (instanceId) => {
|
|
162
|
-
try {
|
|
163
|
-
const response = await this.sendOrchestrationCommand(instanceId, command, payload, timeout);
|
|
164
|
-
return { instanceId, response };
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
logger_js_1.logger.warn(`⚠️ Broadcast failed for instance: ${instanceId}`, { error: error.message });
|
|
168
|
-
return {
|
|
169
|
-
instanceId,
|
|
170
|
-
response: {
|
|
171
|
-
success: false,
|
|
172
|
-
error: {
|
|
173
|
-
code: 'BROADCAST_FAILED',
|
|
174
|
-
message: error.message,
|
|
175
|
-
retryable: true
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const results = await Promise.allSettled(promises);
|
|
182
|
-
const responseMap = new Map();
|
|
183
|
-
results.forEach((result, index) => {
|
|
184
|
-
if (result.status === 'fulfilled') {
|
|
185
|
-
responseMap.set(result.value.instanceId, result.value.response);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
responseMap.set(instances[index], {
|
|
189
|
-
success: false,
|
|
190
|
-
error: {
|
|
191
|
-
code: 'PROMISE_REJECTED',
|
|
192
|
-
message: result.reason?.message || 'Unknown error',
|
|
193
|
-
retryable: false
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
const successCount = Array.from(responseMap.values()).filter(r => r.success).length;
|
|
199
|
-
logger_js_1.logger.info(`📡 Broadcast completed: ${successCount}/${instances.length} successful`);
|
|
200
|
-
return responseMap;
|
|
201
|
-
}
|
|
202
|
-
async handleMCPXMessage(message, connection) {
|
|
203
|
-
try {
|
|
204
|
-
// Security validation
|
|
205
|
-
const securityCheck = await this.securityManager.validateMessage(message, connection);
|
|
206
|
-
if (!securityCheck.valid) {
|
|
207
|
-
throw new MCPXSecurityError(`Security validation failed: ${securityCheck.reason}`);
|
|
208
|
-
}
|
|
209
|
-
// Route message to appropriate handler
|
|
210
|
-
const handler = this.messageHandlers.get(message.method);
|
|
211
|
-
if (!handler) {
|
|
212
|
-
throw new distributed_orchestration_interface_js_1.MCPXError(`Unknown command: ${message.method}`, 'UNKNOWN_COMMAND', true);
|
|
213
|
-
}
|
|
214
|
-
// Execute handler with context
|
|
215
|
-
const context = this.createExecutionContext(message, connection);
|
|
216
|
-
const result = await handler.handle(message.params, context);
|
|
217
|
-
return {
|
|
218
|
-
success: true,
|
|
219
|
-
result,
|
|
220
|
-
metadata: {
|
|
221
|
-
processingTime: Date.now() - message.timestamp,
|
|
222
|
-
instanceId: this.orchestrator.getInstanceId(),
|
|
223
|
-
resourceUsage: await this.getResourceUsage()
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
logger_js_1.logger.error(`❌ MCPX message handling failed`, {
|
|
229
|
-
method: message.method,
|
|
230
|
-
error: error.message
|
|
231
|
-
});
|
|
232
|
-
return {
|
|
233
|
-
success: false,
|
|
234
|
-
error: {
|
|
235
|
-
code: error.code || 'HANDLER_ERROR',
|
|
236
|
-
message: error.message,
|
|
237
|
-
retryable: error.retryable || false
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
// ========================================
|
|
243
|
-
// Protocol Translation
|
|
244
|
-
// ========================================
|
|
245
|
-
translateMCPToMCPX(mcpMessage, context) {
|
|
246
|
-
return {
|
|
247
|
-
...mcpMessage,
|
|
248
|
-
orchestration: context,
|
|
249
|
-
timestamp: Date.now(),
|
|
250
|
-
source: this.orchestrator.getInstanceId(),
|
|
251
|
-
priority: 'normal'
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
translateMCPXToMCP(mcpxMessage) {
|
|
255
|
-
const { orchestration, coordination, distribution, timestamp, source, target, priority, ...mcpMessage } = mcpxMessage;
|
|
256
|
-
return mcpMessage;
|
|
257
|
-
}
|
|
258
|
-
// ========================================
|
|
259
|
-
// Message Handlers Setup
|
|
260
|
-
// ========================================
|
|
261
|
-
setupMessageHandlers() {
|
|
262
|
-
// Orchestration handlers
|
|
263
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.ORCHESTRATE_SESSION_START, new SessionStartHandler(this.orchestrator));
|
|
264
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.ORCHESTRATE_TASK_ASSIGN, new TaskAssignHandler(this.orchestrator));
|
|
265
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.ORCHESTRATE_TASK_COMPLETE, new TaskCompleteHandler(this.orchestrator));
|
|
266
|
-
// Coordination handlers
|
|
267
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.COORDINATE_STATE_SYNC, new StateSyncHandler(this.orchestrator));
|
|
268
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.COORDINATE_DEPENDENCY_RESOLVE, new DependencyResolveHandler(this.orchestrator));
|
|
269
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.COORDINATE_QUALITY_GATE, new QualityGateHandler(this.orchestrator));
|
|
270
|
-
// Distribution handlers
|
|
271
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.DISTRIBUTE_TASK_SPLIT, new TaskSplitHandler(this.orchestrator));
|
|
272
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.DISTRIBUTE_RESULT_MERGE, new ResultMergeHandler(this.orchestrator));
|
|
273
|
-
// Health & monitoring handlers
|
|
274
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.HEALTH_CHECK, new HealthCheckHandler(this.orchestrator));
|
|
275
|
-
this.messageHandlers.set(distributed_orchestration_interface_js_1.MCPXCommand.METRICS_REPORT, new MetricsReportHandler(this.orchestrator));
|
|
276
|
-
}
|
|
277
|
-
// ========================================
|
|
278
|
-
// Utility Methods
|
|
279
|
-
// ========================================
|
|
280
|
-
generateMessageId() {
|
|
281
|
-
return `mcpx_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
282
|
-
}
|
|
283
|
-
getSupportedCapabilities() {
|
|
284
|
-
return [
|
|
285
|
-
'orchestration.session_management',
|
|
286
|
-
'orchestration.task_assignment',
|
|
287
|
-
'coordination.state_sync',
|
|
288
|
-
'coordination.dependency_resolution',
|
|
289
|
-
'distribution.task_splitting',
|
|
290
|
-
'distribution.load_balancing',
|
|
291
|
-
'monitoring.health_check',
|
|
292
|
-
'monitoring.metrics_reporting'
|
|
293
|
-
];
|
|
294
|
-
}
|
|
295
|
-
findCommonCapabilities(local, remote) {
|
|
296
|
-
return local.filter(cap => remote.includes(cap));
|
|
297
|
-
}
|
|
298
|
-
async sendHeartbeat(connection) {
|
|
299
|
-
const heartbeat = {
|
|
300
|
-
jsonrpc: '2.0',
|
|
301
|
-
method: distributed_orchestration_interface_js_1.MCPXCommand.HEALTH_CHECK,
|
|
302
|
-
params: { type: 'heartbeat' },
|
|
303
|
-
timestamp: Date.now(),
|
|
304
|
-
source: this.orchestrator.getInstanceId(),
|
|
305
|
-
priority: 'low'
|
|
306
|
-
};
|
|
307
|
-
await this.sendMessage(connection, heartbeat, 5000);
|
|
308
|
-
}
|
|
309
|
-
async sendMessageWithTimeout(connection, message, timeout) {
|
|
310
|
-
return new Promise((resolve, reject) => {
|
|
311
|
-
const timeoutId = setTimeout(() => {
|
|
312
|
-
reject(new Error(`Message timeout after ${timeout}ms`));
|
|
313
|
-
}, timeout);
|
|
314
|
-
this.sendMessage(connection, message)
|
|
315
|
-
.then(response => {
|
|
316
|
-
clearTimeout(timeoutId);
|
|
317
|
-
resolve(response);
|
|
318
|
-
})
|
|
319
|
-
.catch(error => {
|
|
320
|
-
clearTimeout(timeoutId);
|
|
321
|
-
reject(error);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
async sendMessage(connection, message, timeout) {
|
|
326
|
-
return new Promise((resolve, reject) => {
|
|
327
|
-
const messageId = message.id || this.generateMessageId();
|
|
328
|
-
// Store callback for response
|
|
329
|
-
this.responseCallbacks.set(messageId.toString(), { resolve, reject });
|
|
330
|
-
// Send message
|
|
331
|
-
connection.send(JSON.stringify(message));
|
|
332
|
-
// Setup timeout if specified
|
|
333
|
-
if (timeout) {
|
|
334
|
-
setTimeout(() => {
|
|
335
|
-
this.responseCallbacks.delete(messageId.toString());
|
|
336
|
-
reject(new Error(`Message timeout after ${timeout}ms`));
|
|
337
|
-
}, timeout);
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
createExecutionContext(message, connection) {
|
|
342
|
-
return {
|
|
343
|
-
messageId: message.id?.toString() || '',
|
|
344
|
-
source: message.source,
|
|
345
|
-
target: message.target,
|
|
346
|
-
orchestrationContext: message.orchestration,
|
|
347
|
-
connection,
|
|
348
|
-
timestamp: message.timestamp,
|
|
349
|
-
security: {
|
|
350
|
-
agentId: connection.agentId,
|
|
351
|
-
authenticated: connection.isAuthenticated(),
|
|
352
|
-
capabilities: connection.getNegotiatedCapabilities()
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
async getResourceUsage() {
|
|
357
|
-
// Implementation would gather actual resource metrics
|
|
358
|
-
return {
|
|
359
|
-
cpu: process.cpuUsage().system / 1000000, // Convert to seconds
|
|
360
|
-
memory: process.memoryUsage().heapUsed / 1024 / 1024, // MB
|
|
361
|
-
network: 0, // Would need network monitoring
|
|
362
|
-
storage: 0, // Would need storage monitoring
|
|
363
|
-
apiCalls: 0, // Would need API call counting
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
logCommandExecution(command, target, payload, response) {
|
|
367
|
-
logger_js_1.logger.info(`🚀 MCPX command executed`, {
|
|
368
|
-
command,
|
|
369
|
-
target,
|
|
370
|
-
success: response.success,
|
|
371
|
-
processingTime: response.metadata?.processingTime,
|
|
372
|
-
error: response.error?.code
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
async handleConnectionFailure(connection) {
|
|
376
|
-
logger_js_1.logger.warn(`🔌 Connection failed for agent: ${connection.agentId}`);
|
|
377
|
-
// Remove from active connections
|
|
378
|
-
this.connections.delete(connection.agentId);
|
|
379
|
-
// Emit failure event
|
|
380
|
-
this.emit('connection:failed', { agentId: connection.agentId });
|
|
381
|
-
// Attempt reconnection if configured
|
|
382
|
-
if (this.shouldAttemptReconnection(connection.agentId)) {
|
|
383
|
-
setTimeout(() => {
|
|
384
|
-
this.attemptReconnection(connection.agentId);
|
|
385
|
-
}, 5000); // 5 second delay
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
shouldAttemptReconnection(agentId) {
|
|
389
|
-
// Implementation would check reconnection policy
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
async attemptReconnection(agentId) {
|
|
393
|
-
logger_js_1.logger.info(`🔄 Attempting reconnection to agent: ${agentId}`);
|
|
394
|
-
try {
|
|
395
|
-
const agent = await this.orchestrator.getAgent(agentId);
|
|
396
|
-
if (agent) {
|
|
397
|
-
await this.establishConnection(agent);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
logger_js_1.logger.error(`❌ Reconnection failed for agent: ${agentId}`, { error: error.message });
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
getCurrentOrchestrationContext() {
|
|
405
|
-
// Implementation would return current orchestration context
|
|
406
|
-
return undefined;
|
|
407
|
-
}
|
|
408
|
-
async setupConnection(connection) {
|
|
409
|
-
connection.on('message', async (data) => {
|
|
410
|
-
try {
|
|
411
|
-
const message = JSON.parse(data.toString());
|
|
412
|
-
if (message.id && this.responseCallbacks.has(message.id.toString())) {
|
|
413
|
-
// This is a response to our request
|
|
414
|
-
const callback = this.responseCallbacks.get(message.id.toString());
|
|
415
|
-
this.responseCallbacks.delete(message.id.toString());
|
|
416
|
-
if (message.error) {
|
|
417
|
-
callback?.reject(new Error(message.error.message));
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
callback?.resolve({
|
|
421
|
-
success: true,
|
|
422
|
-
result: message.result
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
// This is an incoming request/notification
|
|
428
|
-
const response = await this.handleMCPXMessage(message, connection);
|
|
429
|
-
if (message.id) {
|
|
430
|
-
// Send response back
|
|
431
|
-
const responseMessage = {
|
|
432
|
-
jsonrpc: '2.0',
|
|
433
|
-
id: message.id,
|
|
434
|
-
result: response.success ? response.result : undefined,
|
|
435
|
-
error: response.success ? undefined : response.error
|
|
436
|
-
};
|
|
437
|
-
connection.send(JSON.stringify(responseMessage));
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
catch (error) {
|
|
442
|
-
logger_js_1.logger.error('❌ Failed to handle MCPX message', { error: error.message });
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
connection.on('error', (error) => {
|
|
446
|
-
logger_js_1.logger.error(`❌ MCPX connection error for agent: ${connection.agentId}`, { error: error.message });
|
|
447
|
-
});
|
|
448
|
-
connection.on('close', () => {
|
|
449
|
-
logger_js_1.logger.info(`🔌 MCPX connection closed for agent: ${connection.agentId}`);
|
|
450
|
-
this.connections.delete(connection.agentId);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
exports.MCPXProtocol = MCPXProtocol;
|
|
455
|
-
// ========================================
|
|
456
|
-
// Supporting Classes
|
|
457
|
-
// ========================================
|
|
458
|
-
class Connection extends events_1.EventEmitter {
|
|
459
|
-
constructor(agentId, websocket, protocol) {
|
|
460
|
-
super();
|
|
461
|
-
this.agentId = agentId;
|
|
462
|
-
this.websocket = websocket;
|
|
463
|
-
this.protocol = protocol;
|
|
464
|
-
this.negotiatedCapabilities = [];
|
|
465
|
-
}
|
|
466
|
-
send(data) {
|
|
467
|
-
if (this.websocket.readyState === ws_1.default.OPEN) {
|
|
468
|
-
this.websocket.send(data);
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
throw new Error(`Connection to ${this.agentId} is not open`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
close() {
|
|
475
|
-
this.websocket.close();
|
|
476
|
-
}
|
|
477
|
-
isAuthenticated() {
|
|
478
|
-
return this.websocket.readyState === ws_1.default.OPEN;
|
|
479
|
-
}
|
|
480
|
-
setNegotiatedCapabilities(capabilities) {
|
|
481
|
-
this.negotiatedCapabilities = capabilities;
|
|
482
|
-
}
|
|
483
|
-
getNegotiatedCapabilities() {
|
|
484
|
-
return [...this.negotiatedCapabilities];
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
class SecurityManager {
|
|
488
|
-
constructor(config) {
|
|
489
|
-
this.config = config;
|
|
490
|
-
}
|
|
491
|
-
async getAuthHeaders(agent) {
|
|
492
|
-
const headers = {
|
|
493
|
-
'Content-Type': 'application/json',
|
|
494
|
-
'User-Agent': 'snow-flow-mcpx/1.0'
|
|
495
|
-
};
|
|
496
|
-
if (agent.authentication.apiKey) {
|
|
497
|
-
headers['Authorization'] = `Bearer ${agent.authentication.apiKey}`;
|
|
498
|
-
}
|
|
499
|
-
return headers;
|
|
500
|
-
}
|
|
501
|
-
async validateMessage(message, connection) {
|
|
502
|
-
// Basic validation - in production, would include:
|
|
503
|
-
// - Message signature verification
|
|
504
|
-
// - Rate limiting checks
|
|
505
|
-
// - Authorization validation
|
|
506
|
-
// - Input sanitization
|
|
507
|
-
if (!message.source) {
|
|
508
|
-
return { valid: false, reason: 'Missing source identifier' };
|
|
509
|
-
}
|
|
510
|
-
return { valid: true };
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
class MessageRouter {
|
|
514
|
-
constructor() { }
|
|
515
|
-
route(message) {
|
|
516
|
-
// Route messages based on type, priority, or other criteria
|
|
517
|
-
return 'default';
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
// ========================================
|
|
521
|
-
// Message Handlers
|
|
522
|
-
// ========================================
|
|
523
|
-
class MCPXMessageHandler {
|
|
524
|
-
constructor(orchestrator) {
|
|
525
|
-
this.orchestrator = orchestrator;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
class SessionStartHandler extends MCPXMessageHandler {
|
|
529
|
-
async handle(params, context) {
|
|
530
|
-
logger_js_1.logger.info('🎯 Handling session start request', { sessionId: params.sessionId });
|
|
531
|
-
// Implementation would create and initialize session
|
|
532
|
-
const session = await this.orchestrator.createSession(params.config);
|
|
533
|
-
return {
|
|
534
|
-
sessionId: session.id,
|
|
535
|
-
status: 'started',
|
|
536
|
-
participants: []
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
class TaskAssignHandler extends MCPXMessageHandler {
|
|
541
|
-
async handle(params, context) {
|
|
542
|
-
logger_js_1.logger.info('📋 Handling task assignment', { taskId: params.taskId });
|
|
543
|
-
// Implementation would assign task to agent
|
|
544
|
-
return {
|
|
545
|
-
taskId: params.taskId,
|
|
546
|
-
assigned: true,
|
|
547
|
-
estimatedCompletion: new Date(Date.now() + params.estimatedDuration)
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
class TaskCompleteHandler extends MCPXMessageHandler {
|
|
552
|
-
async handle(params, context) {
|
|
553
|
-
logger_js_1.logger.info('✅ Handling task completion', { taskId: params.taskId });
|
|
554
|
-
// Implementation would process task completion
|
|
555
|
-
return {
|
|
556
|
-
taskId: params.taskId,
|
|
557
|
-
completed: true,
|
|
558
|
-
result: params.result
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
class StateSyncHandler extends MCPXMessageHandler {
|
|
563
|
-
async handle(params, context) {
|
|
564
|
-
logger_js_1.logger.info('🔄 Handling state synchronization', { keys: params.keys });
|
|
565
|
-
// Implementation would sync state
|
|
566
|
-
return {
|
|
567
|
-
synchronized: params.keys,
|
|
568
|
-
conflicts: [],
|
|
569
|
-
version: Date.now()
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
class DependencyResolveHandler extends MCPXMessageHandler {
|
|
574
|
-
async handle(params, context) {
|
|
575
|
-
logger_js_1.logger.info('🔗 Handling dependency resolution', { dependencies: params.dependencies });
|
|
576
|
-
// Implementation would resolve dependencies
|
|
577
|
-
return {
|
|
578
|
-
resolved: params.dependencies,
|
|
579
|
-
pending: []
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
class QualityGateHandler extends MCPXMessageHandler {
|
|
584
|
-
async handle(params, context) {
|
|
585
|
-
logger_js_1.logger.info('🛡️ Handling quality gate validation', { gateId: params.gateId });
|
|
586
|
-
// Implementation would validate quality gate
|
|
587
|
-
return {
|
|
588
|
-
gateId: params.gateId,
|
|
589
|
-
passed: true,
|
|
590
|
-
score: 0.95,
|
|
591
|
-
validations: []
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
class TaskSplitHandler extends MCPXMessageHandler {
|
|
596
|
-
async handle(params, context) {
|
|
597
|
-
logger_js_1.logger.info('✂️ Handling task splitting', { taskId: params.taskId });
|
|
598
|
-
// Implementation would split task
|
|
599
|
-
return {
|
|
600
|
-
originalTaskId: params.taskId,
|
|
601
|
-
subtasks: [],
|
|
602
|
-
strategy: 'data_parallel'
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
class ResultMergeHandler extends MCPXMessageHandler {
|
|
607
|
-
async handle(params, context) {
|
|
608
|
-
logger_js_1.logger.info('🔀 Handling result merge', { results: params.results.length });
|
|
609
|
-
// Implementation would merge results
|
|
610
|
-
return {
|
|
611
|
-
merged: true,
|
|
612
|
-
result: params.results,
|
|
613
|
-
strategy: 'concatenate'
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
class HealthCheckHandler extends MCPXMessageHandler {
|
|
618
|
-
async handle(params, context) {
|
|
619
|
-
logger_js_1.logger.debug('💓 Handling health check', { type: params.type });
|
|
620
|
-
return {
|
|
621
|
-
status: 'healthy',
|
|
622
|
-
timestamp: new Date(),
|
|
623
|
-
metrics: await this.getHealthMetrics()
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
async getHealthMetrics() {
|
|
627
|
-
return {
|
|
628
|
-
uptime: process.uptime(),
|
|
629
|
-
memory: process.memoryUsage(),
|
|
630
|
-
cpu: process.cpuUsage()
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
class MetricsReportHandler extends MCPXMessageHandler {
|
|
635
|
-
async handle(params, context) {
|
|
636
|
-
logger_js_1.logger.info('📊 Handling metrics report', { metrics: Object.keys(params.metrics) });
|
|
637
|
-
// Implementation would process and store metrics
|
|
638
|
-
return {
|
|
639
|
-
received: true,
|
|
640
|
-
timestamp: new Date()
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
// ========================================
|
|
645
|
-
// Error Classes
|
|
646
|
-
// ========================================
|
|
647
|
-
class MCPXConnectionError extends Error {
|
|
648
|
-
constructor(message, agentId) {
|
|
649
|
-
super(message);
|
|
650
|
-
this.agentId = agentId;
|
|
651
|
-
this.name = 'MCPXConnectionError';
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
class MCPXCommandError extends Error {
|
|
655
|
-
constructor(command, targetInstance, message) {
|
|
656
|
-
super(message);
|
|
657
|
-
this.command = command;
|
|
658
|
-
this.targetInstance = targetInstance;
|
|
659
|
-
this.name = 'MCPXCommandError';
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
class MCPXSecurityError extends Error {
|
|
663
|
-
constructor(message) {
|
|
664
|
-
super(message);
|
|
665
|
-
this.name = 'MCPXSecurityError';
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
//# sourceMappingURL=mcpx-protocol.js.map
|