agentic-qe 2.7.3 → 2.8.0
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/CHANGELOG.md +130 -0
- package/README.md +67 -2
- package/dist/agents/AccessibilityAllyAgent.d.ts +0 -7
- package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.js +0 -15
- package/dist/agents/AccessibilityAllyAgent.js.map +1 -1
- package/dist/agents/ApiContractValidatorAgent.js +4 -4
- package/dist/agents/ApiContractValidatorAgent.js.map +1 -1
- package/dist/agents/BaseAgent.d.ts +2 -0
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +43 -41
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts +0 -8
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.js +0 -15
- package/dist/agents/CodeComplexityAnalyzerAgent.js.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts +0 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.js +0 -2
- package/dist/agents/CodeIntelligenceAgent.js.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.d.ts.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.js +30 -30
- package/dist/agents/DeploymentReadinessAgent.js.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.d.ts +0 -10
- package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.js +10 -20
- package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
- package/dist/agents/FleetCommanderAgent.d.ts.map +1 -1
- package/dist/agents/FleetCommanderAgent.js +28 -28
- package/dist/agents/FleetCommanderAgent.js.map +1 -1
- package/dist/agents/LearningAgent.js +1 -1
- package/dist/agents/LearningAgent.js.map +1 -1
- package/dist/agents/PerformanceTesterAgent.d.ts.map +1 -1
- package/dist/agents/PerformanceTesterAgent.js +25 -25
- package/dist/agents/PerformanceTesterAgent.js.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.js +20 -20
- package/dist/agents/ProductionIntelligenceAgent.js.map +1 -1
- package/dist/agents/QXPartnerAgent.d.ts +0 -8
- package/dist/agents/QXPartnerAgent.d.ts.map +1 -1
- package/dist/agents/QXPartnerAgent.js +0 -15
- package/dist/agents/QXPartnerAgent.js.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.d.ts +0 -7
- package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.js +0 -16
- package/dist/agents/QualityAnalyzerAgent.js.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.js +18 -18
- package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.d.ts.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.js +21 -21
- package/dist/agents/RequirementsValidatorAgent.js.map +1 -1
- package/dist/agents/SecurityScannerAgent.d.ts.map +1 -1
- package/dist/agents/SecurityScannerAgent.js +38 -38
- package/dist/agents/SecurityScannerAgent.js.map +1 -1
- package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -1
- package/dist/agents/TestDataArchitectAgent.js +29 -29
- package/dist/agents/TestDataArchitectAgent.js.map +1 -1
- package/dist/agents/TestExecutorAgent.d.ts +0 -7
- package/dist/agents/TestExecutorAgent.d.ts.map +1 -1
- package/dist/agents/TestExecutorAgent.js +35 -51
- package/dist/agents/TestExecutorAgent.js.map +1 -1
- package/dist/agents/TestGeneratorAgent.d.ts +0 -7
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
- package/dist/agents/TestGeneratorAgent.js +0 -16
- package/dist/agents/TestGeneratorAgent.js.map +1 -1
- package/dist/agents/adapters/AgentLLMAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/AgentLLMAdapter.js +5 -4
- package/dist/agents/adapters/AgentLLMAdapter.js.map +1 -1
- package/dist/agents/adapters/CoordinatorAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/CoordinatorAdapter.js +2 -1
- package/dist/agents/adapters/CoordinatorAdapter.js.map +1 -1
- package/dist/agents/n8n/N8nAPIClient.d.ts.map +1 -1
- package/dist/agents/n8n/N8nAPIClient.js +3 -2
- package/dist/agents/n8n/N8nAPIClient.js.map +1 -1
- package/dist/agents/n8n/N8nAuditPersistence.d.ts.map +1 -1
- package/dist/agents/n8n/N8nAuditPersistence.js +2 -1
- package/dist/agents/n8n/N8nAuditPersistence.js.map +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js.map +1 -1
- package/dist/agents/n8n/N8nComplianceValidatorAgent.js +1 -1
- package/dist/agents/n8n/N8nComplianceValidatorAgent.js.map +1 -1
- package/dist/agents/n8n/N8nMonitoringValidatorAgent.js +1 -1
- package/dist/agents/n8n/N8nMonitoringValidatorAgent.js.map +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js.map +1 -1
- package/dist/agents/n8n/N8nSecurityAuditorAgent.js +1 -1
- package/dist/agents/n8n/N8nSecurityAuditorAgent.js.map +1 -1
- package/dist/agents/pool/AgentPool.d.ts.map +1 -1
- package/dist/agents/pool/AgentPool.js +2 -1
- package/dist/agents/pool/AgentPool.js.map +1 -1
- package/dist/agents/pool/QEAgentPoolFactory.d.ts.map +1 -1
- package/dist/agents/pool/QEAgentPoolFactory.js +2 -1
- package/dist/agents/pool/QEAgentPoolFactory.js.map +1 -1
- package/dist/cli/commands/agent/spawn.d.ts +12 -1
- package/dist/cli/commands/agent/spawn.d.ts.map +1 -1
- package/dist/cli/commands/agent/spawn.js +95 -8
- package/dist/cli/commands/agent/spawn.js.map +1 -1
- package/dist/cli/index.js +91 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts +134 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts.map +1 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js +484 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts +114 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.js +478 -0
- package/dist/edge/adapters/IndexedDBStorage.js.map +1 -0
- package/dist/edge/adapters/index.d.ts +12 -0
- package/dist/edge/adapters/index.d.ts.map +1 -0
- package/dist/edge/adapters/index.js +22 -0
- package/dist/edge/adapters/index.js.map +1 -0
- package/dist/edge/browser/BrowserAgent.d.ts +241 -0
- package/dist/edge/browser/BrowserAgent.d.ts.map +1 -0
- package/dist/edge/browser/BrowserAgent.js +743 -0
- package/dist/edge/browser/BrowserAgent.js.map +1 -0
- package/dist/edge/index.d.ts +34 -0
- package/dist/edge/index.d.ts.map +1 -0
- package/dist/edge/index.js +114 -0
- package/dist/edge/index.js.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts +181 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js +851 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts +143 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js +432 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts +146 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js +783 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js.map +1 -0
- package/dist/edge/p2p/coordination/index.d.ts +70 -0
- package/dist/edge/p2p/coordination/index.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/index.js +107 -0
- package/dist/edge/p2p/coordination/index.js.map +1 -0
- package/dist/edge/p2p/coordination/types.d.ts +572 -0
- package/dist/edge/p2p/coordination/types.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/types.js +366 -0
- package/dist/edge/p2p/coordination/types.js.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts +324 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.js +839 -0
- package/dist/edge/p2p/crdt/CRDTStore.js.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts +173 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.js +394 -0
- package/dist/edge/p2p/crdt/GCounter.js.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts +200 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.js +456 -0
- package/dist/edge/p2p/crdt/LWWRegister.js.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts +232 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.js +723 -0
- package/dist/edge/p2p/crdt/ORSet.js.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts +366 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js +838 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts +274 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.js +499 -0
- package/dist/edge/p2p/crdt/VectorClock.js.map +1 -0
- package/dist/edge/p2p/crdt/index.d.ts +87 -0
- package/dist/edge/p2p/crdt/index.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/index.js +120 -0
- package/dist/edge/p2p/crdt/index.js.map +1 -0
- package/dist/edge/p2p/crdt/types.d.ts +667 -0
- package/dist/edge/p2p/crdt/types.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/types.js +208 -0
- package/dist/edge/p2p/crdt/types.js.map +1 -0
- package/dist/edge/p2p/crypto/Identity.d.ts +139 -0
- package/dist/edge/p2p/crypto/Identity.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Identity.js +449 -0
- package/dist/edge/p2p/crypto/Identity.js.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts +196 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.js +576 -0
- package/dist/edge/p2p/crypto/KeyManager.js.map +1 -0
- package/dist/edge/p2p/crypto/Signer.d.ts +164 -0
- package/dist/edge/p2p/crypto/Signer.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Signer.js +357 -0
- package/dist/edge/p2p/crypto/Signer.js.map +1 -0
- package/dist/edge/p2p/crypto/index.d.ts +90 -0
- package/dist/edge/p2p/crypto/index.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/index.js +158 -0
- package/dist/edge/p2p/crypto/index.js.map +1 -0
- package/dist/edge/p2p/crypto/types.d.ts +217 -0
- package/dist/edge/p2p/crypto/types.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/types.js +42 -0
- package/dist/edge/p2p/crypto/types.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts +270 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js +824 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts +295 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.js +819 -0
- package/dist/edge/p2p/federated/FederatedRound.js.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts +226 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.js +826 -0
- package/dist/edge/p2p/federated/GradientAggregator.js.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts +248 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.js +724 -0
- package/dist/edge/p2p/federated/ModelManager.js.map +1 -0
- package/dist/edge/p2p/federated/index.d.ts +65 -0
- package/dist/edge/p2p/federated/index.d.ts.map +1 -0
- package/dist/edge/p2p/federated/index.js +110 -0
- package/dist/edge/p2p/federated/index.js.map +1 -0
- package/dist/edge/p2p/federated/types.d.ts +905 -0
- package/dist/edge/p2p/federated/types.d.ts.map +1 -0
- package/dist/edge/p2p/federated/types.js +339 -0
- package/dist/edge/p2p/federated/types.js.map +1 -0
- package/dist/edge/p2p/index.d.ts +156 -0
- package/dist/edge/p2p/index.d.ts.map +1 -0
- package/dist/edge/p2p/index.js +242 -0
- package/dist/edge/p2p/index.js.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts +128 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js +560 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts +159 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.js +569 -0
- package/dist/edge/p2p/nat/HolePuncher.js.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts +109 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.js +472 -0
- package/dist/edge/p2p/nat/NATDetector.js.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts +158 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.js +547 -0
- package/dist/edge/p2p/nat/TURNManager.js.map +1 -0
- package/dist/edge/p2p/nat/index.d.ts +74 -0
- package/dist/edge/p2p/nat/index.d.ts.map +1 -0
- package/dist/edge/p2p/nat/index.js +104 -0
- package/dist/edge/p2p/nat/index.js.map +1 -0
- package/dist/edge/p2p/nat/types.d.ts +583 -0
- package/dist/edge/p2p/nat/types.d.ts.map +1 -0
- package/dist/edge/p2p/nat/types.js +267 -0
- package/dist/edge/p2p/nat/types.js.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts +333 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.js +914 -0
- package/dist/edge/p2p/protocol/AgentChannel.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts +147 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js +738 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts +266 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.js +808 -0
- package/dist/edge/p2p/protocol/MessageRouter.js.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts +309 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js +930 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js.map +1 -0
- package/dist/edge/p2p/protocol/index.d.ts +114 -0
- package/dist/edge/p2p/protocol/index.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/index.js +206 -0
- package/dist/edge/p2p/protocol/index.js.map +1 -0
- package/dist/edge/p2p/protocol/types.d.ts +737 -0
- package/dist/edge/p2p/protocol/types.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/types.js +490 -0
- package/dist/edge/p2p/protocol/types.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts +284 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js +644 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts +168 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.js +781 -0
- package/dist/edge/p2p/sharing/PatternIndex.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts +163 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js +696 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts +242 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js +859 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js.map +1 -0
- package/dist/edge/p2p/sharing/index.d.ts +90 -0
- package/dist/edge/p2p/sharing/index.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/index.js +152 -0
- package/dist/edge/p2p/sharing/index.js.map +1 -0
- package/dist/edge/p2p/sharing/types.d.ts +796 -0
- package/dist/edge/p2p/sharing/types.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/types.js +264 -0
- package/dist/edge/p2p/sharing/types.js.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts +218 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js +562 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts +171 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.js +490 -0
- package/dist/edge/p2p/webrtc/ICEManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts +159 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js +735 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts +191 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js +608 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js.map +1 -0
- package/dist/edge/p2p/webrtc/index.d.ts +158 -0
- package/dist/edge/p2p/webrtc/index.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/index.js +164 -0
- package/dist/edge/p2p/webrtc/index.js.map +1 -0
- package/dist/edge/p2p/webrtc/types.d.ts +665 -0
- package/dist/edge/p2p/webrtc/types.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/types.js +245 -0
- package/dist/edge/p2p/webrtc/types.js.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts +98 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.js +264 -0
- package/dist/edge/server/AgentSpawnAPI.js.map +1 -0
- package/dist/edge/server/SignalingServer.d.ts +71 -0
- package/dist/edge/server/SignalingServer.d.ts.map +1 -0
- package/dist/edge/server/SignalingServer.js +429 -0
- package/dist/edge/server/SignalingServer.js.map +1 -0
- package/dist/edge/server/index.d.ts +64 -0
- package/dist/edge/server/index.d.ts.map +1 -0
- package/dist/edge/server/index.js +318 -0
- package/dist/edge/server/index.js.map +1 -0
- package/dist/edge/types/browser-agent.types.d.ts +455 -0
- package/dist/edge/types/browser-agent.types.d.ts.map +1 -0
- package/dist/edge/types/browser-agent.types.js +116 -0
- package/dist/edge/types/browser-agent.types.js.map +1 -0
- package/dist/edge/types/index.d.ts +11 -0
- package/dist/edge/types/index.d.ts.map +1 -0
- package/dist/edge/types/index.js +17 -0
- package/dist/edge/types/index.js.map +1 -0
- package/dist/edge/types/storage.types.d.ts +207 -0
- package/dist/edge/types/storage.types.d.ts.map +1 -0
- package/dist/edge/types/storage.types.js +47 -0
- package/dist/edge/types/storage.types.js.map +1 -0
- package/dist/edge/wasm/shims.d.ts +224 -0
- package/dist/edge/wasm/shims.d.ts.map +1 -0
- package/dist/edge/wasm/shims.js +667 -0
- package/dist/edge/wasm/shims.js.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts +33 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js +305 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js.map +1 -0
- package/dist/mcp/handlers/filtered/index.d.ts +15 -19
- package/dist/mcp/handlers/filtered/index.d.ts.map +1 -1
- package/dist/mcp/handlers/filtered/index.js +16 -27
- package/dist/mcp/handlers/filtered/index.js.map +1 -1
- package/dist/mcp/handlers/integration/index.d.ts +5 -4
- package/dist/mcp/handlers/integration/index.d.ts.map +1 -1
- package/dist/mcp/handlers/integration/index.js +7 -7
- package/dist/mcp/handlers/integration/index.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +14 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +8 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +412 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/persistence/migrations/all-migrations.d.ts.map +1 -1
- package/dist/persistence/migrations/all-migrations.js +44 -1
- package/dist/persistence/migrations/all-migrations.js.map +1 -1
- package/dist/planning/GOAPPlanner.d.ts +1 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +15 -2
- package/dist/planning/GOAPPlanner.js.map +1 -1
- package/dist/planning/PlanLearning.d.ts.map +1 -1
- package/dist/planning/PlanLearning.js +2 -1
- package/dist/planning/PlanLearning.js.map +1 -1
- package/dist/planning/PlanSimilarity.d.ts.map +1 -1
- package/dist/planning/PlanSimilarity.js +2 -1
- package/dist/planning/PlanSimilarity.js.map +1 -1
- package/package.json +29 -8
- package/dist/alerting/AlertManager.d.ts +0 -120
- package/dist/alerting/AlertManager.d.ts.map +0 -1
- package/dist/alerting/AlertManager.js +0 -345
- package/dist/alerting/AlertManager.js.map +0 -1
- package/dist/alerting/FeedbackRouter.d.ts +0 -98
- package/dist/alerting/FeedbackRouter.d.ts.map +0 -1
- package/dist/alerting/FeedbackRouter.js +0 -331
- package/dist/alerting/FeedbackRouter.js.map +0 -1
- package/dist/alerting/StrategyApplicator.d.ts +0 -120
- package/dist/alerting/StrategyApplicator.d.ts.map +0 -1
- package/dist/alerting/StrategyApplicator.js +0 -299
- package/dist/alerting/StrategyApplicator.js.map +0 -1
- package/dist/alerting/index.d.ts +0 -68
- package/dist/alerting/index.d.ts.map +0 -1
- package/dist/alerting/index.js +0 -112
- package/dist/alerting/index.js.map +0 -1
- package/dist/alerting/types.d.ts +0 -118
- package/dist/alerting/types.d.ts.map +0 -1
- package/dist/alerting/types.js +0 -11
- package/dist/alerting/types.js.map +0 -1
- package/dist/cli/commands/fleet/backup.d.ts +0 -49
- package/dist/cli/commands/fleet/backup.d.ts.map +0 -1
- package/dist/cli/commands/fleet/backup.js +0 -88
- package/dist/cli/commands/fleet/backup.js.map +0 -1
- package/dist/cli/commands/fleet/health.d.ts +0 -154
- package/dist/cli/commands/fleet/health.d.ts.map +0 -1
- package/dist/cli/commands/fleet/health.js +0 -483
- package/dist/cli/commands/fleet/health.js.map +0 -1
- package/dist/cli/commands/fleet/init.d.ts +0 -11
- package/dist/cli/commands/fleet/init.d.ts.map +0 -1
- package/dist/cli/commands/fleet/init.js +0 -91
- package/dist/cli/commands/fleet/init.js.map +0 -1
- package/dist/cli/commands/fleet/logs.d.ts +0 -21
- package/dist/cli/commands/fleet/logs.d.ts.map +0 -1
- package/dist/cli/commands/fleet/logs.js +0 -267
- package/dist/cli/commands/fleet/logs.js.map +0 -1
- package/dist/cli/commands/fleet/metrics.d.ts +0 -27
- package/dist/cli/commands/fleet/metrics.d.ts.map +0 -1
- package/dist/cli/commands/fleet/metrics.js +0 -369
- package/dist/cli/commands/fleet/metrics.js.map +0 -1
- package/dist/cli/commands/fleet/monitor.d.ts +0 -18
- package/dist/cli/commands/fleet/monitor.d.ts.map +0 -1
- package/dist/cli/commands/fleet/monitor.js +0 -237
- package/dist/cli/commands/fleet/monitor.js.map +0 -1
- package/dist/cli/commands/fleet/optimize.d.ts +0 -42
- package/dist/cli/commands/fleet/optimize.d.ts.map +0 -1
- package/dist/cli/commands/fleet/optimize.js +0 -135
- package/dist/cli/commands/fleet/optimize.js.map +0 -1
- package/dist/cli/commands/fleet/recover.d.ts +0 -22
- package/dist/cli/commands/fleet/recover.d.ts.map +0 -1
- package/dist/cli/commands/fleet/recover.js +0 -99
- package/dist/cli/commands/fleet/recover.js.map +0 -1
- package/dist/cli/commands/fleet/restart.d.ts +0 -18
- package/dist/cli/commands/fleet/restart.d.ts.map +0 -1
- package/dist/cli/commands/fleet/restart.js +0 -290
- package/dist/cli/commands/fleet/restart.js.map +0 -1
- package/dist/cli/commands/fleet/scale.d.ts +0 -9
- package/dist/cli/commands/fleet/scale.d.ts.map +0 -1
- package/dist/cli/commands/fleet/scale.js +0 -77
- package/dist/cli/commands/fleet/scale.js.map +0 -1
- package/dist/cli/commands/fleet/shutdown.d.ts +0 -19
- package/dist/cli/commands/fleet/shutdown.d.ts.map +0 -1
- package/dist/cli/commands/fleet/shutdown.js +0 -307
- package/dist/cli/commands/fleet/shutdown.js.map +0 -1
- package/dist/cli/commands/fleet/status.d.ts +0 -10
- package/dist/cli/commands/fleet/status.d.ts.map +0 -1
- package/dist/cli/commands/fleet/status.js +0 -97
- package/dist/cli/commands/fleet/status.js.map +0 -1
- package/dist/cli/commands/fleet/topology.d.ts +0 -23
- package/dist/cli/commands/fleet/topology.d.ts.map +0 -1
- package/dist/cli/commands/fleet/topology.js +0 -376
- package/dist/cli/commands/fleet/topology.js.map +0 -1
- package/dist/cli/commands/monitor/alerts.d.ts +0 -45
- package/dist/cli/commands/monitor/alerts.d.ts.map +0 -1
- package/dist/cli/commands/monitor/alerts.js +0 -168
- package/dist/cli/commands/monitor/alerts.js.map +0 -1
- package/dist/cli/commands/monitor/analyze.d.ts +0 -49
- package/dist/cli/commands/monitor/analyze.d.ts.map +0 -1
- package/dist/cli/commands/monitor/analyze.js +0 -209
- package/dist/cli/commands/monitor/analyze.js.map +0 -1
- package/dist/cli/commands/monitor/compare.d.ts +0 -38
- package/dist/cli/commands/monitor/compare.d.ts.map +0 -1
- package/dist/cli/commands/monitor/compare.js +0 -177
- package/dist/cli/commands/monitor/compare.js.map +0 -1
- package/dist/cli/commands/monitor/dashboard.d.ts +0 -34
- package/dist/cli/commands/monitor/dashboard.d.ts.map +0 -1
- package/dist/cli/commands/monitor/dashboard.js +0 -157
- package/dist/cli/commands/monitor/dashboard.js.map +0 -1
- package/dist/cli/commands/monitor/export.d.ts +0 -36
- package/dist/cli/commands/monitor/export.d.ts.map +0 -1
- package/dist/cli/commands/monitor/export.js +0 -157
- package/dist/cli/commands/monitor/export.js.map +0 -1
- package/dist/cli/commands/monitor/index.d.ts +0 -11
- package/dist/cli/commands/monitor/index.d.ts.map +0 -1
- package/dist/cli/commands/monitor/index.js +0 -14
- package/dist/cli/commands/monitor/index.js.map +0 -1
- package/dist/cli/commands/quality/baseline.d.ts +0 -27
- package/dist/cli/commands/quality/baseline.d.ts.map +0 -1
- package/dist/cli/commands/quality/baseline.js +0 -124
- package/dist/cli/commands/quality/baseline.js.map +0 -1
- package/dist/cli/commands/quality/compare.d.ts +0 -36
- package/dist/cli/commands/quality/compare.d.ts.map +0 -1
- package/dist/cli/commands/quality/compare.js +0 -136
- package/dist/cli/commands/quality/compare.js.map +0 -1
- package/dist/cli/commands/quality/decision.d.ts +0 -81
- package/dist/cli/commands/quality/decision.d.ts.map +0 -1
- package/dist/cli/commands/quality/decision.js +0 -319
- package/dist/cli/commands/quality/decision.js.map +0 -1
- package/dist/cli/commands/quality/gate.d.ts +0 -47
- package/dist/cli/commands/quality/gate.d.ts.map +0 -1
- package/dist/cli/commands/quality/gate.js +0 -205
- package/dist/cli/commands/quality/gate.js.map +0 -1
- package/dist/cli/commands/quality/index.d.ts +0 -17
- package/dist/cli/commands/quality/index.d.ts.map +0 -1
- package/dist/cli/commands/quality/index.js +0 -41
- package/dist/cli/commands/quality/index.js.map +0 -1
- package/dist/cli/commands/quality/policy.d.ts +0 -57
- package/dist/cli/commands/quality/policy.d.ts.map +0 -1
- package/dist/cli/commands/quality/policy.js +0 -359
- package/dist/cli/commands/quality/policy.js.map +0 -1
- package/dist/cli/commands/quality/risk.d.ts +0 -41
- package/dist/cli/commands/quality/risk.d.ts.map +0 -1
- package/dist/cli/commands/quality/risk.js +0 -255
- package/dist/cli/commands/quality/risk.js.map +0 -1
- package/dist/cli/commands/quality/trends.d.ts +0 -40
- package/dist/cli/commands/quality/trends.d.ts.map +0 -1
- package/dist/cli/commands/quality/trends.js +0 -122
- package/dist/cli/commands/quality/trends.js.map +0 -1
- package/dist/cli/commands/quality/validate.d.ts +0 -44
- package/dist/cli/commands/quality/validate.d.ts.map +0 -1
- package/dist/cli/commands/quality/validate.js +0 -234
- package/dist/cli/commands/quality/validate.js.map +0 -1
- package/dist/cli/commands/test/analyze-failures.d.ts +0 -39
- package/dist/cli/commands/test/analyze-failures.d.ts.map +0 -1
- package/dist/cli/commands/test/analyze-failures.js +0 -113
- package/dist/cli/commands/test/analyze-failures.js.map +0 -1
- package/dist/cli/commands/test/clean.d.ts +0 -3
- package/dist/cli/commands/test/clean.d.ts.map +0 -1
- package/dist/cli/commands/test/clean.js +0 -148
- package/dist/cli/commands/test/clean.js.map +0 -1
- package/dist/cli/commands/test/debug.d.ts +0 -3
- package/dist/cli/commands/test/debug.d.ts.map +0 -1
- package/dist/cli/commands/test/debug.js +0 -167
- package/dist/cli/commands/test/debug.js.map +0 -1
- package/dist/cli/commands/test/diff.d.ts +0 -3
- package/dist/cli/commands/test/diff.d.ts.map +0 -1
- package/dist/cli/commands/test/diff.js +0 -195
- package/dist/cli/commands/test/diff.js.map +0 -1
- package/dist/cli/commands/test/flakiness.d.ts +0 -32
- package/dist/cli/commands/test/flakiness.d.ts.map +0 -1
- package/dist/cli/commands/test/flakiness.js +0 -121
- package/dist/cli/commands/test/flakiness.js.map +0 -1
- package/dist/cli/commands/test/index.d.ts +0 -17
- package/dist/cli/commands/test/index.d.ts.map +0 -1
- package/dist/cli/commands/test/index.js +0 -45
- package/dist/cli/commands/test/index.js.map +0 -1
- package/dist/cli/commands/test/mutate.d.ts +0 -29
- package/dist/cli/commands/test/mutate.d.ts.map +0 -1
- package/dist/cli/commands/test/mutate.js +0 -163
- package/dist/cli/commands/test/mutate.js.map +0 -1
- package/dist/cli/commands/test/parallel.d.ts +0 -3
- package/dist/cli/commands/test/parallel.d.ts.map +0 -1
- package/dist/cli/commands/test/parallel.js +0 -117
- package/dist/cli/commands/test/parallel.js.map +0 -1
- package/dist/cli/commands/test/profile.d.ts +0 -3
- package/dist/cli/commands/test/profile.d.ts.map +0 -1
- package/dist/cli/commands/test/profile.js +0 -156
- package/dist/cli/commands/test/profile.js.map +0 -1
- package/dist/cli/commands/test/queue.d.ts +0 -3
- package/dist/cli/commands/test/queue.d.ts.map +0 -1
- package/dist/cli/commands/test/queue.js +0 -140
- package/dist/cli/commands/test/queue.js.map +0 -1
- package/dist/cli/commands/test/retry.d.ts +0 -3
- package/dist/cli/commands/test/retry.d.ts.map +0 -1
- package/dist/cli/commands/test/retry.js +0 -105
- package/dist/cli/commands/test/retry.js.map +0 -1
- package/dist/cli/commands/test/snapshot.d.ts +0 -3
- package/dist/cli/commands/test/snapshot.d.ts.map +0 -1
- package/dist/cli/commands/test/snapshot.js +0 -176
- package/dist/cli/commands/test/snapshot.js.map +0 -1
- package/dist/cli/commands/test/trace.d.ts +0 -3
- package/dist/cli/commands/test/trace.d.ts.map +0 -1
- package/dist/cli/commands/test/trace.js +0 -137
- package/dist/cli/commands/test/trace.js.map +0 -1
- package/dist/cli/commands/test/watch.d.ts +0 -3
- package/dist/cli/commands/test/watch.d.ts.map +0 -1
- package/dist/cli/commands/test/watch.js +0 -130
- package/dist/cli/commands/test/watch.js.map +0 -1
- package/dist/cli/index-spec.d.ts +0 -3
- package/dist/cli/index-spec.d.ts.map +0 -1
- package/dist/cli/index-spec.js +0 -154
- package/dist/cli/index-spec.js.map +0 -1
- package/dist/cli/index-working.d.ts +0 -7
- package/dist/cli/index-working.d.ts.map +0 -1
- package/dist/cli/index-working.js +0 -617
- package/dist/cli/index-working.js.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts +0 -83
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js +0 -130
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts +0 -58
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js +0 -84
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts +0 -54
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js +0 -73
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.d.ts +0 -10
- package/dist/mcp/handlers/integration/contract-validate.d.ts.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.js +0 -348
- package/dist/mcp/handlers/integration/contract-validate.js.map +0 -1
- package/dist/reporting/ResultAggregator.d.ts +0 -107
- package/dist/reporting/ResultAggregator.d.ts.map +0 -1
- package/dist/reporting/ResultAggregator.js +0 -435
- package/dist/reporting/ResultAggregator.js.map +0 -1
- package/dist/reporting/index.d.ts +0 -48
- package/dist/reporting/index.d.ts.map +0 -1
- package/dist/reporting/index.js +0 -154
- package/dist/reporting/index.js.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.d.ts +0 -128
- package/dist/reporting/reporters/ControlLoopReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.js +0 -417
- package/dist/reporting/reporters/ControlLoopReporter.js.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.d.ts +0 -140
- package/dist/reporting/reporters/HumanReadableReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.js +0 -524
- package/dist/reporting/reporters/HumanReadableReporter.js.map +0 -1
- package/dist/reporting/reporters/JSONReporter.d.ts +0 -251
- package/dist/reporting/reporters/JSONReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/JSONReporter.js +0 -325
- package/dist/reporting/reporters/JSONReporter.js.map +0 -1
- package/dist/reporting/reporters/index.d.ts +0 -14
- package/dist/reporting/reporters/index.d.ts.map +0 -1
- package/dist/reporting/reporters/index.js +0 -19
- package/dist/reporting/reporters/index.js.map +0 -1
- package/dist/reporting/types.d.ts +0 -427
- package/dist/reporting/types.d.ts.map +0 -1
- package/dist/reporting/types.js +0 -12
- package/dist/reporting/types.js.map +0 -1
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Federated Learning Coordinator
|
|
4
|
+
*
|
|
5
|
+
* High-level API for federated learning that coordinates training rounds,
|
|
6
|
+
* monitors convergence, handles participant failures, and integrates with
|
|
7
|
+
* AgentChannel for peer communication.
|
|
8
|
+
*
|
|
9
|
+
* @module edge/p2p/federated/FederatedCoordinator
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.FederatedCoordinator = void 0;
|
|
14
|
+
exports.createFederatedCoordinator = createFederatedCoordinator;
|
|
15
|
+
exports.createFederatedConfig = createFederatedConfig;
|
|
16
|
+
const types_1 = require("./types");
|
|
17
|
+
const GradientAggregator_1 = require("./GradientAggregator");
|
|
18
|
+
const FederatedRound_1 = require("./FederatedRound");
|
|
19
|
+
const ModelManager_1 = require("./ModelManager");
|
|
20
|
+
// ============================================
|
|
21
|
+
// FederatedCoordinator Class
|
|
22
|
+
// ============================================
|
|
23
|
+
/**
|
|
24
|
+
* High-level federated learning coordinator
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const coordinator = new FederatedCoordinator({
|
|
29
|
+
* federatedConfig: {
|
|
30
|
+
* sessionId: 'training-session-1',
|
|
31
|
+
* modelId: 'my-model',
|
|
32
|
+
* aggregationStrategy: AggregationStrategy.FED_AVG,
|
|
33
|
+
* selectionStrategy: SelectionStrategy.RANDOM,
|
|
34
|
+
* totalRounds: 100,
|
|
35
|
+
* minParticipation: 0.3,
|
|
36
|
+
* },
|
|
37
|
+
* modelConfig: {
|
|
38
|
+
* architecture: modelArchitecture,
|
|
39
|
+
* optimizer: { type: 'adam', learningRate: 0.001 },
|
|
40
|
+
* },
|
|
41
|
+
* transport: channelTransport,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Start training
|
|
45
|
+
* coordinator.on(event => console.log(event));
|
|
46
|
+
* const result = await coordinator.startTraining();
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
class FederatedCoordinator {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.eventHandlers = [];
|
|
52
|
+
this.checkpointIds = [];
|
|
53
|
+
this.errors = [];
|
|
54
|
+
this.lossHistory = [];
|
|
55
|
+
this.accuracyHistory = [];
|
|
56
|
+
this.roundHistory = [];
|
|
57
|
+
this.config = config;
|
|
58
|
+
// Merge with defaults
|
|
59
|
+
this.federatedConfig = {
|
|
60
|
+
...types_1.DEFAULT_FEDERATED_CONFIG,
|
|
61
|
+
...config.federatedConfig,
|
|
62
|
+
};
|
|
63
|
+
// Initialize state
|
|
64
|
+
this.state = {
|
|
65
|
+
sessionId: this.federatedConfig.sessionId,
|
|
66
|
+
isTraining: false,
|
|
67
|
+
currentRound: 0,
|
|
68
|
+
totalRounds: this.federatedConfig.totalRounds,
|
|
69
|
+
activeRound: null,
|
|
70
|
+
convergenceStatus: types_1.ConvergenceStatus.NOT_STARTED,
|
|
71
|
+
startTime: null,
|
|
72
|
+
endTime: null,
|
|
73
|
+
roundsWithoutImprovement: 0,
|
|
74
|
+
bestLoss: Infinity,
|
|
75
|
+
bestRound: 0,
|
|
76
|
+
};
|
|
77
|
+
// Initialize components
|
|
78
|
+
this.modelManager = new ModelManager_1.ModelManager(config.modelConfig);
|
|
79
|
+
this.aggregator = new GradientAggregator_1.GradientAggregator({
|
|
80
|
+
strategy: this.federatedConfig.aggregationStrategy,
|
|
81
|
+
enableClipping: this.federatedConfig.enableGradientClipping,
|
|
82
|
+
clipNorm: this.federatedConfig.gradientClipNorm,
|
|
83
|
+
differentialPrivacy: this.federatedConfig.differentialPrivacy,
|
|
84
|
+
secureAggregation: this.federatedConfig.secureAggregation,
|
|
85
|
+
proximalMu: this.federatedConfig.proximalMu,
|
|
86
|
+
...config.aggregatorConfig,
|
|
87
|
+
});
|
|
88
|
+
this.transport = config.transport ?? null;
|
|
89
|
+
// Set initial weights if provided
|
|
90
|
+
if (config.initialWeights) {
|
|
91
|
+
this.modelManager.setWeights(config.initialWeights);
|
|
92
|
+
}
|
|
93
|
+
// Setup message handling if transport provided
|
|
94
|
+
if (this.transport) {
|
|
95
|
+
this.setupMessageHandling();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// ============================================
|
|
99
|
+
// Training Lifecycle
|
|
100
|
+
// ============================================
|
|
101
|
+
/**
|
|
102
|
+
* Start federated training
|
|
103
|
+
*/
|
|
104
|
+
async startTraining() {
|
|
105
|
+
if (this.state.isTraining) {
|
|
106
|
+
throw new types_1.FederatedError('Training already in progress', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
107
|
+
}
|
|
108
|
+
// Validate configuration
|
|
109
|
+
this.validateConfiguration();
|
|
110
|
+
// Initialize state
|
|
111
|
+
this.state.isTraining = true;
|
|
112
|
+
this.state.startTime = Date.now();
|
|
113
|
+
this.state.currentRound = 0;
|
|
114
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.TRAINING;
|
|
115
|
+
this.errors = [];
|
|
116
|
+
this.lossHistory = [];
|
|
117
|
+
this.accuracyHistory = [];
|
|
118
|
+
this.roundHistory = [];
|
|
119
|
+
this.checkpointIds = [];
|
|
120
|
+
this.emitEvent({
|
|
121
|
+
type: types_1.FederatedEventType.SESSION_STARTED,
|
|
122
|
+
timestamp: Date.now(),
|
|
123
|
+
sessionId: this.state.sessionId,
|
|
124
|
+
details: {
|
|
125
|
+
totalRounds: this.state.totalRounds,
|
|
126
|
+
config: this.federatedConfig,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
// Run training rounds
|
|
131
|
+
await this.runTrainingLoop();
|
|
132
|
+
// Training completed
|
|
133
|
+
this.state.isTraining = false;
|
|
134
|
+
this.state.endTime = Date.now();
|
|
135
|
+
const result = this.buildTrainingResult(true);
|
|
136
|
+
this.emitEvent({
|
|
137
|
+
type: types_1.FederatedEventType.SESSION_ENDED,
|
|
138
|
+
timestamp: Date.now(),
|
|
139
|
+
sessionId: this.state.sessionId,
|
|
140
|
+
details: { result },
|
|
141
|
+
});
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
this.state.isTraining = false;
|
|
146
|
+
this.state.endTime = Date.now();
|
|
147
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.DIVERGING;
|
|
148
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
149
|
+
this.errors.push(errorMessage);
|
|
150
|
+
this.emitEvent({
|
|
151
|
+
type: types_1.FederatedEventType.SESSION_ENDED,
|
|
152
|
+
timestamp: Date.now(),
|
|
153
|
+
sessionId: this.state.sessionId,
|
|
154
|
+
details: { error: errorMessage },
|
|
155
|
+
});
|
|
156
|
+
return this.buildTrainingResult(false);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Stop training
|
|
161
|
+
*/
|
|
162
|
+
stopTraining(reason = 'Training stopped by user') {
|
|
163
|
+
if (!this.state.isTraining)
|
|
164
|
+
return;
|
|
165
|
+
if (this.state.activeRound) {
|
|
166
|
+
this.state.activeRound.cancel(reason);
|
|
167
|
+
}
|
|
168
|
+
this.state.isTraining = false;
|
|
169
|
+
this.state.endTime = Date.now();
|
|
170
|
+
this.errors.push(reason);
|
|
171
|
+
this.emitEvent({
|
|
172
|
+
type: types_1.FederatedEventType.SESSION_ENDED,
|
|
173
|
+
timestamp: Date.now(),
|
|
174
|
+
sessionId: this.state.sessionId,
|
|
175
|
+
details: { reason, stopped: true },
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Pause training (can be resumed)
|
|
180
|
+
*/
|
|
181
|
+
pauseTraining() {
|
|
182
|
+
if (!this.state.isTraining)
|
|
183
|
+
return;
|
|
184
|
+
// Mark as paused - training loop will check this
|
|
185
|
+
this.state.isTraining = false;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Resume training after pause
|
|
189
|
+
*/
|
|
190
|
+
async resumeTraining() {
|
|
191
|
+
if (this.state.isTraining) {
|
|
192
|
+
throw new types_1.FederatedError('Training is already active', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
193
|
+
}
|
|
194
|
+
if (this.state.currentRound >= this.state.totalRounds) {
|
|
195
|
+
throw new types_1.FederatedError('Training already completed', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
196
|
+
}
|
|
197
|
+
this.state.isTraining = true;
|
|
198
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.TRAINING;
|
|
199
|
+
try {
|
|
200
|
+
await this.runTrainingLoop();
|
|
201
|
+
this.state.isTraining = false;
|
|
202
|
+
this.state.endTime = Date.now();
|
|
203
|
+
return this.buildTrainingResult(true);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
this.state.isTraining = false;
|
|
207
|
+
this.errors.push(error instanceof Error ? error.message : String(error));
|
|
208
|
+
return this.buildTrainingResult(false);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// ============================================
|
|
212
|
+
// Training Loop
|
|
213
|
+
// ============================================
|
|
214
|
+
/**
|
|
215
|
+
* Main training loop
|
|
216
|
+
*/
|
|
217
|
+
async runTrainingLoop() {
|
|
218
|
+
while (this.state.isTraining &&
|
|
219
|
+
this.state.currentRound < this.state.totalRounds &&
|
|
220
|
+
!this.shouldStopEarly()) {
|
|
221
|
+
// Check privacy budget
|
|
222
|
+
if (this.federatedConfig.differentialPrivacy?.enabled) {
|
|
223
|
+
if (this.aggregator.isPrivacyBudgetExhausted()) {
|
|
224
|
+
this.emitEvent({
|
|
225
|
+
type: types_1.FederatedEventType.PRIVACY_BUDGET_EXHAUSTED,
|
|
226
|
+
timestamp: Date.now(),
|
|
227
|
+
sessionId: this.state.sessionId,
|
|
228
|
+
details: { budget: this.aggregator.getPrivacyBudget() },
|
|
229
|
+
});
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Run a round
|
|
234
|
+
await this.runRound();
|
|
235
|
+
// Check for convergence
|
|
236
|
+
this.updateConvergenceStatus();
|
|
237
|
+
// Create checkpoint if needed
|
|
238
|
+
if (this.state.currentRound % this.federatedConfig.checkpointInterval === 0) {
|
|
239
|
+
await this.createCheckpoint();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Run a single training round
|
|
245
|
+
*/
|
|
246
|
+
async runRound() {
|
|
247
|
+
const roundNumber = this.state.currentRound;
|
|
248
|
+
// Get available participants
|
|
249
|
+
const participants = await this.getAvailableParticipants();
|
|
250
|
+
if (participants.size < this.getMinParticipants()) {
|
|
251
|
+
throw new types_1.FederatedError('Insufficient participants available', types_1.FederatedErrorCode.INSUFFICIENT_PARTICIPANTS);
|
|
252
|
+
}
|
|
253
|
+
// Get current model
|
|
254
|
+
const globalModel = this.modelManager.getWeights();
|
|
255
|
+
if (!globalModel) {
|
|
256
|
+
throw new types_1.FederatedError('No model weights available', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
257
|
+
}
|
|
258
|
+
// Create round configuration
|
|
259
|
+
const roundConfig = {
|
|
260
|
+
sessionId: this.state.sessionId,
|
|
261
|
+
roundNumber,
|
|
262
|
+
federatedConfig: this.federatedConfig,
|
|
263
|
+
globalModel,
|
|
264
|
+
availableParticipants: participants,
|
|
265
|
+
aggregator: this.aggregator,
|
|
266
|
+
sendMessage: this.sendMessage.bind(this),
|
|
267
|
+
broadcastMessage: this.broadcastMessage.bind(this),
|
|
268
|
+
};
|
|
269
|
+
// Create and start round
|
|
270
|
+
const round = new FederatedRound_1.FederatedRound(roundConfig);
|
|
271
|
+
this.state.activeRound = round;
|
|
272
|
+
// Setup round event forwarding
|
|
273
|
+
round.on((event) => {
|
|
274
|
+
this.handleRoundEvent(event, round);
|
|
275
|
+
});
|
|
276
|
+
this.emitEvent({
|
|
277
|
+
type: types_1.FederatedEventType.ROUND_STARTED,
|
|
278
|
+
timestamp: Date.now(),
|
|
279
|
+
sessionId: this.state.sessionId,
|
|
280
|
+
roundId: round.getRoundId(),
|
|
281
|
+
details: { roundNumber },
|
|
282
|
+
});
|
|
283
|
+
try {
|
|
284
|
+
await round.start();
|
|
285
|
+
const result = await round.waitForCompletion();
|
|
286
|
+
// Apply aggregated model
|
|
287
|
+
this.modelManager.applyUpdate(result.aggregatedWeights);
|
|
288
|
+
// Update metrics
|
|
289
|
+
const metrics = round.getMetrics();
|
|
290
|
+
this.lossHistory.push(metrics.aggregatedLoss);
|
|
291
|
+
if (metrics.aggregatedAccuracy !== undefined) {
|
|
292
|
+
this.accuracyHistory.push(metrics.aggregatedAccuracy);
|
|
293
|
+
}
|
|
294
|
+
this.roundHistory.push(metrics);
|
|
295
|
+
// Update best
|
|
296
|
+
if (metrics.aggregatedLoss < this.state.bestLoss) {
|
|
297
|
+
this.state.bestLoss = metrics.aggregatedLoss;
|
|
298
|
+
this.state.bestRound = roundNumber;
|
|
299
|
+
this.state.roundsWithoutImprovement = 0;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this.state.roundsWithoutImprovement++;
|
|
303
|
+
}
|
|
304
|
+
this.emitEvent({
|
|
305
|
+
type: types_1.FederatedEventType.ROUND_COMPLETED,
|
|
306
|
+
timestamp: Date.now(),
|
|
307
|
+
sessionId: this.state.sessionId,
|
|
308
|
+
roundId: round.getRoundId(),
|
|
309
|
+
details: { metrics, result },
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
314
|
+
this.errors.push(`Round ${roundNumber}: ${errorMessage}`);
|
|
315
|
+
this.emitEvent({
|
|
316
|
+
type: types_1.FederatedEventType.ROUND_FAILED,
|
|
317
|
+
timestamp: Date.now(),
|
|
318
|
+
sessionId: this.state.sessionId,
|
|
319
|
+
roundId: round.getRoundId(),
|
|
320
|
+
details: { error: errorMessage },
|
|
321
|
+
});
|
|
322
|
+
// Don't throw - continue to next round if possible
|
|
323
|
+
}
|
|
324
|
+
this.state.activeRound = null;
|
|
325
|
+
this.state.currentRound++;
|
|
326
|
+
}
|
|
327
|
+
// ============================================
|
|
328
|
+
// Convergence Monitoring
|
|
329
|
+
// ============================================
|
|
330
|
+
/**
|
|
331
|
+
* Update convergence status based on training progress
|
|
332
|
+
*/
|
|
333
|
+
updateConvergenceStatus() {
|
|
334
|
+
const criteria = this.federatedConfig.convergence ?? types_1.DEFAULT_CONVERGENCE_CRITERIA;
|
|
335
|
+
// Check if target accuracy reached
|
|
336
|
+
if (criteria.targetAccuracy !== undefined && this.accuracyHistory.length > 0) {
|
|
337
|
+
const latestAccuracy = this.accuracyHistory[this.accuracyHistory.length - 1];
|
|
338
|
+
if (latestAccuracy >= criteria.targetAccuracy) {
|
|
339
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.CONVERGED;
|
|
340
|
+
this.emitEvent({
|
|
341
|
+
type: types_1.FederatedEventType.CONVERGENCE_DETECTED,
|
|
342
|
+
timestamp: Date.now(),
|
|
343
|
+
sessionId: this.state.sessionId,
|
|
344
|
+
details: {
|
|
345
|
+
reason: 'target_accuracy_reached',
|
|
346
|
+
accuracy: latestAccuracy,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// Check loss improvement
|
|
353
|
+
if (this.lossHistory.length >= 2) {
|
|
354
|
+
const prevLoss = this.lossHistory[this.lossHistory.length - 2];
|
|
355
|
+
const currLoss = this.lossHistory[this.lossHistory.length - 1];
|
|
356
|
+
const improvement = (prevLoss - currLoss) / prevLoss;
|
|
357
|
+
if (improvement < criteria.minLossImprovement) {
|
|
358
|
+
// Not improving much
|
|
359
|
+
if (this.state.roundsWithoutImprovement >= criteria.patience) {
|
|
360
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.PLATEAUED;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
else if (currLoss > prevLoss * 1.5) {
|
|
364
|
+
// Loss increasing significantly - diverging
|
|
365
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.DIVERGING;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// Making progress
|
|
369
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.CONVERGING;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
// Check if converged (no improvement for extended period with low variance)
|
|
373
|
+
if (this.state.roundsWithoutImprovement >= criteria.patience * 2) {
|
|
374
|
+
const recentLosses = this.lossHistory.slice(-criteria.patience);
|
|
375
|
+
const variance = this.computeVariance(recentLosses);
|
|
376
|
+
if (variance < 0.001) {
|
|
377
|
+
this.state.convergenceStatus = types_1.ConvergenceStatus.CONVERGED;
|
|
378
|
+
this.emitEvent({
|
|
379
|
+
type: types_1.FederatedEventType.CONVERGENCE_DETECTED,
|
|
380
|
+
timestamp: Date.now(),
|
|
381
|
+
sessionId: this.state.sessionId,
|
|
382
|
+
details: {
|
|
383
|
+
reason: 'loss_stabilized',
|
|
384
|
+
variance,
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Check if early stopping should trigger
|
|
392
|
+
*/
|
|
393
|
+
shouldStopEarly() {
|
|
394
|
+
const criteria = this.federatedConfig.convergence ?? types_1.DEFAULT_CONVERGENCE_CRITERIA;
|
|
395
|
+
if (!criteria.earlyStoppingEnabled)
|
|
396
|
+
return false;
|
|
397
|
+
// Stop if converged
|
|
398
|
+
if (this.state.convergenceStatus === types_1.ConvergenceStatus.CONVERGED) {
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
// Stop if diverging badly
|
|
402
|
+
if (this.state.convergenceStatus === types_1.ConvergenceStatus.DIVERGING) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
// Stop if no improvement for too long
|
|
406
|
+
if (this.state.roundsWithoutImprovement >= criteria.maxRoundsWithoutImprovement) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Compute variance of an array of numbers
|
|
413
|
+
*/
|
|
414
|
+
computeVariance(values) {
|
|
415
|
+
if (values.length < 2)
|
|
416
|
+
return 0;
|
|
417
|
+
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
418
|
+
const squaredDiffs = values.map((v) => (v - mean) ** 2);
|
|
419
|
+
return squaredDiffs.reduce((a, b) => a + b, 0) / values.length;
|
|
420
|
+
}
|
|
421
|
+
// ============================================
|
|
422
|
+
// Participant Management
|
|
423
|
+
// ============================================
|
|
424
|
+
/**
|
|
425
|
+
* Get available participants
|
|
426
|
+
*/
|
|
427
|
+
async getAvailableParticipants() {
|
|
428
|
+
if (this.transport) {
|
|
429
|
+
return await this.transport.getAvailableParticipants();
|
|
430
|
+
}
|
|
431
|
+
// Return empty map if no transport
|
|
432
|
+
return new Map();
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Get minimum required participants
|
|
436
|
+
*/
|
|
437
|
+
getMinParticipants() {
|
|
438
|
+
return Math.max(1, Math.ceil(this.federatedConfig.maxParticipants * this.federatedConfig.minParticipation));
|
|
439
|
+
}
|
|
440
|
+
// ============================================
|
|
441
|
+
// Message Handling
|
|
442
|
+
// ============================================
|
|
443
|
+
/**
|
|
444
|
+
* Setup message handling from transport
|
|
445
|
+
*/
|
|
446
|
+
setupMessageHandling() {
|
|
447
|
+
this.transport.onMessage((participantId, message) => {
|
|
448
|
+
this.handleIncomingMessage(participantId, message);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Handle incoming message
|
|
453
|
+
*/
|
|
454
|
+
handleIncomingMessage(participantId, message) {
|
|
455
|
+
const msg = message;
|
|
456
|
+
switch (msg.type) {
|
|
457
|
+
case 'join_request':
|
|
458
|
+
this.handleJoinRequest(participantId, msg);
|
|
459
|
+
break;
|
|
460
|
+
case 'update_submission':
|
|
461
|
+
this.handleUpdateSubmission(participantId, msg);
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
// Unknown message type
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Handle join request
|
|
470
|
+
*/
|
|
471
|
+
async handleJoinRequest(participantId, request) {
|
|
472
|
+
if (!this.state.activeRound)
|
|
473
|
+
return;
|
|
474
|
+
const response = await this.state.activeRound.handleJoinRequest(request);
|
|
475
|
+
await this.sendMessage(participantId, response);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Handle update submission
|
|
479
|
+
*/
|
|
480
|
+
async handleUpdateSubmission(participantId, submission) {
|
|
481
|
+
if (!this.state.activeRound)
|
|
482
|
+
return;
|
|
483
|
+
await this.state.activeRound.handleUpdateSubmission(submission);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Send message to participant
|
|
487
|
+
*/
|
|
488
|
+
async sendMessage(participantId, message) {
|
|
489
|
+
if (this.transport) {
|
|
490
|
+
await this.transport.send(participantId, message);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Broadcast message to all participants
|
|
495
|
+
*/
|
|
496
|
+
async broadcastMessage(message) {
|
|
497
|
+
if (this.transport) {
|
|
498
|
+
await this.transport.broadcast(message);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
// ============================================
|
|
502
|
+
// Checkpointing
|
|
503
|
+
// ============================================
|
|
504
|
+
/**
|
|
505
|
+
* Create a checkpoint of current state
|
|
506
|
+
*/
|
|
507
|
+
async createCheckpoint() {
|
|
508
|
+
const metrics = this.buildTrainingMetrics();
|
|
509
|
+
const checkpoint = this.modelManager.checkpoint(this.state.sessionId, this.state.currentRound, metrics);
|
|
510
|
+
this.checkpointIds.push(checkpoint.checkpointId);
|
|
511
|
+
this.emitEvent({
|
|
512
|
+
type: types_1.FederatedEventType.CHECKPOINT_SAVED,
|
|
513
|
+
timestamp: Date.now(),
|
|
514
|
+
sessionId: this.state.sessionId,
|
|
515
|
+
details: {
|
|
516
|
+
checkpointId: checkpoint.checkpointId,
|
|
517
|
+
roundNumber: checkpoint.roundNumber,
|
|
518
|
+
},
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Restore from checkpoint
|
|
523
|
+
*/
|
|
524
|
+
restoreFromCheckpoint(checkpointId) {
|
|
525
|
+
this.modelManager.restoreCheckpoint(checkpointId);
|
|
526
|
+
const checkpoints = this.modelManager.getCheckpoints();
|
|
527
|
+
const restored = checkpoints.find((c) => c.checkpointId === checkpointId);
|
|
528
|
+
if (restored) {
|
|
529
|
+
this.state.currentRound = restored.roundNumber;
|
|
530
|
+
this.lossHistory = restored.metrics.lossHistory;
|
|
531
|
+
this.accuracyHistory = restored.metrics.accuracyHistory ?? [];
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Rollback to previous round
|
|
536
|
+
*/
|
|
537
|
+
rollback() {
|
|
538
|
+
return this.modelManager.rollback();
|
|
539
|
+
}
|
|
540
|
+
// ============================================
|
|
541
|
+
// Event Handling
|
|
542
|
+
// ============================================
|
|
543
|
+
/**
|
|
544
|
+
* Handle round events
|
|
545
|
+
*/
|
|
546
|
+
handleRoundEvent(event, round) {
|
|
547
|
+
// Forward relevant events
|
|
548
|
+
switch (event.type) {
|
|
549
|
+
case FederatedRound_1.RoundEventType.PARTICIPANT_JOINED:
|
|
550
|
+
this.emitEvent({
|
|
551
|
+
type: types_1.FederatedEventType.PARTICIPANT_JOINED,
|
|
552
|
+
timestamp: event.timestamp,
|
|
553
|
+
sessionId: this.state.sessionId,
|
|
554
|
+
roundId: round.getRoundId(),
|
|
555
|
+
details: event.details,
|
|
556
|
+
});
|
|
557
|
+
break;
|
|
558
|
+
case FederatedRound_1.RoundEventType.UPDATE_RECEIVED:
|
|
559
|
+
this.emitEvent({
|
|
560
|
+
type: types_1.FederatedEventType.UPDATE_RECEIVED,
|
|
561
|
+
timestamp: event.timestamp,
|
|
562
|
+
sessionId: this.state.sessionId,
|
|
563
|
+
roundId: round.getRoundId(),
|
|
564
|
+
details: event.details,
|
|
565
|
+
});
|
|
566
|
+
break;
|
|
567
|
+
case FederatedRound_1.RoundEventType.AGGREGATION_STARTED:
|
|
568
|
+
this.emitEvent({
|
|
569
|
+
type: types_1.FederatedEventType.AGGREGATION_STARTED,
|
|
570
|
+
timestamp: event.timestamp,
|
|
571
|
+
sessionId: this.state.sessionId,
|
|
572
|
+
roundId: round.getRoundId(),
|
|
573
|
+
details: event.details,
|
|
574
|
+
});
|
|
575
|
+
break;
|
|
576
|
+
case FederatedRound_1.RoundEventType.AGGREGATION_COMPLETED:
|
|
577
|
+
this.emitEvent({
|
|
578
|
+
type: types_1.FederatedEventType.AGGREGATION_COMPLETED,
|
|
579
|
+
timestamp: event.timestamp,
|
|
580
|
+
sessionId: this.state.sessionId,
|
|
581
|
+
roundId: round.getRoundId(),
|
|
582
|
+
details: event.details,
|
|
583
|
+
});
|
|
584
|
+
break;
|
|
585
|
+
case FederatedRound_1.RoundEventType.PARTICIPANT_DROPPED:
|
|
586
|
+
this.emitEvent({
|
|
587
|
+
type: types_1.FederatedEventType.PARTICIPANT_DROPPED,
|
|
588
|
+
timestamp: event.timestamp,
|
|
589
|
+
sessionId: this.state.sessionId,
|
|
590
|
+
roundId: round.getRoundId(),
|
|
591
|
+
details: event.details,
|
|
592
|
+
});
|
|
593
|
+
break;
|
|
594
|
+
case FederatedRound_1.RoundEventType.ROUND_TIMED_OUT:
|
|
595
|
+
this.emitEvent({
|
|
596
|
+
type: types_1.FederatedEventType.ROUND_TIMED_OUT,
|
|
597
|
+
timestamp: event.timestamp,
|
|
598
|
+
sessionId: this.state.sessionId,
|
|
599
|
+
roundId: round.getRoundId(),
|
|
600
|
+
details: event.details,
|
|
601
|
+
});
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Add event handler
|
|
607
|
+
*/
|
|
608
|
+
on(handler) {
|
|
609
|
+
this.eventHandlers.push(handler);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Remove event handler
|
|
613
|
+
*/
|
|
614
|
+
off(handler) {
|
|
615
|
+
const index = this.eventHandlers.indexOf(handler);
|
|
616
|
+
if (index !== -1) {
|
|
617
|
+
this.eventHandlers.splice(index, 1);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Emit event to handlers
|
|
622
|
+
*/
|
|
623
|
+
emitEvent(event) {
|
|
624
|
+
for (const handler of this.eventHandlers) {
|
|
625
|
+
try {
|
|
626
|
+
handler(event);
|
|
627
|
+
}
|
|
628
|
+
catch {
|
|
629
|
+
// Ignore handler errors
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
// ============================================
|
|
634
|
+
// Result Building
|
|
635
|
+
// ============================================
|
|
636
|
+
/**
|
|
637
|
+
* Build training result
|
|
638
|
+
*/
|
|
639
|
+
buildTrainingResult(success) {
|
|
640
|
+
return {
|
|
641
|
+
success,
|
|
642
|
+
finalModel: this.modelManager.getWeights(),
|
|
643
|
+
metrics: this.buildTrainingMetrics(),
|
|
644
|
+
privacyBudget: this.federatedConfig.differentialPrivacy?.enabled
|
|
645
|
+
? this.aggregator.getPrivacyBudget()
|
|
646
|
+
: undefined,
|
|
647
|
+
checkpoints: this.checkpointIds,
|
|
648
|
+
errors: this.errors,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Build training metrics summary
|
|
653
|
+
*/
|
|
654
|
+
buildTrainingMetrics() {
|
|
655
|
+
const avgParticipation = this.roundHistory.length > 0
|
|
656
|
+
? this.roundHistory.reduce((sum, r) => sum + r.participationRate, 0) / this.roundHistory.length
|
|
657
|
+
: 0;
|
|
658
|
+
const totalCommBytes = this.roundHistory.reduce((sum, r) => sum + r.communicationBytes, 0);
|
|
659
|
+
return {
|
|
660
|
+
currentRound: this.state.currentRound,
|
|
661
|
+
totalRounds: this.state.totalRounds,
|
|
662
|
+
bestLoss: this.state.bestLoss,
|
|
663
|
+
bestRound: this.state.bestRound,
|
|
664
|
+
lossHistory: this.lossHistory,
|
|
665
|
+
accuracyHistory: this.accuracyHistory.length > 0 ? this.accuracyHistory : undefined,
|
|
666
|
+
convergenceStatus: this.state.convergenceStatus,
|
|
667
|
+
startTime: this.state.startTime ?? Date.now(),
|
|
668
|
+
totalTrainingTime: this.state.endTime
|
|
669
|
+
? this.state.endTime - (this.state.startTime ?? 0)
|
|
670
|
+
: Date.now() - (this.state.startTime ?? Date.now()),
|
|
671
|
+
totalCommunicationBytes: totalCommBytes,
|
|
672
|
+
avgParticipationRate: avgParticipation,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
// ============================================
|
|
676
|
+
// Validation
|
|
677
|
+
// ============================================
|
|
678
|
+
/**
|
|
679
|
+
* Validate configuration
|
|
680
|
+
*/
|
|
681
|
+
validateConfiguration() {
|
|
682
|
+
if (!this.federatedConfig.sessionId) {
|
|
683
|
+
throw new types_1.FederatedError('Session ID is required', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
684
|
+
}
|
|
685
|
+
if (!this.federatedConfig.modelId) {
|
|
686
|
+
throw new types_1.FederatedError('Model ID is required', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
687
|
+
}
|
|
688
|
+
if (this.federatedConfig.totalRounds < 1) {
|
|
689
|
+
throw new types_1.FederatedError('Total rounds must be at least 1', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
690
|
+
}
|
|
691
|
+
if (this.federatedConfig.minParticipation < 0 || this.federatedConfig.minParticipation > 1) {
|
|
692
|
+
throw new types_1.FederatedError('Min participation must be between 0 and 1', types_1.FederatedErrorCode.INVALID_CONFIG);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
// ============================================
|
|
696
|
+
// Getters
|
|
697
|
+
// ============================================
|
|
698
|
+
/**
|
|
699
|
+
* Get session ID
|
|
700
|
+
*/
|
|
701
|
+
getSessionId() {
|
|
702
|
+
return this.state.sessionId;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Check if training is active
|
|
706
|
+
*/
|
|
707
|
+
isTraining() {
|
|
708
|
+
return this.state.isTraining;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Get current round number
|
|
712
|
+
*/
|
|
713
|
+
getCurrentRound() {
|
|
714
|
+
return this.state.currentRound;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Get convergence status
|
|
718
|
+
*/
|
|
719
|
+
getConvergenceStatus() {
|
|
720
|
+
return this.state.convergenceStatus;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Get current model weights
|
|
724
|
+
*/
|
|
725
|
+
getModel() {
|
|
726
|
+
return this.modelManager.getWeights();
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Get model manager
|
|
730
|
+
*/
|
|
731
|
+
getModelManager() {
|
|
732
|
+
return this.modelManager;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Get aggregator
|
|
736
|
+
*/
|
|
737
|
+
getAggregator() {
|
|
738
|
+
return this.aggregator;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Get active round
|
|
742
|
+
*/
|
|
743
|
+
getActiveRound() {
|
|
744
|
+
return this.state.activeRound;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Get training metrics
|
|
748
|
+
*/
|
|
749
|
+
getMetrics() {
|
|
750
|
+
return this.buildTrainingMetrics();
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Get privacy budget
|
|
754
|
+
*/
|
|
755
|
+
getPrivacyBudget() {
|
|
756
|
+
if (!this.federatedConfig.differentialPrivacy?.enabled) {
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
return this.aggregator.getPrivacyBudget();
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Get checkpoints
|
|
763
|
+
*/
|
|
764
|
+
getCheckpoints() {
|
|
765
|
+
return this.modelManager.getCheckpoints();
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Get configuration
|
|
769
|
+
*/
|
|
770
|
+
getConfig() {
|
|
771
|
+
return { ...this.federatedConfig };
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Reset coordinator state
|
|
775
|
+
*/
|
|
776
|
+
reset() {
|
|
777
|
+
if (this.state.isTraining) {
|
|
778
|
+
this.stopTraining('Reset requested');
|
|
779
|
+
}
|
|
780
|
+
this.state = {
|
|
781
|
+
sessionId: this.federatedConfig.sessionId,
|
|
782
|
+
isTraining: false,
|
|
783
|
+
currentRound: 0,
|
|
784
|
+
totalRounds: this.federatedConfig.totalRounds,
|
|
785
|
+
activeRound: null,
|
|
786
|
+
convergenceStatus: types_1.ConvergenceStatus.NOT_STARTED,
|
|
787
|
+
startTime: null,
|
|
788
|
+
endTime: null,
|
|
789
|
+
roundsWithoutImprovement: 0,
|
|
790
|
+
bestLoss: Infinity,
|
|
791
|
+
bestRound: 0,
|
|
792
|
+
};
|
|
793
|
+
this.modelManager.reset();
|
|
794
|
+
this.aggregator.reset();
|
|
795
|
+
this.checkpointIds = [];
|
|
796
|
+
this.errors = [];
|
|
797
|
+
this.lossHistory = [];
|
|
798
|
+
this.accuracyHistory = [];
|
|
799
|
+
this.roundHistory = [];
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
exports.FederatedCoordinator = FederatedCoordinator;
|
|
803
|
+
// ============================================
|
|
804
|
+
// Factory Functions
|
|
805
|
+
// ============================================
|
|
806
|
+
/**
|
|
807
|
+
* Create a new federated coordinator
|
|
808
|
+
*/
|
|
809
|
+
function createFederatedCoordinator(config) {
|
|
810
|
+
return new FederatedCoordinator(config);
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Create a minimal federated config
|
|
814
|
+
*/
|
|
815
|
+
function createFederatedConfig(sessionId, modelId, totalRounds, options) {
|
|
816
|
+
return {
|
|
817
|
+
...types_1.DEFAULT_FEDERATED_CONFIG,
|
|
818
|
+
...options,
|
|
819
|
+
sessionId,
|
|
820
|
+
modelId,
|
|
821
|
+
totalRounds,
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
//# sourceMappingURL=FederatedCoordinator.js.map
|