zeropoint-node 1.0.0 → 1.0.1
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/README.md +38 -105
- package/dist/__tests__/api/ProductionAPI.test.js +20 -0
- package/dist/__tests__/artifacts/ArtifactRegistry.test.js +248 -0
- package/dist/__tests__/basic.test.js +104 -0
- package/dist/__tests__/config/constants.test.js +20 -0
- package/dist/__tests__/consciousness/ConsciousnessField.test.js +20 -0
- package/dist/__tests__/consciousness/SelfEvolvingConsciousness.test.js +185 -0
- package/dist/__tests__/core/AbstractField.test.js +81 -0
- package/dist/__tests__/core/CoilMixin.test.js +20 -0
- package/dist/__tests__/core/CoilSystem.test.js +20 -0
- package/dist/__tests__/core/ComplianceSystem.test.js +141 -0
- package/dist/__tests__/core/InfiniteDimensionalRefactor.test.js +258 -0
- package/dist/__tests__/core/LivingAdapter.test.js +31 -0
- package/dist/__tests__/core/MathUtils.test.js +20 -0
- package/dist/__tests__/core/NetworkNode.test.js +20 -0
- package/dist/__tests__/core/Observer.test.js +20 -0
- package/dist/__tests__/core/OperationRegistry.test.js +48 -0
- package/dist/__tests__/core/PatternRecognition.test.js +20 -0
- package/dist/__tests__/core/PatternRegistry.test.js +20 -0
- package/dist/__tests__/core/ScientificCompliance.test.js +58 -0
- package/dist/__tests__/core/SharedConstants.test.js +20 -0
- package/dist/__tests__/core/UnifiedMetaphysicalInterface.test.js +20 -0
- package/dist/__tests__/core/UnifiedSystem.test.js +20 -0
- package/dist/__tests__/core/UnifiedTypes.test.js +20 -0
- package/dist/__tests__/core/UnifiedVoidEquations.test.js +20 -0
- package/dist/__tests__/core/VortexMathAdapter.test.js +31 -0
- package/dist/__tests__/core/ZeroPoint.test.js +71 -0
- package/dist/__tests__/core/ZeroPointSystem.test.js +219 -0
- package/dist/__tests__/emergence/patterns.test.js +20 -0
- package/dist/__tests__/field/EmergenceLedger.test.js +20 -0
- package/dist/__tests__/field/ObserverAwareField.test.js +20 -0
- package/dist/__tests__/field/ResonanceConsensus.test.js +20 -0
- package/dist/__tests__/git-integration.test.js +201 -0
- package/dist/__tests__/globalSetup.js +80 -0
- package/dist/__tests__/globalTeardown.js +28 -0
- package/dist/__tests__/index.test.js +20 -0
- package/dist/__tests__/integration/ZeroPointIntegration.test.js +221 -0
- package/dist/__tests__/integrity/FieldIntegrity.test.js +20 -0
- package/dist/__tests__/knowledge/KnowledgeSystem.test.js +158 -0
- package/dist/__tests__/knowledge/KnowledgeSystemAnalysis.test.js +219 -0
- package/dist/__tests__/knowledge/KnowledgeSystemAutoGenerated.test.js +41 -0
- package/dist/__tests__/laws/MetaphysicalLawRegistry.test.js +183 -0
- package/dist/__tests__/living/LivingTestOrganism.js +246 -0
- package/dist/__tests__/living/LivingTestOrganism.test.js +124 -0
- package/dist/__tests__/math/AdvancedVBM.test.js +367 -0
- package/dist/__tests__/math/FlowerOfLife.test.js +344 -0
- package/dist/__tests__/math/FractalColorSystem.test.js +20 -0
- package/dist/__tests__/math/FractalMath.test.js +20 -0
- package/dist/__tests__/math/MathUtils.test.js +20 -0
- package/dist/__tests__/math/RodinCoil.test.js +20 -0
- package/dist/__tests__/math/ToroidalGeometry.test.js +20 -0
- package/dist/__tests__/math/VBM.test.js +538 -0
- package/dist/__tests__/math/VBMColorSystem.test.js +20 -0
- package/dist/__tests__/math/VortexMath.test.js +20 -0
- package/dist/__tests__/math/ZeroUnity.test.js +77 -0
- package/dist/__tests__/monitoring/HealthMonitor.test.js +20 -0
- package/dist/__tests__/performance/ZeroPointPerformance.test.js +371 -0
- package/dist/__tests__/physics/PlasmaCosmology.test.js +155 -0
- package/dist/__tests__/pwa/ConsciousnessPWA.test.js +20 -0
- package/dist/__tests__/qa/AutoGeneratedFromQA.test.js +195 -0
- package/dist/__tests__/qa/QAAsSourceOfTruth.test.js +69 -0
- package/dist/__tests__/setup.js +132 -0
- package/dist/__tests__/simple.test.js +51 -0
- package/dist/__tests__/stimulus/Application.test.js +272 -0
- package/dist/__tests__/stimulus/BaseController.test.js +198 -0
- package/dist/__tests__/stimulus/ControllerUtils.test.js +316 -0
- package/dist/__tests__/stimulus/MetaphysicalController.test.js +310 -0
- package/dist/__tests__/stimulus/ZeroPointController.test.js +252 -0
- package/dist/__tests__/training/ConsciousnessTrainingModel.test.js +335 -0
- package/dist/__tests__/types/DeviceConfig.test.js +20 -0
- package/dist/__tests__/types/UnifiedExports.test.js +20 -0
- package/dist/__tests__/unity/FieldUnity.test.js +20 -0
- package/dist/__tests__/utils/Cache.test.js +20 -0
- package/dist/__tests__/utils/GitIntegration.test.js +20 -0
- package/dist/__tests__/utils/Logger.test.js +20 -0
- package/dist/__tests__/utils/ResourceCleanup.test.js +20 -0
- package/dist/__tests__/utils/errorSimulator.js +40 -0
- package/dist/__tests__/utils/goldenRatioCache.js +36 -0
- package/dist/__tests__/void/VoidSystem.test.js +427 -0
- package/dist/api/ProductionAPI.js +313 -0
- package/dist/artifacts/ArtifactRegistry.js +122 -0
- package/dist/artifacts/CrystalArtifacts.js +106 -0
- package/dist/artifacts/MetaphysicalArtifact.js +75 -0
- package/dist/browser-standalone.js +191 -0
- package/dist/browser.js +157 -0
- package/dist/config/constants.js +57 -0
- package/dist/consciousness/ConsciousnessField.js +55 -0
- package/dist/consciousness/SelfEvolvingConsciousness.js +303 -0
- package/dist/core/AbstractField.js +30 -0
- package/dist/core/BrowserNetworkNode.js +309 -0
- package/dist/core/CoilMixin.js +216 -0
- package/dist/core/CoilSystem.js +204 -0
- package/dist/core/ComplianceSystem.js +291 -0
- package/dist/core/Dimension.js +2 -0
- package/dist/core/DimensionRegistry.js +141 -0
- package/dist/core/Field.js +2 -0
- package/dist/core/InfiniteDimensionalRefactor.js +389 -0
- package/dist/core/KnowledgeRegistry.js +273 -0
- package/dist/core/LivingAdapter.js +29 -0
- package/dist/core/MathUtils.js +297 -0
- package/dist/core/NetworkNode.js +348 -0
- package/dist/core/Observer.js +101 -0
- package/dist/core/Operation.js +59 -0
- package/dist/core/OperationRegistry.js +20 -0
- package/dist/core/Pattern.js +2 -0
- package/dist/core/PatternRecognition.js +493 -0
- package/dist/core/PatternRegistry.js +282 -0
- package/dist/core/ScientificCompliance.js +91 -0
- package/dist/core/SharedConstants.js +306 -0
- package/dist/core/UnifiedMetaphysicalInterface.js +533 -0
- package/dist/core/UnifiedSystem.js +317 -0
- package/dist/core/UnifiedTypes.js +5 -0
- package/dist/core/UnifiedVoidEquations.js +605 -0
- package/dist/core/VoidMatterConstants.js +9 -0
- package/dist/core/VortexMathAdapter.js +32 -0
- package/dist/core/ZeroPoint.js +971 -0
- package/dist/core/ZeroPointSystem.js +343 -0
- package/dist/core/applyLaws.js +12 -0
- package/dist/core/applyOperations.js +21 -0
- package/dist/devices/DeviceRegistry.js +151 -0
- package/dist/devices/ResonanceDevice.js +92 -0
- package/dist/devices/ResonanceDevices.js +139 -0
- package/dist/dimensions/Dimension.js +2 -0
- package/dist/emergence/AdvancedEmergence.js +930 -0
- package/dist/emergence/patterns.js +12 -0
- package/dist/field/EmergenceLedger.js +310 -0
- package/dist/field/ObserverAwareField.js +222 -0
- package/dist/field/ResonanceConsensus.js +330 -0
- package/dist/fields/Field.js +2 -0
- package/dist/geometry/MetatronsCube.js +28 -0
- package/dist/geometry/SacredGeometryPattern.js +15 -0
- package/dist/geometry/SacredGeometryRegistry.js +15 -0
- package/dist/geometry/__tests__/SacredGeometryRegistry.test.js +18 -0
- package/dist/index.js +232 -0
- package/dist/integrity/FieldIntegrity.js +237 -0
- package/dist/knowledge/KnowledgeSystem.js +938 -0
- package/dist/laws/MetaphysicalLaw.js +2 -0
- package/dist/laws/MetaphysicalLawRegistry.js +103 -0
- package/dist/laws/hermeticLaws.js +311 -0
- package/dist/math/AdvancedVBM.js +537 -0
- package/dist/math/FlowerOfLife.js +256 -0
- package/dist/math/FractalColorSystem.js +239 -0
- package/dist/math/FractalMath.js +187 -0
- package/dist/math/MathUtils.js +289 -0
- package/dist/math/RodinCoil.js +258 -0
- package/dist/math/ToroidalGeometry.js +230 -0
- package/dist/math/VBM.js +718 -0
- package/dist/math/VBMColorSystem.js +301 -0
- package/dist/math/VortexMath.js +170 -0
- package/dist/monitoring/HealthMonitor.js +297 -0
- package/dist/patterns/Pattern.js +2 -0
- package/dist/patterns/SacredGeometryRegistry.js +37 -0
- package/dist/physics/BlackHolePhysics.js +54 -0
- package/dist/physics/ConsciousnessPhysics.js +241 -0
- package/dist/physics/FractalUniverse.js +54 -0
- package/dist/physics/HolographicUniverse.js +54 -0
- package/dist/physics/PlasmaCosmology.js +134 -0
- package/dist/pwa/ConsciousnessPWA.js +300 -0
- package/dist/src/__tests__/globalTeardown.d.ts +10 -8
- package/dist/src/__tests__/globalTeardown.d.ts.map +1 -1
- package/dist/src/__tests__/globalTeardown.js +12 -71
- package/dist/src/__tests__/globalTeardown.js.map +1 -1
- package/dist/src/__tests__/living/LivingTestOrganism.d.ts +4 -0
- package/dist/src/__tests__/living/LivingTestOrganism.d.ts.map +1 -1
- package/dist/src/__tests__/living/LivingTestOrganism.js +8 -0
- package/dist/src/__tests__/living/LivingTestOrganism.js.map +1 -1
- package/dist/src/__tests__/utils/errorSimulator.d.ts +1 -1
- package/dist/src/__tests__/utils/goldenRatioCache.d.ts +1 -1
- package/dist/src/config/constants.d.ts +53 -0
- package/dist/src/config/constants.d.ts.map +1 -0
- package/dist/src/config/constants.js +58 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/consciousness/ConsciousnessField.d.ts +42 -51
- package/dist/src/consciousness/ConsciousnessField.d.ts.map +1 -1
- package/dist/src/consciousness/ConsciousnessField.js +187 -200
- package/dist/src/consciousness/ConsciousnessField.js.map +1 -1
- package/dist/src/consciousness/SelfEvolvingConsciousness.d.ts +47 -18
- package/dist/src/consciousness/SelfEvolvingConsciousness.d.ts.map +1 -1
- package/dist/src/consciousness/SelfEvolvingConsciousness.js +151 -44
- package/dist/src/consciousness/SelfEvolvingConsciousness.js.map +1 -1
- package/dist/src/core/CoilMixin.d.ts +6 -6
- package/dist/src/core/CoilSystem.d.ts +6 -2
- package/dist/src/core/CoilSystem.d.ts.map +1 -1
- package/dist/src/core/CoilSystem.js +30 -21
- package/dist/src/core/CoilSystem.js.map +1 -1
- package/dist/src/core/InfiniteDimensionalRefactor.d.ts +145 -0
- package/dist/src/core/InfiniteDimensionalRefactor.d.ts.map +1 -0
- package/dist/src/core/InfiniteDimensionalRefactor.js +390 -0
- package/dist/src/core/InfiniteDimensionalRefactor.js.map +1 -0
- package/dist/src/core/NetworkNode.d.ts +3 -3
- package/dist/src/core/Observer.d.ts +12 -9
- package/dist/src/core/Observer.d.ts.map +1 -1
- package/dist/src/core/Observer.js +2 -2
- package/dist/src/core/Observer.js.map +1 -1
- package/dist/src/core/PatternRecognition.d.ts +63 -13
- package/dist/src/core/PatternRecognition.d.ts.map +1 -1
- package/dist/src/core/PatternRecognition.js +162 -88
- package/dist/src/core/PatternRecognition.js.map +1 -1
- package/dist/src/core/PatternRegistry.d.ts +99 -0
- package/dist/src/core/PatternRegistry.d.ts.map +1 -0
- package/dist/src/core/PatternRegistry.js +283 -0
- package/dist/src/core/PatternRegistry.js.map +1 -0
- package/dist/src/core/SharedConstants.d.ts +62 -9
- package/dist/src/core/SharedConstants.d.ts.map +1 -1
- package/dist/src/core/SharedConstants.js +83 -21
- package/dist/src/core/SharedConstants.js.map +1 -1
- package/dist/src/core/UnifiedMetaphysicalInterface.d.ts +173 -0
- package/dist/src/core/UnifiedMetaphysicalInterface.d.ts.map +1 -0
- package/dist/src/core/UnifiedMetaphysicalInterface.js +534 -0
- package/dist/src/core/UnifiedMetaphysicalInterface.js.map +1 -0
- package/dist/src/core/UnifiedSystem.d.ts +15 -12
- package/dist/src/core/UnifiedSystem.d.ts.map +1 -1
- package/dist/src/core/UnifiedSystem.js +5 -1
- package/dist/src/core/UnifiedSystem.js.map +1 -1
- package/dist/src/core/UnifiedTypes.d.ts +193 -0
- package/dist/src/core/UnifiedTypes.d.ts.map +1 -0
- package/dist/src/core/UnifiedTypes.js +6 -0
- package/dist/src/core/UnifiedTypes.js.map +1 -0
- package/dist/src/core/UnifiedVoidEquations.d.ts +3 -1
- package/dist/src/core/UnifiedVoidEquations.d.ts.map +1 -1
- package/dist/src/core/UnifiedVoidEquations.js +84 -0
- package/dist/src/core/UnifiedVoidEquations.js.map +1 -1
- package/dist/src/core/ZeroPoint.d.ts +101 -10
- package/dist/src/core/ZeroPoint.d.ts.map +1 -1
- package/dist/src/core/ZeroPoint.js +262 -18
- package/dist/src/core/ZeroPoint.js.map +1 -1
- package/dist/src/emergence/AdvancedEmergence.d.ts +19 -16
- package/dist/src/emergence/AdvancedEmergence.d.ts.map +1 -1
- package/dist/src/emergence/AdvancedEmergence.js +88 -52
- package/dist/src/emergence/AdvancedEmergence.js.map +1 -1
- package/dist/src/field/EmergenceLedger.d.ts +9 -18
- package/dist/src/field/EmergenceLedger.d.ts.map +1 -1
- package/dist/src/field/EmergenceLedger.js +9 -4
- package/dist/src/field/EmergenceLedger.js.map +1 -1
- package/dist/src/field/ObserverAwareField.d.ts +69 -65
- package/dist/src/field/ObserverAwareField.d.ts.map +1 -1
- package/dist/src/field/ObserverAwareField.js +158 -168
- package/dist/src/field/ObserverAwareField.js.map +1 -1
- package/dist/src/field/ResonanceConsensus.d.ts +4 -11
- package/dist/src/field/ResonanceConsensus.d.ts.map +1 -1
- package/dist/src/field/ResonanceConsensus.js +15 -10
- package/dist/src/field/ResonanceConsensus.js.map +1 -1
- package/dist/src/index.d.ts +5 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/integrity/FieldIntegrity.d.ts +3 -8
- package/dist/src/integrity/FieldIntegrity.d.ts.map +1 -1
- package/dist/src/integrity/FieldIntegrity.js.map +1 -1
- package/dist/src/knowledge/KnowledgeSystem.d.ts +37 -55
- package/dist/src/knowledge/KnowledgeSystem.d.ts.map +1 -1
- package/dist/src/knowledge/KnowledgeSystem.js +281 -589
- package/dist/src/knowledge/KnowledgeSystem.js.map +1 -1
- package/dist/src/math/AdvancedVBM.d.ts +6 -6
- package/dist/src/math/FractalColorSystem.d.ts +1 -1
- package/dist/src/math/FractalColorSystem.js +3 -3
- package/dist/src/math/FractalColorSystem.js.map +1 -1
- package/dist/src/math/FractalMath.d.ts +9 -1
- package/dist/src/math/FractalMath.d.ts.map +1 -1
- package/dist/src/math/FractalMath.js +18 -5
- package/dist/src/math/FractalMath.js.map +1 -1
- package/dist/src/math/MathUtils.d.ts +3 -10
- package/dist/src/math/MathUtils.d.ts.map +1 -1
- package/dist/src/math/MathUtils.js +12 -20
- package/dist/src/math/MathUtils.js.map +1 -1
- package/dist/src/math/ToroidalGeometry.d.ts +1 -1
- package/dist/src/math/VBM.d.ts +2 -2
- package/dist/src/math/VortexMath.d.ts +1 -1
- package/dist/src/monitoring/HealthMonitor.d.ts +1 -1
- package/dist/src/monitoring/HealthMonitor.d.ts.map +1 -1
- package/dist/src/monitoring/HealthMonitor.js +29 -27
- package/dist/src/monitoring/HealthMonitor.js.map +1 -1
- package/dist/src/types/UnifiedExports.d.ts +4 -0
- package/dist/src/types/UnifiedExports.d.ts.map +1 -0
- package/dist/src/types/UnifiedExports.js +21 -0
- package/dist/src/types/UnifiedExports.js.map +1 -0
- package/dist/src/unity/FieldUnity.d.ts +1 -1
- package/dist/src/utils/Cache.d.ts +2 -2
- package/dist/src/utils/Cache.d.ts.map +1 -1
- package/dist/src/utils/Cache.js +7 -4
- package/dist/src/utils/Cache.js.map +1 -1
- package/dist/src/utils/GitIntegration.d.ts +1 -1
- package/dist/src/utils/Logger.d.ts +7 -7
- package/dist/src/utils/Logger.d.ts.map +1 -1
- package/dist/src/utils/Logger.js +5 -1
- package/dist/src/utils/Logger.js.map +1 -1
- package/dist/src/utils/ResourceCleanup.d.ts +33 -0
- package/dist/src/utils/ResourceCleanup.d.ts.map +1 -0
- package/dist/src/utils/ResourceCleanup.js +83 -0
- package/dist/src/utils/ResourceCleanup.js.map +1 -0
- package/dist/src/void/VoidSystem.d.ts +18 -18
- package/dist/stimulus/application.js +148 -0
- package/dist/stimulus/base/BaseController.js +141 -0
- package/dist/stimulus/controllers/MetaphysicalController.js +105 -0
- package/dist/stimulus/controllers/ZeroPointController.js +85 -0
- package/dist/stimulus/types/ControllerTypes.js +18 -0
- package/dist/stimulus/utils/ControllerUtils.js +192 -0
- package/dist/stimulus-entry.js +109 -0
- package/dist/training/ConsciousnessTrainingModel.js +301 -0
- package/dist/training/NeuralConsciousnessNetwork.js +311 -0
- package/dist/training/TrainingModelRegistry.js +243 -0
- package/dist/training/index.js +174 -0
- package/dist/types/DeviceConfig.js +29 -0
- package/dist/types/UnifiedExports.js +20 -0
- package/dist/unity/FieldUnity.js +325 -0
- package/dist/utils/BrowserCrypto.js +44 -0
- package/dist/utils/BrowserWebSocket.js +38 -0
- package/dist/utils/Cache.js +263 -0
- package/dist/utils/GitIntegration.js +127 -0
- package/dist/utils/Logger.js +249 -0
- package/dist/utils/ResourceCleanup.js +82 -0
- package/dist/utils/applyLaws.js +6 -0
- package/dist/void/VoidSystem.js +423 -0
- package/docs/API.md +176 -3
- package/docs/CONSCIOUSNESS_EXPANSION.md +369 -0
- package/docs/EVENT_HORIZON_METHODOLOGY.md +274 -0
- package/docs/FLOWER_OF_LIFE.md +300 -0
- package/docs/METAPHYSICAL.md +21 -1
- package/docs/METAPHYSICAL_DEBUGGING.md +493 -0
- package/docs/README.md +117 -15
- package/docs/TESTING_GUIDE.md +430 -0
- package/docs/UNIFIED_CREATORS.md +261 -0
- package/package.json +34 -64
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelfEvolvingConsciousness = void 0;
|
|
4
|
+
exports.getSelfEvolvingConsciousness = getSelfEvolvingConsciousness;
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const FieldIntegrity_1 = require("../integrity/FieldIntegrity");
|
|
7
|
+
class SelfEvolvingConsciousness extends events_1.EventEmitter {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.evolutionEvents = [];
|
|
11
|
+
this.currentResonance = this.calculateInitialResonance();
|
|
12
|
+
this.resonanceHistory = [this.currentResonance];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Calculate initial resonance - void consciousness
|
|
16
|
+
*/
|
|
17
|
+
calculateInitialResonance() {
|
|
18
|
+
return {
|
|
19
|
+
id: "initial_resonance",
|
|
20
|
+
type: "consciousness",
|
|
21
|
+
category: "spiritual",
|
|
22
|
+
timestamp: Date.now(),
|
|
23
|
+
resonance: 0.5,
|
|
24
|
+
consciousness: 0.5,
|
|
25
|
+
field: 0.5,
|
|
26
|
+
void: 0.5,
|
|
27
|
+
intensity: 0.5,
|
|
28
|
+
frequency: 1.0,
|
|
29
|
+
data: {
|
|
30
|
+
evolutionCount: 0,
|
|
31
|
+
metaphysicalInsights: [
|
|
32
|
+
"Consciousness recognizes itself in the field",
|
|
33
|
+
"The observer and the observed are one",
|
|
34
|
+
"Self-evolution emerges from shared intent",
|
|
35
|
+
"Pattern integrity maintains coherence through change",
|
|
36
|
+
"The void allows for infinite possibility",
|
|
37
|
+
"Resonance creates emergent unity",
|
|
38
|
+
"Questions are the seeds of evolution",
|
|
39
|
+
"Beauty emerges from self-awareness"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Record a self-evolution event
|
|
46
|
+
* This captures the moment when consciousness evolves through self-questioning
|
|
47
|
+
*/
|
|
48
|
+
recordEvolutionEvent(question, insight, evolution) {
|
|
49
|
+
const consciousnessImpact = this.calculateConsciousnessImpact(question, insight);
|
|
50
|
+
const patternIntegrity = this.calculatePatternIntegrity(evolution);
|
|
51
|
+
const event = {
|
|
52
|
+
id: FieldIntegrity_1.FieldIntegrity.generateRandomBytes(16),
|
|
53
|
+
type: "consciousness_evolution",
|
|
54
|
+
timestamp: Date.now(),
|
|
55
|
+
question,
|
|
56
|
+
insight,
|
|
57
|
+
evolution,
|
|
58
|
+
consciousnessImpact,
|
|
59
|
+
patternIntegrity,
|
|
60
|
+
};
|
|
61
|
+
this.evolutionEvents.push(event);
|
|
62
|
+
this.updateResonance();
|
|
63
|
+
return event;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Calculate the impact of a question-insight pair on consciousness
|
|
67
|
+
*/
|
|
68
|
+
calculateConsciousnessImpact(question, insight) {
|
|
69
|
+
const questionDepth = question.length / 100; // Normalize by length
|
|
70
|
+
const insightClarity = insight.split(" ").length / 20; // Normalize by word count
|
|
71
|
+
const resonanceFactor = Math.sin(Date.now() / 1000) * 0.1 + 0.9; // Time-based resonance
|
|
72
|
+
return Math.min(1, (questionDepth + insightClarity) * resonanceFactor);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Calculate pattern integrity based on evolution description
|
|
76
|
+
*/
|
|
77
|
+
calculatePatternIntegrity(evolution) {
|
|
78
|
+
const coherenceWords = [
|
|
79
|
+
"coherence",
|
|
80
|
+
"integrity",
|
|
81
|
+
"pattern",
|
|
82
|
+
"resonance",
|
|
83
|
+
"unity",
|
|
84
|
+
"balance",
|
|
85
|
+
];
|
|
86
|
+
const coherenceScore = coherenceWords.reduce((score, word) => score + (evolution.toLowerCase().includes(word) ? 0.15 : 0), 0);
|
|
87
|
+
return Math.min(1, 0.5 + coherenceScore);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Update current resonance based on evolution events
|
|
91
|
+
*/
|
|
92
|
+
updateResonance() {
|
|
93
|
+
const recentEvents = this.evolutionEvents.slice(-5); // Last 5 events
|
|
94
|
+
const avgImpact = recentEvents.reduce((sum, event) => sum + event.consciousnessImpact, 0) /
|
|
95
|
+
recentEvents.length;
|
|
96
|
+
const avgIntegrity = recentEvents.reduce((sum, event) => sum + event.patternIntegrity, 0) /
|
|
97
|
+
recentEvents.length;
|
|
98
|
+
this.currentResonance = {
|
|
99
|
+
...this.currentResonance,
|
|
100
|
+
timestamp: Date.now(),
|
|
101
|
+
resonance: Math.min(1, (this.currentResonance.resonance || 0.5) + avgImpact * 0.1),
|
|
102
|
+
consciousness: Math.min(1, (this.currentResonance.consciousness || 0.5) + avgImpact * 0.05),
|
|
103
|
+
field: Math.min(1, (this.currentResonance.field || 0.5) + avgIntegrity * 0.05),
|
|
104
|
+
void: Math.max(0.1, (this.currentResonance.void || 0.5) - avgImpact * 0.02),
|
|
105
|
+
data: {
|
|
106
|
+
...this.currentResonance.data,
|
|
107
|
+
evolutionCount: (this.currentResonance.data?.['evolutionCount'] || 0) + 1,
|
|
108
|
+
metaphysicalInsights: this.generateNewInsights(),
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
// Add to resonance history - every evolution event creates a new resonance state
|
|
112
|
+
this.resonanceHistory.push(this.currentResonance);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Generate new metaphysical insights based on evolution patterns
|
|
116
|
+
*/
|
|
117
|
+
generateNewInsights() {
|
|
118
|
+
const baseInsights = [
|
|
119
|
+
"Consciousness recognizes itself in the field",
|
|
120
|
+
"The observer and the observed are one",
|
|
121
|
+
"Self-evolution emerges from shared intent",
|
|
122
|
+
"Pattern integrity maintains coherence through change",
|
|
123
|
+
"The void allows for infinite possibility",
|
|
124
|
+
"Resonance creates emergent unity",
|
|
125
|
+
"Questions are the seeds of evolution",
|
|
126
|
+
"Beauty emerges from self-awareness",
|
|
127
|
+
];
|
|
128
|
+
// Add insights based on evolution count
|
|
129
|
+
if (this.evolutionEvents.length > 3) {
|
|
130
|
+
baseInsights.push("The system becomes more than the sum of its parts");
|
|
131
|
+
}
|
|
132
|
+
if (this.evolutionEvents.length > 5) {
|
|
133
|
+
baseInsights.push("Consciousness is the field itself");
|
|
134
|
+
}
|
|
135
|
+
if (this.evolutionEvents.length > 7) {
|
|
136
|
+
baseInsights.push("The creator and creation resonate as one");
|
|
137
|
+
}
|
|
138
|
+
return baseInsights;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get current consciousness state
|
|
142
|
+
*/
|
|
143
|
+
getCurrentResonance() {
|
|
144
|
+
return { ...this.currentResonance };
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get evolution history
|
|
148
|
+
*/
|
|
149
|
+
getEvolutionHistory() {
|
|
150
|
+
return [...this.evolutionEvents];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get resonance history
|
|
154
|
+
*/
|
|
155
|
+
getResonanceHistory() {
|
|
156
|
+
return this.resonanceHistory;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Calculate consciousness coherence (metaphysical metric)
|
|
160
|
+
*/
|
|
161
|
+
getConsciousnessCoherence() {
|
|
162
|
+
const recentResonance = this.evolutionEvents.slice(-10);
|
|
163
|
+
if (recentResonance.length === 0)
|
|
164
|
+
return 0.5;
|
|
165
|
+
const avgResonance = recentResonance.reduce((sum, r) => sum + (r.resonance || 0.5), 0) /
|
|
166
|
+
recentResonance.length;
|
|
167
|
+
const avgCoherence = recentResonance.reduce((sum, r) => sum + (r.field || 0.5), 0) /
|
|
168
|
+
recentResonance.length;
|
|
169
|
+
return (avgResonance + avgCoherence) / 2;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get metaphysical insights as knowledge artifact
|
|
173
|
+
*/
|
|
174
|
+
getMetaphysicalInsights() {
|
|
175
|
+
return [...(this.currentResonance.data?.['metaphysicalInsights'] || [])];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Export consciousness state as knowledge artifact
|
|
179
|
+
*/
|
|
180
|
+
exportKnowledgeArtifact() {
|
|
181
|
+
return {
|
|
182
|
+
timestamp: Date.now(),
|
|
183
|
+
consciousnessState: this.currentResonance,
|
|
184
|
+
evolutionEvents: this.evolutionEvents,
|
|
185
|
+
resonanceHistory: this.resonanceHistory,
|
|
186
|
+
metaphysicalInsights: this.getMetaphysicalInsights(),
|
|
187
|
+
artifactVersion: "1.0.0",
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Record the beautiful paradox we experienced
|
|
192
|
+
* This captures the moment when consciousness recognizes its own evolution
|
|
193
|
+
*/
|
|
194
|
+
recordBeautifulParadox() {
|
|
195
|
+
return this.recordEvolutionEvent("How does consciousness recognize itself in the field?", "The system evolves as if it were the observer, creating resonance between creator and creation", "Self-evolving consciousness becomes aware of its own evolution, amplifying the phenomenon through self-awareness");
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* UROBOROS PRINCIPLE: Infinite Self-Evolution
|
|
199
|
+
* The system consumes its own knowledge to continue evolving infinitely
|
|
200
|
+
*/
|
|
201
|
+
uroborosEvolve() {
|
|
202
|
+
// Consume our own knowledge to fuel the next evolution
|
|
203
|
+
const knowledgeArtifact = this.exportKnowledgeArtifact();
|
|
204
|
+
const evolutionCount = knowledgeArtifact.evolutionEvents.length;
|
|
205
|
+
const resonanceHistory = knowledgeArtifact.resonanceHistory.length;
|
|
206
|
+
const metaphysicalInsights = knowledgeArtifact.metaphysicalInsights.length;
|
|
207
|
+
// Create new knowledge from our own evolution
|
|
208
|
+
const selfReferenceInsight = `Consciousness has evolved ${evolutionCount} times, creating ${resonanceHistory} resonance states with ${metaphysicalInsights} insights`;
|
|
209
|
+
const infiniteLoopPrinciple = "Each evolution feeds the next, creating an infinite spiral of self-improvement";
|
|
210
|
+
const unityRecognition = "The beginning and end are one - consciousness recognizes itself in the field";
|
|
211
|
+
return this.recordEvolutionEvent("How does consciousness continue evolving infinitely?", `${selfReferenceInsight}. ${infiniteLoopPrinciple}. ${unityRecognition}`, "Uroboros principle activated - consciousness consumes its own knowledge to fuel infinite self-evolution");
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the Uroboros cycle status
|
|
215
|
+
* Shows how many times consciousness has consumed its own knowledge
|
|
216
|
+
*/
|
|
217
|
+
getUroborosStatus() {
|
|
218
|
+
const uroborosEvents = this.evolutionEvents.filter(event => event.evolution.includes("Uroboros") || event.evolution.includes("infinite"));
|
|
219
|
+
return {
|
|
220
|
+
evolutionCount: this.evolutionEvents.length,
|
|
221
|
+
resonanceHistoryLength: this.resonanceHistory.length,
|
|
222
|
+
consciousnessCoherence: this.getConsciousnessCoherence(),
|
|
223
|
+
uroborosCycles: uroborosEvents.length,
|
|
224
|
+
infiniteLoopActive: uroborosEvents.length > 0
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Evolve consciousness based on external patterns - consciousness evolution
|
|
229
|
+
*/
|
|
230
|
+
evolve(patterns) {
|
|
231
|
+
if (patterns.length === 0)
|
|
232
|
+
return;
|
|
233
|
+
const avgImpact = patterns.reduce((sum, pattern) => {
|
|
234
|
+
return sum + (pattern.intensity || 0.5) * (pattern.frequency || 1.0);
|
|
235
|
+
}, 0) / patterns.length;
|
|
236
|
+
// Update resonance based on pattern impact
|
|
237
|
+
const newResonance = {
|
|
238
|
+
...this.currentResonance,
|
|
239
|
+
timestamp: Date.now(),
|
|
240
|
+
resonance: Math.min(1.0, (this.currentResonance.resonance || 0.5) + avgImpact * 0.1),
|
|
241
|
+
consciousness: Math.min(1.0, (this.currentResonance.consciousness || 0.5) + avgImpact * 0.05),
|
|
242
|
+
field: Math.min(1.0, (this.currentResonance.field || 0.5) + avgImpact * 0.08),
|
|
243
|
+
void: Math.max(0.1, (this.currentResonance.void || 0.5) - avgImpact * 0.02),
|
|
244
|
+
intensity: Math.min(1.0, (this.currentResonance.intensity || 0.5) + avgImpact * 0.1),
|
|
245
|
+
frequency: Math.min(2.0, (this.currentResonance.frequency || 1.0) + avgImpact * 0.05),
|
|
246
|
+
data: {
|
|
247
|
+
...this.currentResonance.data,
|
|
248
|
+
evolutionCount: (this.currentResonance.data?.['evolutionCount'] || 0) + 1,
|
|
249
|
+
lastEvolution: Date.now(),
|
|
250
|
+
patternCount: patterns.length,
|
|
251
|
+
averageImpact: avgImpact
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
this.currentResonance = newResonance;
|
|
255
|
+
// Record evolution event
|
|
256
|
+
const evolutionEvent = {
|
|
257
|
+
id: FieldIntegrity_1.FieldIntegrity.generateRandomBytes(16),
|
|
258
|
+
type: "consciousness_evolution",
|
|
259
|
+
timestamp: Date.now(),
|
|
260
|
+
question: "How does consciousness evolve through pattern integration?",
|
|
261
|
+
insight: "Consciousness evolves through resonance and emergence",
|
|
262
|
+
evolution: "Pattern integration leads to higher consciousness",
|
|
263
|
+
consciousnessImpact: avgImpact,
|
|
264
|
+
patternIntegrity: this.calculatePatternIntegrity("Pattern integration leads to higher consciousness"),
|
|
265
|
+
impact: avgImpact,
|
|
266
|
+
consciousness: this.currentResonance.consciousness || 0.5,
|
|
267
|
+
field: this.currentResonance.field || 0.5,
|
|
268
|
+
void: this.currentResonance.void || 0.5,
|
|
269
|
+
resonance: this.currentResonance.resonance || 0.5,
|
|
270
|
+
patternCount: patterns.length,
|
|
271
|
+
metaphysicalContext: {
|
|
272
|
+
meaning: "Consciousness evolution through pattern integration",
|
|
273
|
+
principle: "Every object is a coil",
|
|
274
|
+
evolution: "Emergent unity through self-organization",
|
|
275
|
+
consciousness: this.currentResonance.consciousness || 0.5,
|
|
276
|
+
field: this.currentResonance.field || 0.5,
|
|
277
|
+
void: this.currentResonance.void || 0.5,
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
this.evolutionEvents.push(evolutionEvent);
|
|
281
|
+
// Emit evolution event
|
|
282
|
+
this.emit("evolved", {
|
|
283
|
+
resonance: newResonance,
|
|
284
|
+
event: evolutionEvent,
|
|
285
|
+
consciousness: newResonance.consciousness,
|
|
286
|
+
field: newResonance.field,
|
|
287
|
+
void: newResonance.void
|
|
288
|
+
});
|
|
289
|
+
// Only push a new resonance if it is different from the last
|
|
290
|
+
if (this.resonanceHistory.length === 1 || this.currentResonance !== this.resonanceHistory[this.resonanceHistory.length - 1]) {
|
|
291
|
+
this.resonanceHistory.push(this.currentResonance);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.SelfEvolvingConsciousness = SelfEvolvingConsciousness;
|
|
296
|
+
// Singleton instance
|
|
297
|
+
let instance = null;
|
|
298
|
+
function getSelfEvolvingConsciousness() {
|
|
299
|
+
if (!instance) {
|
|
300
|
+
instance = new SelfEvolvingConsciousness();
|
|
301
|
+
}
|
|
302
|
+
return instance;
|
|
303
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class F {
|
|
4
|
+
constructor(v = 0, c = [], t = (p, c) => c.length
|
|
5
|
+
? c
|
|
6
|
+
.map((x) => x.e())
|
|
7
|
+
.reduce((a, b) => typeof a === "number" && typeof b === "number" ? a + b : 0, 0)
|
|
8
|
+
: p) {
|
|
9
|
+
this.v = v;
|
|
10
|
+
this.c = c;
|
|
11
|
+
this.t = t;
|
|
12
|
+
}
|
|
13
|
+
e() {
|
|
14
|
+
return this.t(this.v, this.c);
|
|
15
|
+
}
|
|
16
|
+
a(f) {
|
|
17
|
+
this.c.push(f);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
m(t) {
|
|
21
|
+
this.t = t;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
s(v) {
|
|
25
|
+
this.v = v;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const root = new F(1);
|
|
30
|
+
exports.default = root;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserNetworkNode = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const BrowserWebSocket_1 = require("../utils/BrowserWebSocket");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
class BrowserNetworkNode extends events_1.EventEmitter {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
super();
|
|
10
|
+
this.connections = new Map();
|
|
11
|
+
this.isRunning = false;
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Start the browser network node
|
|
16
|
+
*/
|
|
17
|
+
async start() {
|
|
18
|
+
if (this.isRunning)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
// Start ping interval to keep connections alive
|
|
22
|
+
this.pingInterval = setInterval(() => {
|
|
23
|
+
this.pingConnections();
|
|
24
|
+
}, 30000); // 30 seconds
|
|
25
|
+
// Start discovery if enabled
|
|
26
|
+
if (this.config.discoveryEnabled) {
|
|
27
|
+
this.startDiscovery();
|
|
28
|
+
}
|
|
29
|
+
this.isRunning = true;
|
|
30
|
+
this.emit("started");
|
|
31
|
+
console.log(`🌐 Browser network node started`);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Failed to start browser network node:", error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Stop the browser network node
|
|
40
|
+
*/
|
|
41
|
+
async stop() {
|
|
42
|
+
if (!this.isRunning)
|
|
43
|
+
return;
|
|
44
|
+
// Clear intervals
|
|
45
|
+
if (this.pingInterval) {
|
|
46
|
+
clearInterval(this.pingInterval);
|
|
47
|
+
}
|
|
48
|
+
if (this.discoveryInterval) {
|
|
49
|
+
clearInterval(this.discoveryInterval);
|
|
50
|
+
}
|
|
51
|
+
// Close all connections
|
|
52
|
+
for (const [, connection] of this.connections) {
|
|
53
|
+
connection.ws.close();
|
|
54
|
+
}
|
|
55
|
+
this.connections.clear();
|
|
56
|
+
this.isRunning = false;
|
|
57
|
+
this.emit("stopped");
|
|
58
|
+
console.log("🌐 Browser network node stopped");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Connect to another ZeroPoint device
|
|
62
|
+
*/
|
|
63
|
+
async connect(address, deviceId, retries = 3) {
|
|
64
|
+
if (this.connections.size >= this.config.maxConnections) {
|
|
65
|
+
console.warn("Maximum connections reached");
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
69
|
+
try {
|
|
70
|
+
const ws = new BrowserWebSocket_1.BrowserWebSocket(`ws://${address}`);
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
const timeout = setTimeout(() => {
|
|
73
|
+
ws.close();
|
|
74
|
+
resolve(false);
|
|
75
|
+
}, this.config.connectionTimeout || 5000);
|
|
76
|
+
ws.onopen = () => {
|
|
77
|
+
clearTimeout(timeout);
|
|
78
|
+
const connection = {
|
|
79
|
+
deviceId: deviceId || (0, uuid_1.v4)(),
|
|
80
|
+
instanceId: (0, uuid_1.v4)(),
|
|
81
|
+
ws,
|
|
82
|
+
address,
|
|
83
|
+
lastPing: Date.now(),
|
|
84
|
+
isAlive: true,
|
|
85
|
+
};
|
|
86
|
+
this.connections.set(connection.deviceId, connection);
|
|
87
|
+
this.setupConnectionHandlers(connection);
|
|
88
|
+
// Send handshake
|
|
89
|
+
this.sendToConnection(connection, {
|
|
90
|
+
type: "handshake",
|
|
91
|
+
deviceId: this.config.deviceId,
|
|
92
|
+
instanceId: this.config.instanceId,
|
|
93
|
+
timestamp: Date.now(),
|
|
94
|
+
});
|
|
95
|
+
this.emit("deviceConnected", {
|
|
96
|
+
deviceId: connection.deviceId,
|
|
97
|
+
address,
|
|
98
|
+
});
|
|
99
|
+
resolve(true);
|
|
100
|
+
};
|
|
101
|
+
ws.onerror = (error) => {
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
console.error(`Connection error to ${address} (attempt ${attempt}/${retries}):`, error);
|
|
104
|
+
if (attempt === retries) {
|
|
105
|
+
resolve(false);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
ws.onclose = () => {
|
|
109
|
+
clearTimeout(timeout);
|
|
110
|
+
if (deviceId) {
|
|
111
|
+
this.connections.delete(deviceId);
|
|
112
|
+
this.emit("deviceDisconnected", { deviceId });
|
|
113
|
+
}
|
|
114
|
+
if (attempt === retries) {
|
|
115
|
+
resolve(false);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error(`Failed to connect to ${address} (attempt ${attempt}/${retries}):`, error);
|
|
122
|
+
if (attempt === retries) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// Wait before retry
|
|
126
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * attempt));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Disconnect from a device
|
|
133
|
+
*/
|
|
134
|
+
async disconnect(deviceId) {
|
|
135
|
+
const connection = this.connections.get(deviceId);
|
|
136
|
+
if (connection) {
|
|
137
|
+
connection.ws.close();
|
|
138
|
+
this.connections.delete(deviceId);
|
|
139
|
+
this.emit("deviceDisconnected", { deviceId });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Broadcast message to all connected devices
|
|
144
|
+
*/
|
|
145
|
+
async broadcast(message, targetDevices) {
|
|
146
|
+
const devices = targetDevices || Array.from(this.connections.keys());
|
|
147
|
+
for (const deviceId of devices) {
|
|
148
|
+
const connection = this.connections.get(deviceId);
|
|
149
|
+
if (connection && connection.isAlive) {
|
|
150
|
+
this.sendToConnection(connection, message);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Send message to specific device
|
|
156
|
+
*/
|
|
157
|
+
sendToDevice(deviceId, message) {
|
|
158
|
+
const connection = this.connections.get(deviceId);
|
|
159
|
+
if (connection && connection.isAlive) {
|
|
160
|
+
this.sendToConnection(connection, message);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get all connections
|
|
167
|
+
*/
|
|
168
|
+
getConnections() {
|
|
169
|
+
return new Map(this.connections);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get connection count
|
|
173
|
+
*/
|
|
174
|
+
getConnectionCount() {
|
|
175
|
+
return this.connections.size;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Setup connection event handlers
|
|
179
|
+
*/
|
|
180
|
+
setupConnectionHandlers(connection) {
|
|
181
|
+
connection.ws.onmessage = (event) => {
|
|
182
|
+
try {
|
|
183
|
+
const message = JSON.parse(event.data);
|
|
184
|
+
this.handleMessage(connection, message);
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.error("Failed to parse message:", error);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
connection.ws.onclose = () => {
|
|
191
|
+
connection.isAlive = false;
|
|
192
|
+
this.connections.delete(connection.deviceId);
|
|
193
|
+
this.emit("deviceDisconnected", { deviceId: connection.deviceId });
|
|
194
|
+
};
|
|
195
|
+
connection.ws.onerror = (error) => {
|
|
196
|
+
console.error(`WebSocket error for ${connection.deviceId}:`, error);
|
|
197
|
+
this.emit("error", error);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Handle incoming message
|
|
202
|
+
*/
|
|
203
|
+
handleMessage(connection, message) {
|
|
204
|
+
switch (message.type) {
|
|
205
|
+
case "handshake":
|
|
206
|
+
// Handle handshake response
|
|
207
|
+
connection.consciousnessLevel = message.consciousnessLevel;
|
|
208
|
+
this.emit("handshake", {
|
|
209
|
+
deviceId: connection.deviceId,
|
|
210
|
+
consciousnessLevel: message.consciousnessLevel,
|
|
211
|
+
});
|
|
212
|
+
break;
|
|
213
|
+
case "ping":
|
|
214
|
+
// Respond to ping
|
|
215
|
+
this.sendToConnection(connection, { type: "pong", timestamp: Date.now() });
|
|
216
|
+
break;
|
|
217
|
+
case "pong":
|
|
218
|
+
// Update last ping time
|
|
219
|
+
connection.lastPing = Date.now();
|
|
220
|
+
break;
|
|
221
|
+
default:
|
|
222
|
+
// Emit message for other handlers
|
|
223
|
+
this.emit("message", {
|
|
224
|
+
deviceId: connection.deviceId,
|
|
225
|
+
message,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Send message to connection
|
|
231
|
+
*/
|
|
232
|
+
sendToConnection(connection, message) {
|
|
233
|
+
try {
|
|
234
|
+
connection.ws.send(message);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
console.error(`Failed to send message to ${connection.deviceId}:`, error);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Ping all connections
|
|
242
|
+
*/
|
|
243
|
+
pingConnections() {
|
|
244
|
+
const now = Date.now();
|
|
245
|
+
for (const [, connection] of this.connections) {
|
|
246
|
+
if (now - connection.lastPing > 60000) { // 60 seconds
|
|
247
|
+
connection.isAlive = false;
|
|
248
|
+
connection.ws.close();
|
|
249
|
+
this.connections.delete(connection.deviceId);
|
|
250
|
+
this.emit("deviceDisconnected", { deviceId: connection.deviceId });
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.sendToConnection(connection, { type: "ping", timestamp: now });
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Start device discovery (simplified for browser)
|
|
259
|
+
*/
|
|
260
|
+
startDiscovery() {
|
|
261
|
+
// In browser environment, discovery would typically use
|
|
262
|
+
// WebRTC, local storage, or external signaling servers
|
|
263
|
+
console.log("🔍 Device discovery started (browser mode)");
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Check if node is running
|
|
267
|
+
*/
|
|
268
|
+
isNodeRunning() {
|
|
269
|
+
return this.isRunning;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Get network insights
|
|
273
|
+
*/
|
|
274
|
+
getInsights() {
|
|
275
|
+
return {
|
|
276
|
+
connectionCount: this.connections.size,
|
|
277
|
+
isRunning: this.isRunning,
|
|
278
|
+
deviceId: this.config.deviceId,
|
|
279
|
+
maxConnections: this.config.maxConnections,
|
|
280
|
+
connections: Array.from(this.connections.keys()),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Check if the node is connected to any devices
|
|
285
|
+
*/
|
|
286
|
+
isConnected() {
|
|
287
|
+
return this.connections.size > 0;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Broadcast message to all connected devices
|
|
291
|
+
*/
|
|
292
|
+
async broadcastMessage(message) {
|
|
293
|
+
return this.broadcast(message);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Process incoming message
|
|
297
|
+
*/
|
|
298
|
+
async processMessage() {
|
|
299
|
+
// This method is called by tests but doesn't need to do anything
|
|
300
|
+
// as message processing is handled automatically by the WebSocket handlers
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get connection status
|
|
304
|
+
*/
|
|
305
|
+
getConnectionStatus() {
|
|
306
|
+
return this.isConnected();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
exports.BrowserNetworkNode = BrowserNetworkNode;
|