agentic-qe 2.7.4 → 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 +104 -0
- package/README.md +67 -2
- 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/planning/GOAPPlanner.d.ts +1 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +12 -0
- package/dist/planning/GOAPPlanner.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,696 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pattern Serializer for Binary Encoding and Anonymization
|
|
4
|
+
*
|
|
5
|
+
* Provides efficient binary serialization of patterns for P2P transmission,
|
|
6
|
+
* along with privacy-preserving anonymization and differential privacy helpers.
|
|
7
|
+
*
|
|
8
|
+
* @module edge/p2p/sharing/PatternSerializer
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PatternSerializer = void 0;
|
|
13
|
+
exports.createPatternSerializer = createPatternSerializer;
|
|
14
|
+
exports.serializePattern = serializePattern;
|
|
15
|
+
exports.deserializePattern = deserializePattern;
|
|
16
|
+
exports.anonymizePattern = anonymizePattern;
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
// ============================================
|
|
19
|
+
// Constants
|
|
20
|
+
// ============================================
|
|
21
|
+
/**
|
|
22
|
+
* Magic bytes for pattern binary format
|
|
23
|
+
*/
|
|
24
|
+
const MAGIC_BYTES = new Uint8Array([0x50, 0x41, 0x54, 0x54]); // "PATT"
|
|
25
|
+
/**
|
|
26
|
+
* Binary format version
|
|
27
|
+
*/
|
|
28
|
+
const FORMAT_VERSION = 1;
|
|
29
|
+
/**
|
|
30
|
+
* Reserved keywords to preserve during anonymization
|
|
31
|
+
*/
|
|
32
|
+
const RESERVED_KEYWORDS = new Set([
|
|
33
|
+
// JavaScript/TypeScript keywords
|
|
34
|
+
'async',
|
|
35
|
+
'await',
|
|
36
|
+
'break',
|
|
37
|
+
'case',
|
|
38
|
+
'catch',
|
|
39
|
+
'class',
|
|
40
|
+
'const',
|
|
41
|
+
'continue',
|
|
42
|
+
'debugger',
|
|
43
|
+
'default',
|
|
44
|
+
'delete',
|
|
45
|
+
'do',
|
|
46
|
+
'else',
|
|
47
|
+
'enum',
|
|
48
|
+
'export',
|
|
49
|
+
'extends',
|
|
50
|
+
'false',
|
|
51
|
+
'finally',
|
|
52
|
+
'for',
|
|
53
|
+
'function',
|
|
54
|
+
'if',
|
|
55
|
+
'implements',
|
|
56
|
+
'import',
|
|
57
|
+
'in',
|
|
58
|
+
'instanceof',
|
|
59
|
+
'interface',
|
|
60
|
+
'let',
|
|
61
|
+
'new',
|
|
62
|
+
'null',
|
|
63
|
+
'package',
|
|
64
|
+
'private',
|
|
65
|
+
'protected',
|
|
66
|
+
'public',
|
|
67
|
+
'return',
|
|
68
|
+
'static',
|
|
69
|
+
'super',
|
|
70
|
+
'switch',
|
|
71
|
+
'this',
|
|
72
|
+
'throw',
|
|
73
|
+
'true',
|
|
74
|
+
'try',
|
|
75
|
+
'typeof',
|
|
76
|
+
'undefined',
|
|
77
|
+
'var',
|
|
78
|
+
'void',
|
|
79
|
+
'while',
|
|
80
|
+
'with',
|
|
81
|
+
'yield',
|
|
82
|
+
// Common types
|
|
83
|
+
'string',
|
|
84
|
+
'number',
|
|
85
|
+
'boolean',
|
|
86
|
+
'object',
|
|
87
|
+
'any',
|
|
88
|
+
'unknown',
|
|
89
|
+
'never',
|
|
90
|
+
'void',
|
|
91
|
+
'Array',
|
|
92
|
+
'Promise',
|
|
93
|
+
'Map',
|
|
94
|
+
'Set',
|
|
95
|
+
'Date',
|
|
96
|
+
'Error',
|
|
97
|
+
'RegExp',
|
|
98
|
+
'JSON',
|
|
99
|
+
'Math',
|
|
100
|
+
'console',
|
|
101
|
+
// Testing
|
|
102
|
+
'describe',
|
|
103
|
+
'it',
|
|
104
|
+
'test',
|
|
105
|
+
'expect',
|
|
106
|
+
'jest',
|
|
107
|
+
'beforeEach',
|
|
108
|
+
'afterEach',
|
|
109
|
+
'beforeAll',
|
|
110
|
+
'afterAll',
|
|
111
|
+
'mock',
|
|
112
|
+
'spy',
|
|
113
|
+
]);
|
|
114
|
+
// ============================================
|
|
115
|
+
// Pattern Serializer Class
|
|
116
|
+
// ============================================
|
|
117
|
+
/**
|
|
118
|
+
* Serializes and deserializes patterns for P2P transmission
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const serializer = new PatternSerializer();
|
|
123
|
+
*
|
|
124
|
+
* // Serialize a pattern
|
|
125
|
+
* const binary = serializer.serialize(pattern);
|
|
126
|
+
*
|
|
127
|
+
* // Deserialize
|
|
128
|
+
* const restored = serializer.deserialize(binary);
|
|
129
|
+
*
|
|
130
|
+
* // Anonymize content
|
|
131
|
+
* const anonymized = serializer.anonymize(pattern);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
class PatternSerializer {
|
|
135
|
+
constructor(anonymizationConfig) {
|
|
136
|
+
this.textEncoder = new TextEncoder();
|
|
137
|
+
this.textDecoder = new TextDecoder();
|
|
138
|
+
this.anonymizationConfig = {
|
|
139
|
+
...types_1.DEFAULT_ANONYMIZATION_CONFIG,
|
|
140
|
+
...anonymizationConfig,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// ============================================
|
|
144
|
+
// Serialization
|
|
145
|
+
// ============================================
|
|
146
|
+
/**
|
|
147
|
+
* Serialize a pattern to binary format
|
|
148
|
+
*
|
|
149
|
+
* Binary format:
|
|
150
|
+
* - 4 bytes: Magic "PATT"
|
|
151
|
+
* - 1 byte: Format version
|
|
152
|
+
* - 4 bytes: Total length (BE)
|
|
153
|
+
* - 4 bytes: Embedding length (BE)
|
|
154
|
+
* - N bytes: Embedding (Float32Array)
|
|
155
|
+
* - 4 bytes: JSON length (BE)
|
|
156
|
+
* - M bytes: JSON payload (UTF-8)
|
|
157
|
+
* - 32 bytes: SHA-256 checksum
|
|
158
|
+
*/
|
|
159
|
+
async serialize(pattern) {
|
|
160
|
+
// Convert embedding to Float32Array
|
|
161
|
+
const embedding = this.normalizeEmbedding(pattern.embedding);
|
|
162
|
+
const embeddingBytes = new Uint8Array(embedding.buffer);
|
|
163
|
+
// Create JSON payload (without embedding)
|
|
164
|
+
const jsonPayload = this.createJsonPayload(pattern);
|
|
165
|
+
const jsonBytes = this.textEncoder.encode(jsonPayload);
|
|
166
|
+
// Calculate total size
|
|
167
|
+
const totalSize = 4 + // magic
|
|
168
|
+
1 + // version
|
|
169
|
+
4 + // total length
|
|
170
|
+
4 + // embedding length
|
|
171
|
+
embeddingBytes.length +
|
|
172
|
+
4 + // json length
|
|
173
|
+
jsonBytes.length +
|
|
174
|
+
32; // checksum
|
|
175
|
+
if (totalSize > types_1.MAX_PATTERN_SIZE) {
|
|
176
|
+
throw new types_1.SharingError(`Pattern size ${totalSize} exceeds maximum ${types_1.MAX_PATTERN_SIZE}`, types_1.SharingErrorCode.PATTERN_TOO_LARGE);
|
|
177
|
+
}
|
|
178
|
+
// Build buffer
|
|
179
|
+
const buffer = new ArrayBuffer(totalSize);
|
|
180
|
+
const view = new DataView(buffer);
|
|
181
|
+
const bytes = new Uint8Array(buffer);
|
|
182
|
+
let offset = 0;
|
|
183
|
+
// Magic bytes
|
|
184
|
+
bytes.set(MAGIC_BYTES, offset);
|
|
185
|
+
offset += 4;
|
|
186
|
+
// Version
|
|
187
|
+
view.setUint8(offset, FORMAT_VERSION);
|
|
188
|
+
offset += 1;
|
|
189
|
+
// Total length
|
|
190
|
+
view.setUint32(offset, totalSize, false);
|
|
191
|
+
offset += 4;
|
|
192
|
+
// Embedding length
|
|
193
|
+
view.setUint32(offset, embeddingBytes.length, false);
|
|
194
|
+
offset += 4;
|
|
195
|
+
// Embedding
|
|
196
|
+
bytes.set(embeddingBytes, offset);
|
|
197
|
+
offset += embeddingBytes.length;
|
|
198
|
+
// JSON length
|
|
199
|
+
view.setUint32(offset, jsonBytes.length, false);
|
|
200
|
+
offset += 4;
|
|
201
|
+
// JSON
|
|
202
|
+
bytes.set(jsonBytes, offset);
|
|
203
|
+
offset += jsonBytes.length;
|
|
204
|
+
// Checksum
|
|
205
|
+
const dataToHash = bytes.slice(0, offset);
|
|
206
|
+
const checksum = await this.sha256(dataToHash);
|
|
207
|
+
bytes.set(new Uint8Array(checksum), offset);
|
|
208
|
+
return bytes;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Deserialize a pattern from binary format
|
|
212
|
+
*/
|
|
213
|
+
async deserialize(data) {
|
|
214
|
+
if (data.length < 45) {
|
|
215
|
+
// Minimum size
|
|
216
|
+
throw new types_1.SharingError('Invalid binary data: too short', types_1.SharingErrorCode.SERIALIZATION_ERROR);
|
|
217
|
+
}
|
|
218
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
219
|
+
let offset = 0;
|
|
220
|
+
// Verify magic bytes
|
|
221
|
+
const magic = data.slice(offset, offset + 4);
|
|
222
|
+
if (!this.arrayEquals(magic, MAGIC_BYTES)) {
|
|
223
|
+
throw new types_1.SharingError('Invalid binary data: wrong magic bytes', types_1.SharingErrorCode.SERIALIZATION_ERROR);
|
|
224
|
+
}
|
|
225
|
+
offset += 4;
|
|
226
|
+
// Version
|
|
227
|
+
const version = view.getUint8(offset);
|
|
228
|
+
if (version > FORMAT_VERSION) {
|
|
229
|
+
throw new types_1.SharingError(`Unsupported format version: ${version}`, types_1.SharingErrorCode.SERIALIZATION_ERROR);
|
|
230
|
+
}
|
|
231
|
+
offset += 1;
|
|
232
|
+
// Total length
|
|
233
|
+
const totalLength = view.getUint32(offset, false);
|
|
234
|
+
if (totalLength !== data.length) {
|
|
235
|
+
throw new types_1.SharingError(`Length mismatch: expected ${totalLength}, got ${data.length}`, types_1.SharingErrorCode.SERIALIZATION_ERROR);
|
|
236
|
+
}
|
|
237
|
+
offset += 4;
|
|
238
|
+
// Embedding length
|
|
239
|
+
const embeddingLength = view.getUint32(offset, false);
|
|
240
|
+
offset += 4;
|
|
241
|
+
// Embedding
|
|
242
|
+
const embeddingBytes = data.slice(offset, offset + embeddingLength);
|
|
243
|
+
const embedding = new Float32Array(embeddingBytes.buffer, embeddingBytes.byteOffset, embeddingLength / 4);
|
|
244
|
+
offset += embeddingLength;
|
|
245
|
+
// JSON length
|
|
246
|
+
const jsonLength = view.getUint32(offset, false);
|
|
247
|
+
offset += 4;
|
|
248
|
+
// JSON
|
|
249
|
+
const jsonBytes = data.slice(offset, offset + jsonLength);
|
|
250
|
+
const jsonPayload = this.textDecoder.decode(jsonBytes);
|
|
251
|
+
offset += jsonLength;
|
|
252
|
+
// Checksum
|
|
253
|
+
const storedChecksum = data.slice(offset, offset + 32);
|
|
254
|
+
const dataToHash = data.slice(0, offset);
|
|
255
|
+
const computedChecksum = await this.sha256(dataToHash);
|
|
256
|
+
if (!this.arrayEquals(new Uint8Array(storedChecksum), new Uint8Array(computedChecksum))) {
|
|
257
|
+
throw new types_1.SharingError('Checksum verification failed', types_1.SharingErrorCode.SERIALIZATION_ERROR);
|
|
258
|
+
}
|
|
259
|
+
// Parse JSON and reconstruct pattern
|
|
260
|
+
const parsed = JSON.parse(jsonPayload);
|
|
261
|
+
return {
|
|
262
|
+
...parsed,
|
|
263
|
+
embedding: Array.from(embedding),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Serialize pattern summary (lightweight)
|
|
268
|
+
*/
|
|
269
|
+
serializeSummary(summary) {
|
|
270
|
+
const json = JSON.stringify(summary);
|
|
271
|
+
return this.textEncoder.encode(json);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Deserialize pattern summary
|
|
275
|
+
*/
|
|
276
|
+
deserializeSummary(data) {
|
|
277
|
+
const json = this.textDecoder.decode(data);
|
|
278
|
+
return JSON.parse(json);
|
|
279
|
+
}
|
|
280
|
+
// ============================================
|
|
281
|
+
// Anonymization
|
|
282
|
+
// ============================================
|
|
283
|
+
/**
|
|
284
|
+
* Anonymize a pattern's content
|
|
285
|
+
*/
|
|
286
|
+
anonymize(pattern, config) {
|
|
287
|
+
const cfg = { ...this.anonymizationConfig, ...config };
|
|
288
|
+
const result = this.anonymizeContent(pattern.content.raw, cfg);
|
|
289
|
+
return {
|
|
290
|
+
...pattern,
|
|
291
|
+
content: {
|
|
292
|
+
...pattern.content,
|
|
293
|
+
anonymized: result.content,
|
|
294
|
+
},
|
|
295
|
+
metadata: this.anonymizeMetadata(pattern.metadata),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Anonymize content string
|
|
300
|
+
*/
|
|
301
|
+
anonymizeContent(content, config) {
|
|
302
|
+
const stats = {
|
|
303
|
+
identifiersReplaced: 0,
|
|
304
|
+
stringsReplaced: 0,
|
|
305
|
+
numbersReplaced: 0,
|
|
306
|
+
commentsRemoved: 0,
|
|
307
|
+
charactersChanged: 0,
|
|
308
|
+
};
|
|
309
|
+
let result = content;
|
|
310
|
+
const originalLength = content.length;
|
|
311
|
+
const mapping = {};
|
|
312
|
+
// Identifier counter for consistent replacement
|
|
313
|
+
let identifierCounter = 0;
|
|
314
|
+
const identifierMap = new Map();
|
|
315
|
+
// Remove comments if configured
|
|
316
|
+
if (config.removeComments) {
|
|
317
|
+
const before = result.length;
|
|
318
|
+
result = this.removeComments(result);
|
|
319
|
+
stats.commentsRemoved = Math.max(0, before - result.length);
|
|
320
|
+
}
|
|
321
|
+
// Replace string literals
|
|
322
|
+
if (config.replaceStrings) {
|
|
323
|
+
result = result.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g, (match, quote) => {
|
|
324
|
+
const isTemplateString = quote === '`' && match.includes('${');
|
|
325
|
+
if (isTemplateString && config.preserveStructure) {
|
|
326
|
+
// Preserve template structure but anonymize content
|
|
327
|
+
return match.replace(/\$\{[^}]+\}/g, '${var}');
|
|
328
|
+
}
|
|
329
|
+
stats.stringsReplaced++;
|
|
330
|
+
const replacement = `${quote}str_${stats.stringsReplaced}${quote}`;
|
|
331
|
+
mapping[match] = replacement;
|
|
332
|
+
return replacement;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// Replace numbers
|
|
336
|
+
if (config.replaceNumbers) {
|
|
337
|
+
result = result.replace(/\b\d+(\.\d+)?\b/g, (match) => {
|
|
338
|
+
stats.numbersReplaced++;
|
|
339
|
+
return '0';
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// Replace identifiers
|
|
343
|
+
if (config.replaceIdentifiers) {
|
|
344
|
+
const preserveWords = new Set([
|
|
345
|
+
...RESERVED_KEYWORDS,
|
|
346
|
+
...(config.preserveWords || []),
|
|
347
|
+
]);
|
|
348
|
+
result = result.replace(/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g, (match) => {
|
|
349
|
+
// Skip reserved words
|
|
350
|
+
if (preserveWords.has(match) || preserveWords.has(match.toLowerCase())) {
|
|
351
|
+
return match;
|
|
352
|
+
}
|
|
353
|
+
// Skip short identifiers (likely loop variables)
|
|
354
|
+
if (match.length <= 2) {
|
|
355
|
+
return match;
|
|
356
|
+
}
|
|
357
|
+
// Check if already mapped
|
|
358
|
+
if (identifierMap.has(match)) {
|
|
359
|
+
return identifierMap.get(match);
|
|
360
|
+
}
|
|
361
|
+
// Create new mapping
|
|
362
|
+
const replacement = `var_${identifierCounter++}`;
|
|
363
|
+
identifierMap.set(match, replacement);
|
|
364
|
+
mapping[match] = replacement;
|
|
365
|
+
stats.identifiersReplaced++;
|
|
366
|
+
return replacement;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
// Replace file paths
|
|
370
|
+
if (config.replaceFilePaths) {
|
|
371
|
+
result = result.replace(/(['"`])([\/\\]?(?:[\w.-]+[\/\\])+[\w.-]+)\1/g, (match, quote) => {
|
|
372
|
+
return `${quote}/path/to/file${quote}`;
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
// Apply custom patterns
|
|
376
|
+
if (config.customPatterns) {
|
|
377
|
+
for (const pattern of config.customPatterns) {
|
|
378
|
+
result = result.replace(pattern, '[REDACTED]');
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
stats.charactersChanged = Math.abs(result.length - originalLength);
|
|
382
|
+
return {
|
|
383
|
+
content: result,
|
|
384
|
+
mapping,
|
|
385
|
+
stats,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Anonymize metadata
|
|
390
|
+
*/
|
|
391
|
+
anonymizeMetadata(metadata) {
|
|
392
|
+
return {
|
|
393
|
+
...metadata,
|
|
394
|
+
sourceId: metadata.sourceId ? this.hashIdentifier(metadata.sourceId) : undefined,
|
|
395
|
+
filePath: metadata.filePath ? '/path/to/file' : undefined,
|
|
396
|
+
custom: undefined, // Remove custom metadata
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Remove comments from code
|
|
401
|
+
*/
|
|
402
|
+
removeComments(code) {
|
|
403
|
+
// Remove single-line comments
|
|
404
|
+
let result = code.replace(/\/\/.*$/gm, '');
|
|
405
|
+
// Remove multi-line comments
|
|
406
|
+
result = result.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
// ============================================
|
|
410
|
+
// Differential Privacy
|
|
411
|
+
// ============================================
|
|
412
|
+
/**
|
|
413
|
+
* Apply differential privacy to an embedding
|
|
414
|
+
*/
|
|
415
|
+
applyDifferentialPrivacy(embedding, config) {
|
|
416
|
+
const dpConfig = {
|
|
417
|
+
epsilon: config?.epsilon ?? types_1.DEFAULT_DP_EPSILON,
|
|
418
|
+
delta: config?.delta ?? types_1.DEFAULT_DP_DELTA,
|
|
419
|
+
mechanism: config?.mechanism ?? 'laplace',
|
|
420
|
+
sensitivity: config?.sensitivity ?? 1.0,
|
|
421
|
+
clipNorm: config?.clipNorm ?? 1.0,
|
|
422
|
+
};
|
|
423
|
+
// Convert to Float32Array
|
|
424
|
+
const input = embedding instanceof Float32Array
|
|
425
|
+
? embedding
|
|
426
|
+
: new Float32Array(embedding);
|
|
427
|
+
// Clip to bounded norm
|
|
428
|
+
const clipped = this.clipToNorm(input, dpConfig.clipNorm);
|
|
429
|
+
// Add noise based on mechanism
|
|
430
|
+
const noised = dpConfig.mechanism === 'laplace'
|
|
431
|
+
? this.addLaplaceNoise(clipped, dpConfig.epsilon, dpConfig.sensitivity)
|
|
432
|
+
: this.addGaussianNoise(clipped, dpConfig.epsilon, dpConfig.delta, dpConfig.sensitivity);
|
|
433
|
+
// Calculate noise magnitude
|
|
434
|
+
const noiseMagnitude = this.calculateNoiseMagnitude(input, noised);
|
|
435
|
+
return {
|
|
436
|
+
data: noised,
|
|
437
|
+
noiseMagnitude,
|
|
438
|
+
budgetConsumed: dpConfig.epsilon,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Clip embedding to bounded L2 norm
|
|
443
|
+
*/
|
|
444
|
+
clipToNorm(embedding, maxNorm) {
|
|
445
|
+
let norm = 0;
|
|
446
|
+
for (let i = 0; i < embedding.length; i++) {
|
|
447
|
+
norm += embedding[i] * embedding[i];
|
|
448
|
+
}
|
|
449
|
+
norm = Math.sqrt(norm);
|
|
450
|
+
if (norm <= maxNorm) {
|
|
451
|
+
return embedding;
|
|
452
|
+
}
|
|
453
|
+
const scale = maxNorm / norm;
|
|
454
|
+
const result = new Float32Array(embedding.length);
|
|
455
|
+
for (let i = 0; i < embedding.length; i++) {
|
|
456
|
+
result[i] = embedding[i] * scale;
|
|
457
|
+
}
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Add Laplace noise for differential privacy
|
|
462
|
+
*/
|
|
463
|
+
addLaplaceNoise(embedding, epsilon, sensitivity) {
|
|
464
|
+
const scale = sensitivity / epsilon;
|
|
465
|
+
const result = new Float32Array(embedding.length);
|
|
466
|
+
for (let i = 0; i < embedding.length; i++) {
|
|
467
|
+
result[i] = embedding[i] + this.sampleLaplace(scale);
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Add Gaussian noise for differential privacy
|
|
473
|
+
*/
|
|
474
|
+
addGaussianNoise(embedding, epsilon, delta, sensitivity) {
|
|
475
|
+
// Compute sigma for (epsilon, delta)-DP
|
|
476
|
+
const sigma = (sensitivity * Math.sqrt(2 * Math.log(1.25 / delta))) / epsilon;
|
|
477
|
+
const result = new Float32Array(embedding.length);
|
|
478
|
+
for (let i = 0; i < embedding.length; i++) {
|
|
479
|
+
result[i] = embedding[i] + this.sampleGaussian(0, sigma);
|
|
480
|
+
}
|
|
481
|
+
return result;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Sample from Laplace distribution
|
|
485
|
+
*/
|
|
486
|
+
sampleLaplace(scale) {
|
|
487
|
+
const u = Math.random() - 0.5;
|
|
488
|
+
return -scale * Math.sign(u) * Math.log(1 - 2 * Math.abs(u));
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Sample from Gaussian distribution (Box-Muller transform)
|
|
492
|
+
*/
|
|
493
|
+
sampleGaussian(mean, stddev) {
|
|
494
|
+
const u1 = Math.random();
|
|
495
|
+
const u2 = Math.random();
|
|
496
|
+
const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
|
|
497
|
+
return mean + stddev * z;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Calculate noise magnitude (L2 distance)
|
|
501
|
+
*/
|
|
502
|
+
calculateNoiseMagnitude(original, noised) {
|
|
503
|
+
let sum = 0;
|
|
504
|
+
for (let i = 0; i < original.length; i++) {
|
|
505
|
+
const diff = original[i] - noised[i];
|
|
506
|
+
sum += diff * diff;
|
|
507
|
+
}
|
|
508
|
+
return Math.sqrt(sum);
|
|
509
|
+
}
|
|
510
|
+
// ============================================
|
|
511
|
+
// Utility Methods
|
|
512
|
+
// ============================================
|
|
513
|
+
/**
|
|
514
|
+
* Create JSON payload (pattern without embedding)
|
|
515
|
+
*/
|
|
516
|
+
createJsonPayload(pattern) {
|
|
517
|
+
const { embedding, ...rest } = pattern;
|
|
518
|
+
return JSON.stringify(rest);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Normalize embedding to Float32Array
|
|
522
|
+
*/
|
|
523
|
+
normalizeEmbedding(embedding) {
|
|
524
|
+
if (embedding instanceof Float32Array) {
|
|
525
|
+
return embedding;
|
|
526
|
+
}
|
|
527
|
+
return new Float32Array(embedding);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Calculate SHA-256 hash
|
|
531
|
+
*/
|
|
532
|
+
async sha256(data) {
|
|
533
|
+
if (typeof crypto !== 'undefined' && crypto.subtle) {
|
|
534
|
+
return crypto.subtle.digest('SHA-256', data.buffer);
|
|
535
|
+
}
|
|
536
|
+
// Fallback for environments without SubtleCrypto
|
|
537
|
+
// Simple hash function (not cryptographically secure, but works for checksums)
|
|
538
|
+
const hash = new Uint8Array(32);
|
|
539
|
+
for (let i = 0; i < data.length; i++) {
|
|
540
|
+
hash[i % 32] ^= data[i];
|
|
541
|
+
hash[(i + 1) % 32] = (hash[(i + 1) % 32] + data[i]) % 256;
|
|
542
|
+
}
|
|
543
|
+
return hash.buffer;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Hash an identifier for anonymization
|
|
547
|
+
*/
|
|
548
|
+
hashIdentifier(id) {
|
|
549
|
+
let hash = 0;
|
|
550
|
+
for (let i = 0; i < id.length; i++) {
|
|
551
|
+
const char = id.charCodeAt(i);
|
|
552
|
+
hash = ((hash << 5) - hash) + char;
|
|
553
|
+
hash = hash & hash;
|
|
554
|
+
}
|
|
555
|
+
return `anon_${Math.abs(hash).toString(36)}`;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Compare two arrays for equality
|
|
559
|
+
*/
|
|
560
|
+
arrayEquals(a, b) {
|
|
561
|
+
if (a.length !== b.length)
|
|
562
|
+
return false;
|
|
563
|
+
for (let i = 0; i < a.length; i++) {
|
|
564
|
+
if (a[i] !== b[i])
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Calculate content hash
|
|
571
|
+
*/
|
|
572
|
+
async calculateContentHash(content) {
|
|
573
|
+
const data = this.textEncoder.encode(content);
|
|
574
|
+
const hash = await this.sha256(data);
|
|
575
|
+
const bytes = new Uint8Array(hash);
|
|
576
|
+
return Array.from(bytes)
|
|
577
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
578
|
+
.join('');
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Create a pattern from raw components
|
|
582
|
+
*/
|
|
583
|
+
createPattern(id, category, type, domain, content, embedding, options) {
|
|
584
|
+
const now = new Date().toISOString();
|
|
585
|
+
const contentHash = this.simpleHash(content);
|
|
586
|
+
return {
|
|
587
|
+
id,
|
|
588
|
+
category,
|
|
589
|
+
type,
|
|
590
|
+
domain,
|
|
591
|
+
content: {
|
|
592
|
+
raw: content,
|
|
593
|
+
contentHash,
|
|
594
|
+
language: options?.language || 'typescript',
|
|
595
|
+
framework: options?.framework,
|
|
596
|
+
},
|
|
597
|
+
embedding: Array.from(embedding),
|
|
598
|
+
metadata: {
|
|
599
|
+
name: options?.name,
|
|
600
|
+
description: options?.description,
|
|
601
|
+
tags: options?.tags || [],
|
|
602
|
+
},
|
|
603
|
+
version: {
|
|
604
|
+
semver: '1.0.0',
|
|
605
|
+
vectorClock: { clock: {} },
|
|
606
|
+
},
|
|
607
|
+
quality: {
|
|
608
|
+
level: types_1.PatternQuality.UNVERIFIED,
|
|
609
|
+
successRate: 0,
|
|
610
|
+
usageCount: 0,
|
|
611
|
+
uniqueUsers: 0,
|
|
612
|
+
avgConfidence: 0,
|
|
613
|
+
feedbackScore: 0,
|
|
614
|
+
},
|
|
615
|
+
sharing: {
|
|
616
|
+
policy: types_1.SharingPolicy.PUBLIC,
|
|
617
|
+
privacyLevel: types_1.PrivacyLevel.ANONYMIZED,
|
|
618
|
+
differentialPrivacy: false,
|
|
619
|
+
redistributable: true,
|
|
620
|
+
requireAttribution: false,
|
|
621
|
+
},
|
|
622
|
+
createdAt: now,
|
|
623
|
+
updatedAt: now,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Simple synchronous hash for content
|
|
628
|
+
*/
|
|
629
|
+
simpleHash(content) {
|
|
630
|
+
let hash = 0;
|
|
631
|
+
for (let i = 0; i < content.length; i++) {
|
|
632
|
+
const char = content.charCodeAt(i);
|
|
633
|
+
hash = ((hash << 5) - hash) + char;
|
|
634
|
+
hash = hash & hash;
|
|
635
|
+
}
|
|
636
|
+
return Math.abs(hash).toString(36);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Validate a pattern structure
|
|
640
|
+
*/
|
|
641
|
+
validatePattern(pattern) {
|
|
642
|
+
if (!pattern.id || typeof pattern.id !== 'string')
|
|
643
|
+
return false;
|
|
644
|
+
if (!pattern.category || !Object.values(types_1.PatternCategory).includes(pattern.category))
|
|
645
|
+
return false;
|
|
646
|
+
if (!pattern.type || typeof pattern.type !== 'string')
|
|
647
|
+
return false;
|
|
648
|
+
if (!pattern.domain || typeof pattern.domain !== 'string')
|
|
649
|
+
return false;
|
|
650
|
+
if (!pattern.content || typeof pattern.content.raw !== 'string')
|
|
651
|
+
return false;
|
|
652
|
+
if (!pattern.embedding || (!Array.isArray(pattern.embedding) && !(pattern.embedding instanceof Float32Array)))
|
|
653
|
+
return false;
|
|
654
|
+
if (!pattern.metadata || !Array.isArray(pattern.metadata.tags))
|
|
655
|
+
return false;
|
|
656
|
+
if (!pattern.version || typeof pattern.version.semver !== 'string')
|
|
657
|
+
return false;
|
|
658
|
+
if (!pattern.quality || typeof pattern.quality.successRate !== 'number')
|
|
659
|
+
return false;
|
|
660
|
+
if (!pattern.sharing || !Object.values(types_1.SharingPolicy).includes(pattern.sharing.policy))
|
|
661
|
+
return false;
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
exports.PatternSerializer = PatternSerializer;
|
|
666
|
+
// ============================================
|
|
667
|
+
// Factory Functions
|
|
668
|
+
// ============================================
|
|
669
|
+
/**
|
|
670
|
+
* Create a new pattern serializer
|
|
671
|
+
*/
|
|
672
|
+
function createPatternSerializer(config) {
|
|
673
|
+
return new PatternSerializer(config);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Serialize a pattern to bytes
|
|
677
|
+
*/
|
|
678
|
+
async function serializePattern(pattern) {
|
|
679
|
+
const serializer = new PatternSerializer();
|
|
680
|
+
return serializer.serialize(pattern);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Deserialize a pattern from bytes
|
|
684
|
+
*/
|
|
685
|
+
async function deserializePattern(data) {
|
|
686
|
+
const serializer = new PatternSerializer();
|
|
687
|
+
return serializer.deserialize(data);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Anonymize pattern content
|
|
691
|
+
*/
|
|
692
|
+
function anonymizePattern(pattern, config) {
|
|
693
|
+
const serializer = new PatternSerializer(config);
|
|
694
|
+
return serializer.anonymize(pattern);
|
|
695
|
+
}
|
|
696
|
+
//# sourceMappingURL=PatternSerializer.js.map
|