@ruvector/edge-net 0.1.0 → 0.1.2

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.
@@ -0,0 +1,2289 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class AdaptiveSecurity {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ /**
8
+ * Choose action using epsilon-greedy policy
9
+ */
10
+ chooseAction(state: string, available_actions: string): string;
11
+ /**
12
+ * Detect if request matches known attack pattern
13
+ */
14
+ detectAttack(features: Float32Array): number;
15
+ /**
16
+ * Export learned patterns for persistence
17
+ */
18
+ exportPatterns(): Uint8Array;
19
+ /**
20
+ * Import learned patterns
21
+ */
22
+ importPatterns(data: Uint8Array): void;
23
+ getMinReputation(): number;
24
+ getRateLimitMax(): number;
25
+ getSecurityLevel(): number;
26
+ /**
27
+ * Get current adaptive thresholds
28
+ */
29
+ getRateLimitWindow(): bigint;
30
+ /**
31
+ * Record attack pattern for learning
32
+ */
33
+ recordAttackPattern(pattern_type: string, features: Float32Array, severity: number): void;
34
+ /**
35
+ * Update network health metrics
36
+ */
37
+ updateNetworkHealth(active_nodes: number, suspicious_nodes: number, attacks_hour: number, false_positives: number, avg_response_ms: number): void;
38
+ getSpotCheckProbability(): number;
39
+ constructor();
40
+ /**
41
+ * Learn from security event outcome (batched for better performance)
42
+ */
43
+ learn(state: string, action: string, reward: number, next_state: string): void;
44
+ /**
45
+ * Get learning statistics
46
+ */
47
+ getStats(): string;
48
+ }
49
+
50
+ export class AdversarialSimulator {
51
+ free(): void;
52
+ [Symbol.dispose](): void;
53
+ /**
54
+ * Simulate DDoS attack
55
+ */
56
+ simulateDDoS(requests_per_second: number, duration_ms: bigint): string;
57
+ /**
58
+ * Simulate Sybil attack
59
+ */
60
+ simulateSybil(fake_nodes: number, same_fingerprint: boolean): string;
61
+ /**
62
+ * Enable chaos mode for continuous testing
63
+ */
64
+ enableChaosMode(enabled: boolean): void;
65
+ /**
66
+ * Run comprehensive security audit
67
+ */
68
+ runSecurityAudit(): string;
69
+ /**
70
+ * Simulate Byzantine node behavior
71
+ */
72
+ simulateByzantine(byzantine_nodes: number, total_nodes: number): string;
73
+ /**
74
+ * Get defence metrics
75
+ */
76
+ getDefenceMetrics(): string;
77
+ /**
78
+ * Get recommendations based on testing
79
+ */
80
+ getRecommendations(): string;
81
+ /**
82
+ * Generate chaos event
83
+ */
84
+ generateChaosEvent(): string | undefined;
85
+ /**
86
+ * Simulate free-riding attack
87
+ */
88
+ simulateFreeRiding(consumption_rate: number, contribution_rate: number): string;
89
+ /**
90
+ * Simulate double-spend attempt
91
+ */
92
+ simulateDoubleSpend(amount: bigint, concurrent_targets: number): string;
93
+ /**
94
+ * Simulate result tampering
95
+ */
96
+ simulateResultTampering(tamper_percentage: number): string;
97
+ constructor();
98
+ }
99
+
100
+ export class AuditLog {
101
+ free(): void;
102
+ [Symbol.dispose](): void;
103
+ /**
104
+ * Export events as JSON
105
+ */
106
+ exportEvents(): string;
107
+ /**
108
+ * Get events for a node
109
+ */
110
+ getEventsForNode(node_id: string): number;
111
+ /**
112
+ * Get events by severity
113
+ */
114
+ getEventsBySeverity(min_severity: number): number;
115
+ /**
116
+ * Log an event
117
+ */
118
+ log(event_type: string, node_id: string, details: string, severity: number): void;
119
+ constructor();
120
+ }
121
+
122
+ export class BrowserFingerprint {
123
+ private constructor();
124
+ free(): void;
125
+ [Symbol.dispose](): void;
126
+ /**
127
+ * Generate anonymous uniqueness score
128
+ * This doesn't track users, just ensures one node per browser
129
+ */
130
+ static generate(): Promise<string>;
131
+ }
132
+
133
+ export class ByzantineDetector {
134
+ free(): void;
135
+ [Symbol.dispose](): void;
136
+ /**
137
+ * Get maximum allowed magnitude
138
+ */
139
+ getMaxMagnitude(): number;
140
+ /**
141
+ * Create a new Byzantine detector
142
+ */
143
+ constructor(max_magnitude: number, zscore_threshold: number);
144
+ }
145
+
146
+ export class CoherenceEngine {
147
+ free(): void;
148
+ [Symbol.dispose](): void;
149
+ /**
150
+ * Get event log length
151
+ */
152
+ eventCount(): number;
153
+ /**
154
+ * Check if context has drifted
155
+ */
156
+ hasDrifted(context_hex: string): boolean;
157
+ /**
158
+ * Check if a claim can be used in decisions
159
+ */
160
+ canUseClaim(claim_id: string): boolean;
161
+ /**
162
+ * Get witness count for a claim
163
+ */
164
+ witnessCount(claim_id: string): number;
165
+ /**
166
+ * Get conflict count
167
+ */
168
+ conflictCount(): number;
169
+ /**
170
+ * Get current Merkle root
171
+ */
172
+ getMerkleRoot(): string;
173
+ /**
174
+ * Get quarantined claim count
175
+ */
176
+ quarantinedCount(): number;
177
+ /**
178
+ * Check quarantine level for a claim
179
+ */
180
+ getQuarantineLevel(claim_id: string): number;
181
+ /**
182
+ * Check if claim has sufficient witnesses
183
+ */
184
+ hasSufficientWitnesses(claim_id: string): boolean;
185
+ /**
186
+ * Create a new coherence engine
187
+ */
188
+ constructor();
189
+ /**
190
+ * Get drift for a context
191
+ */
192
+ getDrift(context_hex: string): number;
193
+ /**
194
+ * Get statistics as JSON
195
+ */
196
+ getStats(): string;
197
+ }
198
+
199
+ export class CollectiveMemory {
200
+ free(): void;
201
+ [Symbol.dispose](): void;
202
+ /**
203
+ * Get queue size
204
+ */
205
+ queueSize(): number;
206
+ /**
207
+ * Run consolidation (call during idle periods)
208
+ */
209
+ consolidate(): number;
210
+ /**
211
+ * Check if a pattern ID exists
212
+ */
213
+ hasPattern(pattern_id: string): boolean;
214
+ /**
215
+ * Get pattern count in shared index
216
+ */
217
+ patternCount(): number;
218
+ /**
219
+ * Create new collective memory with default config
220
+ */
221
+ constructor(node_id: string);
222
+ /**
223
+ * Search for similar patterns
224
+ */
225
+ search(query_json: string, k: number): string;
226
+ /**
227
+ * Get statistics as JSON
228
+ */
229
+ getStats(): string;
230
+ }
231
+
232
+ export class ContributionStream {
233
+ free(): void;
234
+ [Symbol.dispose](): void;
235
+ /**
236
+ * Check if streams are healthy
237
+ */
238
+ isHealthy(): boolean;
239
+ /**
240
+ * Process network fee distribution
241
+ */
242
+ processFees(total_fees: bigint, epoch: bigint): bigint;
243
+ /**
244
+ * Get total distributed
245
+ */
246
+ getTotalDistributed(): bigint;
247
+ constructor();
248
+ }
249
+
250
+ export class DifferentialPrivacy {
251
+ free(): void;
252
+ [Symbol.dispose](): void;
253
+ /**
254
+ * Check if DP is enabled
255
+ */
256
+ isEnabled(): boolean;
257
+ /**
258
+ * Get epsilon value
259
+ */
260
+ getEpsilon(): number;
261
+ /**
262
+ * Enable/disable differential privacy
263
+ */
264
+ setEnabled(enabled: boolean): void;
265
+ /**
266
+ * Create a new differential privacy module
267
+ */
268
+ constructor(epsilon: number, sensitivity: number);
269
+ }
270
+
271
+ export class DriftTracker {
272
+ free(): void;
273
+ [Symbol.dispose](): void;
274
+ /**
275
+ * Check if context has drifted beyond threshold
276
+ */
277
+ hasDrifted(context_hex: string): boolean;
278
+ /**
279
+ * Get contexts with significant drift
280
+ */
281
+ getDriftedContexts(): string;
282
+ /**
283
+ * Create a new drift tracker
284
+ */
285
+ constructor(drift_threshold: number);
286
+ /**
287
+ * Get drift for a context
288
+ */
289
+ getDrift(context_hex: string): number;
290
+ }
291
+
292
+ export class EconomicEngine {
293
+ free(): void;
294
+ [Symbol.dispose](): void;
295
+ /**
296
+ * Get economic health status
297
+ */
298
+ getHealth(): EconomicHealth;
299
+ /**
300
+ * Get treasury balance
301
+ */
302
+ getTreasury(): bigint;
303
+ /**
304
+ * Advance to next epoch
305
+ */
306
+ advanceEpoch(): void;
307
+ /**
308
+ * Process task completion and distribute rewards
309
+ */
310
+ processReward(base_amount: bigint, multiplier: number): RewardDistribution;
311
+ /**
312
+ * Get protocol fund balance (for development sustainability)
313
+ */
314
+ getProtocolFund(): bigint;
315
+ /**
316
+ * Check if network can sustain itself
317
+ */
318
+ isSelfSustaining(active_nodes: number, daily_tasks: bigint): boolean;
319
+ constructor();
320
+ }
321
+
322
+ export class EconomicHealth {
323
+ private constructor();
324
+ free(): void;
325
+ [Symbol.dispose](): void;
326
+ /**
327
+ * Velocity of rUv (transactions per period)
328
+ */
329
+ velocity: number;
330
+ /**
331
+ * Network utilization rate
332
+ */
333
+ utilization: number;
334
+ /**
335
+ * Supply growth rate
336
+ */
337
+ growth_rate: number;
338
+ /**
339
+ * Stability index (0-1)
340
+ */
341
+ stability: number;
342
+ }
343
+
344
+ export class EdgeNetConfig {
345
+ free(): void;
346
+ [Symbol.dispose](): void;
347
+ memoryLimit(bytes: number): EdgeNetConfig;
348
+ minIdleTime(ms: number): EdgeNetConfig;
349
+ respectBattery(respect: boolean): EdgeNetConfig;
350
+ constructor(site_id: string);
351
+ build(): EdgeNetNode;
352
+ addRelay(url: string): EdgeNetConfig;
353
+ cpuLimit(limit: number): EdgeNetConfig;
354
+ }
355
+
356
+ export class EdgeNetNode {
357
+ free(): void;
358
+ [Symbol.dispose](): void;
359
+ /**
360
+ * Disconnect from the network
361
+ */
362
+ disconnect(): void;
363
+ /**
364
+ * Enable HDC for hyperdimensional computing
365
+ */
366
+ enableHDC(): boolean;
367
+ /**
368
+ * Enable Neural Autonomous Organization for governance
369
+ */
370
+ enableNAO(quorum: number): boolean;
371
+ /**
372
+ * Enable WTA for instant decisions
373
+ */
374
+ enableWTA(num_neurons: number): boolean;
375
+ /**
376
+ * Enable BTSP for one-shot learning
377
+ */
378
+ enableBTSP(input_dim: number): boolean;
379
+ /**
380
+ * Propose an action in the NAO
381
+ */
382
+ proposeNAO(action: string): string;
383
+ /**
384
+ * Alias for creditBalance - returns rUv balance
385
+ */
386
+ ruvBalance(): bigint;
387
+ /**
388
+ * Submit a task to the network
389
+ */
390
+ submitTask(task_type: string, payload: Uint8Array, max_credits: bigint): Promise<any>;
391
+ /**
392
+ * Check for active celebration events
393
+ */
394
+ checkEvents(): string;
395
+ /**
396
+ * Get current throttle level (0.0 - 1.0)
397
+ */
398
+ getThrottle(): number;
399
+ /**
400
+ * Get treasury balance for operations
401
+ */
402
+ getTreasury(): bigint;
403
+ /**
404
+ * Check if a claim can be used (not quarantined)
405
+ */
406
+ canUseClaim(claim_id: string): boolean;
407
+ /**
408
+ * Process epoch for economic distribution
409
+ */
410
+ processEpoch(): void;
411
+ /**
412
+ * Store a learned pattern in the reasoning bank
413
+ */
414
+ storePattern(pattern_json: string): number;
415
+ /**
416
+ * Get current rUv (Resource Utility Voucher) balance
417
+ */
418
+ creditBalance(): bigint;
419
+ /**
420
+ * Get motivational message (subtle Easter egg)
421
+ */
422
+ getMotivation(): string;
423
+ /**
424
+ * Get current contribution multiplier based on network size
425
+ */
426
+ getMultiplier(): number;
427
+ /**
428
+ * Prune low-quality learned patterns
429
+ */
430
+ prunePatterns(min_usage: number, min_confidence: number): number;
431
+ /**
432
+ * Get current Merkle root for audit (Axiom 11: Equivocation detectable)
433
+ */
434
+ getMerkleRoot(): string;
435
+ /**
436
+ * Lookup similar patterns for task optimization
437
+ */
438
+ lookupPatterns(query_json: string, k: number): string;
439
+ /**
440
+ * Get all available exotic capabilities and their status
441
+ */
442
+ getCapabilities(): any;
443
+ /**
444
+ * Check if this node should replicate (high performer)
445
+ */
446
+ shouldReplicate(): boolean;
447
+ /**
448
+ * Enable MicroLoRA for self-learning
449
+ */
450
+ enableMicroLoRA(rank: number): boolean;
451
+ /**
452
+ * Get founding contributor count
453
+ */
454
+ getFounderCount(): number;
455
+ /**
456
+ * Get optimal peers for task routing
457
+ */
458
+ getOptimalPeers(count: number): string[];
459
+ /**
460
+ * Get stored pattern count
461
+ */
462
+ getPatternCount(): number;
463
+ /**
464
+ * Get protocol development fund balance
465
+ */
466
+ getProtocolFund(): bigint;
467
+ /**
468
+ * Get themed network status
469
+ */
470
+ getThemedStatus(node_count: number): string;
471
+ /**
472
+ * Get contribution stream health
473
+ */
474
+ isStreamHealthy(): boolean;
475
+ /**
476
+ * Process the next available task (called by worker)
477
+ */
478
+ processNextTask(): Promise<boolean>;
479
+ /**
480
+ * Step all exotic capabilities forward
481
+ */
482
+ stepCapabilities(dt: number): void;
483
+ /**
484
+ * Get active conflict count (Axiom 6: Disagreement is signal)
485
+ */
486
+ getConflictCount(): number;
487
+ /**
488
+ * Get learning statistics
489
+ */
490
+ getLearningStats(): string;
491
+ /**
492
+ * Check if network is self-sustaining
493
+ */
494
+ isSelfSustaining(active_nodes: number, daily_tasks: bigint): boolean;
495
+ /**
496
+ * Record node performance for evolution
497
+ */
498
+ recordPerformance(success_rate: number, throughput: number): void;
499
+ /**
500
+ * Run security audit (adversarial testing)
501
+ */
502
+ runSecurityAudit(): string;
503
+ /**
504
+ * Enable Time Crystal for P2P synchronization
505
+ */
506
+ enableTimeCrystal(oscillators: number): boolean;
507
+ /**
508
+ * Get coherence statistics
509
+ */
510
+ getCoherenceStats(): string;
511
+ /**
512
+ * Get economic health metrics
513
+ */
514
+ getEconomicHealth(): string;
515
+ /**
516
+ * Get network fitness score (0-1)
517
+ */
518
+ getNetworkFitness(): number;
519
+ /**
520
+ * Record task routing outcome for optimization
521
+ */
522
+ recordTaskRouting(task_type: string, node_id: string, latency_ms: bigint, success: boolean): void;
523
+ /**
524
+ * Enable Morphogenetic Network for emergent topology
525
+ */
526
+ enableMorphogenetic(size: number): boolean;
527
+ /**
528
+ * Get trajectory count for learning analysis
529
+ */
530
+ getTrajectoryCount(): number;
531
+ /**
532
+ * Get energy efficiency ratio from spike-driven attention
533
+ */
534
+ getEnergyEfficiency(seq_len: number, hidden_dim: number): number;
535
+ /**
536
+ * Get quarantined claim count (Axiom 9: Quarantine is mandatory)
537
+ */
538
+ getQuarantinedCount(): number;
539
+ /**
540
+ * Get Time Crystal synchronization level (0.0 - 1.0)
541
+ */
542
+ getTimeCrystalSync(): number;
543
+ /**
544
+ * Get optimization statistics
545
+ */
546
+ getOptimizationStats(): string;
547
+ /**
548
+ * Get recommended configuration for new nodes
549
+ */
550
+ getRecommendedConfig(): string;
551
+ /**
552
+ * Enable Global Workspace for attention
553
+ */
554
+ enableGlobalWorkspace(capacity: number): boolean;
555
+ /**
556
+ * Record peer interaction for topology optimization
557
+ */
558
+ recordPeerInteraction(peer_id: string, success_rate: number): void;
559
+ /**
560
+ * Get capabilities summary as JSON
561
+ */
562
+ getCapabilitiesSummary(): any;
563
+ /**
564
+ * Get coherence engine event count
565
+ */
566
+ getCoherenceEventCount(): number;
567
+ /**
568
+ * Get quarantine level for a claim
569
+ */
570
+ getClaimQuarantineLevel(claim_id: string): number;
571
+ /**
572
+ * Record a task execution trajectory for learning
573
+ */
574
+ recordLearningTrajectory(trajectory_json: string): boolean;
575
+ /**
576
+ * Create a new EdgeNet node
577
+ */
578
+ constructor(site_id: string, config?: NodeConfig | null);
579
+ /**
580
+ * Pause contribution
581
+ */
582
+ pause(): void;
583
+ /**
584
+ * Start contributing to the network
585
+ */
586
+ start(): void;
587
+ /**
588
+ * Resume contribution
589
+ */
590
+ resume(): void;
591
+ /**
592
+ * Check if user is currently idle
593
+ */
594
+ isIdle(): boolean;
595
+ /**
596
+ * Get the node's unique identifier
597
+ */
598
+ nodeId(): string;
599
+ /**
600
+ * Vote on a NAO proposal
601
+ */
602
+ voteNAO(proposal_id: string, weight: number): boolean;
603
+ /**
604
+ * Get node statistics
605
+ */
606
+ getStats(): NodeStats;
607
+ }
608
+
609
+ export class EntropyConsensus {
610
+ free(): void;
611
+ [Symbol.dispose](): void;
612
+ /**
613
+ * Get belief probability for a decision
614
+ */
615
+ getBelief(decision_id: bigint): number;
616
+ /**
617
+ * Get number of negotiation rounds completed
618
+ */
619
+ getRounds(): number;
620
+ /**
621
+ * Set initial belief for a decision
622
+ */
623
+ setBelief(decision_id: bigint, probability: number): void;
624
+ /**
625
+ * Get the winning decision (if converged)
626
+ */
627
+ getDecision(): bigint | undefined;
628
+ /**
629
+ * Get number of decision options
630
+ */
631
+ optionCount(): number;
632
+ /**
633
+ * Check if negotiation has timed out
634
+ */
635
+ hasTimedOut(): boolean;
636
+ /**
637
+ * Set belief without normalizing (for batch updates)
638
+ * Call normalize_beliefs() after all set_belief_raw calls
639
+ */
640
+ set_belief_raw(decision_id: bigint, probability: number): void;
641
+ /**
642
+ * Create with custom entropy threshold
643
+ */
644
+ static withThreshold(threshold: number): EntropyConsensus;
645
+ /**
646
+ * Get current temperature (for annealing)
647
+ */
648
+ getTemperature(): number;
649
+ /**
650
+ * Manually trigger normalization (for use after set_belief_raw)
651
+ */
652
+ finalize_beliefs(): void;
653
+ /**
654
+ * Get entropy history as JSON
655
+ */
656
+ getEntropyHistory(): string;
657
+ /**
658
+ * Get the entropy threshold for convergence
659
+ */
660
+ getEntropyThreshold(): number;
661
+ /**
662
+ * Create new entropy consensus with default configuration
663
+ */
664
+ constructor();
665
+ /**
666
+ * Reset consensus state for new decision
667
+ */
668
+ reset(): void;
669
+ /**
670
+ * Get current entropy of belief distribution
671
+ */
672
+ entropy(): number;
673
+ /**
674
+ * Check if consensus has been reached
675
+ */
676
+ converged(): boolean;
677
+ /**
678
+ * Get consensus statistics as JSON
679
+ */
680
+ getStats(): string;
681
+ }
682
+
683
+ export class EventLog {
684
+ free(): void;
685
+ [Symbol.dispose](): void;
686
+ /**
687
+ * Get total event count
688
+ */
689
+ totalEvents(): number;
690
+ /**
691
+ * Get current event count (includes all events)
692
+ */
693
+ len(): number;
694
+ /**
695
+ * Create a new event log
696
+ */
697
+ constructor();
698
+ /**
699
+ * Get current Merkle root as hex string
700
+ */
701
+ getRoot(): string;
702
+ /**
703
+ * Check if log is empty
704
+ */
705
+ isEmpty(): boolean;
706
+ }
707
+
708
+ export class EvolutionEngine {
709
+ free(): void;
710
+ [Symbol.dispose](): void;
711
+ /**
712
+ * Check if node should replicate (spawn similar node)
713
+ */
714
+ shouldReplicate(node_id: string): boolean;
715
+ /**
716
+ * Record node performance for fitness evaluation
717
+ */
718
+ recordPerformance(node_id: string, success_rate: number, throughput: number): void;
719
+ /**
720
+ * Get network fitness score
721
+ */
722
+ getNetworkFitness(): number;
723
+ /**
724
+ * Get recommended configuration for new nodes
725
+ */
726
+ getRecommendedConfig(): string;
727
+ constructor();
728
+ /**
729
+ * Evolve patterns for next generation
730
+ */
731
+ evolve(): void;
732
+ }
733
+
734
+ export class FederatedModel {
735
+ free(): void;
736
+ [Symbol.dispose](): void;
737
+ /**
738
+ * Get parameter dimension
739
+ */
740
+ getDimension(): number;
741
+ /**
742
+ * Get parameters as array
743
+ */
744
+ getParameters(): Float32Array;
745
+ /**
746
+ * Set parameters from array
747
+ */
748
+ setParameters(params: Float32Array): void;
749
+ /**
750
+ * Apply aggregated gradients to update model
751
+ */
752
+ applyGradients(gradients: Float32Array): void;
753
+ /**
754
+ * Set local epochs per round
755
+ */
756
+ setLocalEpochs(epochs: number): void;
757
+ /**
758
+ * Set learning rate
759
+ */
760
+ setLearningRate(lr: number): void;
761
+ /**
762
+ * Create a new federated model
763
+ */
764
+ constructor(dimension: number, learning_rate: number, momentum: number);
765
+ /**
766
+ * Get current round
767
+ */
768
+ getRound(): bigint;
769
+ }
770
+
771
+ export class FoundingRegistry {
772
+ free(): void;
773
+ [Symbol.dispose](): void;
774
+ /**
775
+ * Process epoch distribution
776
+ */
777
+ processEpoch(current_epoch: bigint, available_amount: bigint): any[];
778
+ /**
779
+ * Calculate vested amount for current epoch
780
+ */
781
+ calculateVested(current_epoch: bigint, pool_balance: bigint): bigint;
782
+ /**
783
+ * Get founding contributor count
784
+ */
785
+ getFounderCount(): number;
786
+ /**
787
+ * Register additional founding contributor
788
+ */
789
+ registerContributor(id: string, category: string, weight: number): void;
790
+ constructor();
791
+ }
792
+
793
+ export class GenesisKey {
794
+ free(): void;
795
+ [Symbol.dispose](): void;
796
+ /**
797
+ * Get ID as hex
798
+ */
799
+ getIdHex(): string;
800
+ /**
801
+ * Export ultra-compact genesis key (21 bytes only)
802
+ */
803
+ exportUltraCompact(): Uint8Array;
804
+ /**
805
+ * Create a new genesis key
806
+ */
807
+ constructor(creator: PiKey, epoch: number);
808
+ /**
809
+ * Get the φ-sized genesis ID
810
+ */
811
+ getId(): Uint8Array;
812
+ /**
813
+ * Verify this genesis key was created by a specific Pi-Key
814
+ */
815
+ verify(creator_public_key: Uint8Array): boolean;
816
+ /**
817
+ * Get epoch
818
+ */
819
+ getEpoch(): number;
820
+ }
821
+
822
+ export class GenesisSunset {
823
+ free(): void;
824
+ [Symbol.dispose](): void;
825
+ /**
826
+ * Check if it's safe to retire genesis nodes
827
+ */
828
+ canRetire(): boolean;
829
+ /**
830
+ * Get sunset status
831
+ */
832
+ getStatus(): string;
833
+ /**
834
+ * Check if genesis nodes should be read-only
835
+ */
836
+ isReadOnly(): boolean;
837
+ /**
838
+ * Get current sunset phase
839
+ * 0 = Active (genesis required)
840
+ * 1 = Transition (stop new connections)
841
+ * 2 = Read-only (genesis read-only)
842
+ * 3 = Retired (genesis can be removed)
843
+ */
844
+ getCurrentPhase(): number;
845
+ /**
846
+ * Update network node count
847
+ */
848
+ updateNodeCount(count: number): number;
849
+ /**
850
+ * Check if network is self-sustaining
851
+ */
852
+ isSelfSustaining(): boolean;
853
+ /**
854
+ * Register a genesis node
855
+ */
856
+ registerGenesisNode(node_id: string): void;
857
+ /**
858
+ * Check if genesis nodes should accept new connections
859
+ */
860
+ shouldAcceptConnections(): boolean;
861
+ constructor();
862
+ }
863
+
864
+ export class GradientGossip {
865
+ free(): void;
866
+ [Symbol.dispose](): void;
867
+ /**
868
+ * Get number of active peers
869
+ */
870
+ peerCount(): number;
871
+ /**
872
+ * Prune stale peer gradients
873
+ */
874
+ pruneStale(): number;
875
+ /**
876
+ * Configure differential privacy
877
+ */
878
+ configureDifferentialPrivacy(epsilon: number, sensitivity: number): void;
879
+ /**
880
+ * Advance to next consensus round
881
+ */
882
+ advanceRound(): bigint;
883
+ /**
884
+ * Get gradient dimension
885
+ */
886
+ getDimension(): number;
887
+ /**
888
+ * Enable/disable differential privacy
889
+ */
890
+ setDPEnabled(enabled: boolean): void;
891
+ /**
892
+ * Set model hash for version compatibility
893
+ */
894
+ setModelHash(hash: Uint8Array): void;
895
+ /**
896
+ * Get current consensus round
897
+ */
898
+ getCurrentRound(): bigint;
899
+ /**
900
+ * Set local gradients from JavaScript
901
+ */
902
+ setLocalGradients(gradients: Float32Array): void;
903
+ /**
904
+ * Get compression ratio achieved
905
+ */
906
+ getCompressionRatio(): number;
907
+ /**
908
+ * Get aggregated gradients as JavaScript array
909
+ */
910
+ getAggregatedGradients(): Float32Array;
911
+ /**
912
+ * Create a new GradientGossip instance
913
+ *
914
+ * # Arguments
915
+ * * `local_peer_id` - 32-byte peer identifier
916
+ * * `dimension` - Gradient vector dimension
917
+ * * `k_ratio` - TopK sparsification ratio (0.1 = keep top 10%)
918
+ */
919
+ constructor(local_peer_id: Uint8Array, dimension: number, k_ratio: number);
920
+ /**
921
+ * Get statistics as JSON
922
+ */
923
+ getStats(): string;
924
+ }
925
+
926
+ export class ModelConsensusManager {
927
+ free(): void;
928
+ [Symbol.dispose](): void;
929
+ /**
930
+ * Get number of tracked models
931
+ */
932
+ modelCount(): number;
933
+ /**
934
+ * Get number of active disputes
935
+ */
936
+ disputeCount(): number;
937
+ /**
938
+ * Get number of quarantined updates
939
+ */
940
+ quarantinedUpdateCount(): number;
941
+ /**
942
+ * Create a new model consensus manager
943
+ */
944
+ constructor(min_witnesses: number);
945
+ /**
946
+ * Get statistics as JSON
947
+ */
948
+ getStats(): string;
949
+ }
950
+
951
+ export class MultiHeadAttention {
952
+ free(): void;
953
+ [Symbol.dispose](): void;
954
+ /**
955
+ * Get embedding dimension
956
+ */
957
+ dim(): number;
958
+ /**
959
+ * Create new multi-head attention
960
+ */
961
+ constructor(dim: number, num_heads: number);
962
+ /**
963
+ * Get number of heads
964
+ */
965
+ numHeads(): number;
966
+ }
967
+
968
+ export class NetworkEvents {
969
+ free(): void;
970
+ [Symbol.dispose](): void;
971
+ /**
972
+ * Get a subtle motivational message
973
+ */
974
+ getMotivation(balance: bigint): string;
975
+ /**
976
+ * Check for discovery triggers (Easter eggs)
977
+ */
978
+ checkDiscovery(action: string, node_id: string): string | undefined;
979
+ /**
980
+ * Get ASCII art for special occasions
981
+ */
982
+ getSpecialArt(): string | undefined;
983
+ /**
984
+ * Check milestone achievements
985
+ */
986
+ checkMilestones(balance: bigint, node_id: string): string;
987
+ /**
988
+ * Set current time (for testing)
989
+ */
990
+ setCurrentTime(timestamp: bigint): void;
991
+ /**
992
+ * Get network status with thematic flair
993
+ */
994
+ getThemedStatus(node_count: number, total_ruv: bigint): string;
995
+ /**
996
+ * Check for active special events
997
+ */
998
+ checkActiveEvents(): string;
999
+ /**
1000
+ * Get celebration multiplier boost
1001
+ */
1002
+ getCelebrationBoost(): number;
1003
+ constructor();
1004
+ }
1005
+
1006
+ export class NetworkLearning {
1007
+ free(): void;
1008
+ [Symbol.dispose](): void;
1009
+ /**
1010
+ * Get pattern count
1011
+ */
1012
+ patternCount(): number;
1013
+ /**
1014
+ * Store a learned pattern
1015
+ */
1016
+ storePattern(pattern_json: string): number;
1017
+ /**
1018
+ * Look up similar patterns
1019
+ */
1020
+ lookupPatterns(query_json: string, k: number): string;
1021
+ /**
1022
+ * Get energy savings ratio for spike-driven attention
1023
+ */
1024
+ getEnergyRatio(seq_len: number, hidden_dim: number): number;
1025
+ /**
1026
+ * Get trajectory count
1027
+ */
1028
+ trajectoryCount(): number;
1029
+ /**
1030
+ * Record a task execution trajectory
1031
+ */
1032
+ recordTrajectory(trajectory_json: string): boolean;
1033
+ /**
1034
+ * Create new network learning intelligence
1035
+ */
1036
+ constructor();
1037
+ /**
1038
+ * Prune low-quality patterns
1039
+ */
1040
+ prune(min_usage: number, min_confidence: number): number;
1041
+ /**
1042
+ * Get combined statistics
1043
+ */
1044
+ getStats(): string;
1045
+ }
1046
+
1047
+ export class NetworkTopology {
1048
+ free(): void;
1049
+ [Symbol.dispose](): void;
1050
+ /**
1051
+ * Register a node in the topology
1052
+ */
1053
+ registerNode(node_id: string, capabilities: Float32Array): void;
1054
+ /**
1055
+ * Get optimal peers for a node
1056
+ */
1057
+ getOptimalPeers(node_id: string, count: number): string[];
1058
+ /**
1059
+ * Update connection strength between nodes
1060
+ */
1061
+ updateConnection(from: string, to: string, success_rate: number): void;
1062
+ constructor();
1063
+ }
1064
+
1065
+ export class NodeConfig {
1066
+ private constructor();
1067
+ free(): void;
1068
+ [Symbol.dispose](): void;
1069
+ /**
1070
+ * Maximum CPU usage when idle (0.0 - 1.0)
1071
+ */
1072
+ cpu_limit: number;
1073
+ /**
1074
+ * Maximum memory usage in bytes
1075
+ */
1076
+ memory_limit: number;
1077
+ /**
1078
+ * Maximum bandwidth in bytes/sec
1079
+ */
1080
+ bandwidth_limit: number;
1081
+ /**
1082
+ * Minimum idle time before contributing (ms)
1083
+ */
1084
+ min_idle_time: number;
1085
+ /**
1086
+ * Whether to reduce contribution on battery
1087
+ */
1088
+ respect_battery: boolean;
1089
+ }
1090
+
1091
+ export class NodeStats {
1092
+ private constructor();
1093
+ free(): void;
1094
+ [Symbol.dispose](): void;
1095
+ /**
1096
+ * Total rUv (Resource Utility Vouchers) earned
1097
+ */
1098
+ ruv_earned: bigint;
1099
+ /**
1100
+ * Total rUv spent
1101
+ */
1102
+ ruv_spent: bigint;
1103
+ /**
1104
+ * Tasks completed
1105
+ */
1106
+ tasks_completed: bigint;
1107
+ /**
1108
+ * Tasks submitted
1109
+ */
1110
+ tasks_submitted: bigint;
1111
+ /**
1112
+ * Total uptime in seconds
1113
+ */
1114
+ uptime_seconds: bigint;
1115
+ /**
1116
+ * Current reputation score (0.0 - 1.0)
1117
+ */
1118
+ reputation: number;
1119
+ /**
1120
+ * Current contribution multiplier
1121
+ */
1122
+ multiplier: number;
1123
+ /**
1124
+ * Active lifecycle events
1125
+ */
1126
+ celebration_boost: number;
1127
+ }
1128
+
1129
+ export class OptimizationEngine {
1130
+ free(): void;
1131
+ [Symbol.dispose](): void;
1132
+ /**
1133
+ * Record task routing outcome
1134
+ */
1135
+ recordRouting(task_type: string, node_id: string, latency_ms: bigint, success: boolean): void;
1136
+ /**
1137
+ * Get optimal node for a task type
1138
+ */
1139
+ selectOptimalNode(task_type: string, candidates: string[]): string;
1140
+ constructor();
1141
+ /**
1142
+ * Get optimization stats
1143
+ */
1144
+ getStats(): string;
1145
+ }
1146
+
1147
+ export class PiKey {
1148
+ free(): void;
1149
+ [Symbol.dispose](): void;
1150
+ /**
1151
+ * Get the Pi-sized identity (40 bytes)
1152
+ */
1153
+ getIdentity(): Uint8Array;
1154
+ /**
1155
+ * Get short identity (first 8 bytes as hex)
1156
+ */
1157
+ getShortId(): string;
1158
+ /**
1159
+ * Export minimal key representation (Pi + Phi sized = 61 bytes total)
1160
+ */
1161
+ exportCompact(): Uint8Array;
1162
+ /**
1163
+ * Get public key for verification
1164
+ */
1165
+ getPublicKey(): Uint8Array;
1166
+ /**
1167
+ * Verify this key has Pi magic marker
1168
+ */
1169
+ verifyPiMagic(): boolean;
1170
+ /**
1171
+ * Get identity as hex string
1172
+ */
1173
+ getIdentityHex(): string;
1174
+ /**
1175
+ * Restore from encrypted backup (supports both v1 legacy and v2 Argon2id)
1176
+ */
1177
+ static restoreFromBackup(backup: Uint8Array, password: string): PiKey;
1178
+ /**
1179
+ * Create encrypted backup of private key using Argon2id KDF
1180
+ */
1181
+ createEncryptedBackup(password: string): Uint8Array;
1182
+ /**
1183
+ * Get the Phi-sized genesis fingerprint (21 bytes)
1184
+ */
1185
+ getGenesisFingerprint(): Uint8Array;
1186
+ /**
1187
+ * Sign data with this key
1188
+ */
1189
+ sign(data: Uint8Array): Uint8Array;
1190
+ /**
1191
+ * Verify signature from another Pi-Key
1192
+ */
1193
+ verify(data: Uint8Array, signature: Uint8Array, public_key: Uint8Array): boolean;
1194
+ /**
1195
+ * Generate a new Pi-Key with genesis linking
1196
+ */
1197
+ constructor(genesis_seed?: Uint8Array | null);
1198
+ /**
1199
+ * Get key statistics
1200
+ */
1201
+ getStats(): string;
1202
+ }
1203
+
1204
+ export class QDAGLedger {
1205
+ free(): void;
1206
+ [Symbol.dispose](): void;
1207
+ /**
1208
+ * Export ledger state for sync
1209
+ */
1210
+ exportState(): Uint8Array;
1211
+ /**
1212
+ * Import ledger state from sync
1213
+ */
1214
+ importState(state_bytes: Uint8Array): number;
1215
+ /**
1216
+ * Get total supply
1217
+ */
1218
+ totalSupply(): bigint;
1219
+ /**
1220
+ * Get staked amount for a node
1221
+ */
1222
+ stakedAmount(node_id: string): bigint;
1223
+ /**
1224
+ * Create genesis transaction (called once at network start)
1225
+ */
1226
+ createGenesis(initial_supply: bigint, founder_pubkey: Uint8Array): Uint8Array;
1227
+ /**
1228
+ * Get transaction count
1229
+ */
1230
+ transactionCount(): number;
1231
+ /**
1232
+ * Create and validate a new transaction
1233
+ */
1234
+ createTransaction(sender_id: string, recipient_id: string, amount: bigint, tx_type: number, sender_privkey: Uint8Array, sender_pubkey: Uint8Array): Uint8Array;
1235
+ /**
1236
+ * Create a new QDAG ledger
1237
+ */
1238
+ constructor();
1239
+ /**
1240
+ * Get balance for a node
1241
+ */
1242
+ balance(node_id: string): bigint;
1243
+ /**
1244
+ * Get tip count
1245
+ */
1246
+ tipCount(): number;
1247
+ }
1248
+
1249
+ export class QuarantineManager {
1250
+ free(): void;
1251
+ [Symbol.dispose](): void;
1252
+ /**
1253
+ * Get number of quarantined claims
1254
+ */
1255
+ quarantinedCount(): number;
1256
+ /**
1257
+ * Create a new quarantine manager
1258
+ */
1259
+ constructor();
1260
+ /**
1261
+ * Check if claim can be used in decisions
1262
+ */
1263
+ canUse(claim_id: string): boolean;
1264
+ /**
1265
+ * Check quarantine level for a claim
1266
+ */
1267
+ getLevel(claim_id: string): number;
1268
+ /**
1269
+ * Set quarantine level
1270
+ */
1271
+ setLevel(claim_id: string, level: number): void;
1272
+ }
1273
+
1274
+ export class RacEconomicEngine {
1275
+ free(): void;
1276
+ [Symbol.dispose](): void;
1277
+ /**
1278
+ * Get summary statistics as JSON
1279
+ */
1280
+ getSummary(): string;
1281
+ /**
1282
+ * Check if node can participate (has stake + reputation)
1283
+ */
1284
+ canParticipate(node_id: Uint8Array): boolean;
1285
+ /**
1286
+ * Get combined score (stake-weighted reputation)
1287
+ */
1288
+ getCombinedScore(node_id: Uint8Array): number;
1289
+ /**
1290
+ * Create a new RAC economic engine
1291
+ */
1292
+ constructor();
1293
+ }
1294
+
1295
+ export class RacSemanticRouter {
1296
+ free(): void;
1297
+ [Symbol.dispose](): void;
1298
+ /**
1299
+ * Get peer count
1300
+ */
1301
+ peerCount(): number;
1302
+ /**
1303
+ * Create a new semantic router
1304
+ */
1305
+ constructor();
1306
+ }
1307
+
1308
+ export class RateLimiter {
1309
+ free(): void;
1310
+ [Symbol.dispose](): void;
1311
+ /**
1312
+ * Check if request is allowed
1313
+ */
1314
+ checkAllowed(node_id: string): boolean;
1315
+ constructor(window_ms: bigint, max_requests: number);
1316
+ /**
1317
+ * Reset rate limiter
1318
+ */
1319
+ reset(): void;
1320
+ /**
1321
+ * Get current count for a node
1322
+ */
1323
+ getCount(node_id: string): number;
1324
+ }
1325
+
1326
+ export class ReasoningBank {
1327
+ free(): void;
1328
+ [Symbol.dispose](): void;
1329
+ /**
1330
+ * Create a new ReasoningBank
1331
+ */
1332
+ constructor();
1333
+ /**
1334
+ * Get total pattern count
1335
+ */
1336
+ count(): number;
1337
+ /**
1338
+ * Prune low-quality patterns
1339
+ */
1340
+ prune(min_usage: number, min_confidence: number): number;
1341
+ /**
1342
+ * Store a new pattern (JSON format)
1343
+ */
1344
+ store(pattern_json: string): number;
1345
+ /**
1346
+ * Lookup most similar patterns (OPTIMIZED with spatial indexing)
1347
+ */
1348
+ lookup(query_json: string, k: number): string;
1349
+ /**
1350
+ * Get bank statistics
1351
+ */
1352
+ getStats(): string;
1353
+ }
1354
+
1355
+ export class ReputationManager {
1356
+ free(): void;
1357
+ [Symbol.dispose](): void;
1358
+ /**
1359
+ * Get number of tracked nodes
1360
+ */
1361
+ nodeCount(): number;
1362
+ /**
1363
+ * Get effective reputation for a node (with decay applied)
1364
+ */
1365
+ getReputation(node_id: Uint8Array): number;
1366
+ /**
1367
+ * Get average network reputation
1368
+ */
1369
+ averageReputation(): number;
1370
+ /**
1371
+ * Check if node has sufficient reputation
1372
+ */
1373
+ hasSufficientReputation(node_id: Uint8Array): boolean;
1374
+ /**
1375
+ * Create a new reputation manager
1376
+ */
1377
+ constructor(decay_rate: number, decay_interval_ms: bigint);
1378
+ }
1379
+
1380
+ export class ReputationSystem {
1381
+ free(): void;
1382
+ [Symbol.dispose](): void;
1383
+ /**
1384
+ * Get reputation score for a node
1385
+ */
1386
+ getReputation(node_id: string): number;
1387
+ /**
1388
+ * Record failed task completion
1389
+ */
1390
+ recordFailure(node_id: string): void;
1391
+ /**
1392
+ * Record penalty (fraud, invalid result)
1393
+ */
1394
+ recordPenalty(node_id: string, severity: number): void;
1395
+ /**
1396
+ * Record successful task completion
1397
+ */
1398
+ recordSuccess(node_id: string): void;
1399
+ /**
1400
+ * Check if node can participate
1401
+ */
1402
+ canParticipate(node_id: string): boolean;
1403
+ constructor();
1404
+ }
1405
+
1406
+ export class RewardDistribution {
1407
+ private constructor();
1408
+ free(): void;
1409
+ [Symbol.dispose](): void;
1410
+ total: bigint;
1411
+ contributor_share: bigint;
1412
+ treasury_share: bigint;
1413
+ protocol_share: bigint;
1414
+ founder_share: bigint;
1415
+ }
1416
+
1417
+ export class RewardManager {
1418
+ free(): void;
1419
+ [Symbol.dispose](): void;
1420
+ /**
1421
+ * Get number of pending rewards
1422
+ */
1423
+ pendingCount(): number;
1424
+ /**
1425
+ * Get total pending reward amount
1426
+ */
1427
+ pendingAmount(): bigint;
1428
+ /**
1429
+ * Get claimable rewards for a node
1430
+ */
1431
+ claimableAmount(node_id: Uint8Array): bigint;
1432
+ /**
1433
+ * Create a new reward manager
1434
+ */
1435
+ constructor(default_vesting_ms: bigint);
1436
+ }
1437
+
1438
+ export class SemanticRouter {
1439
+ free(): void;
1440
+ [Symbol.dispose](): void;
1441
+ /**
1442
+ * Get peer count
1443
+ */
1444
+ peerCount(): number;
1445
+ /**
1446
+ * Get topic count
1447
+ */
1448
+ topicCount(): number;
1449
+ /**
1450
+ * Create with custom parameters
1451
+ */
1452
+ static withParams(embedding_dim: number, semantic_neighbors: number, random_sample: number): SemanticRouter;
1453
+ /**
1454
+ * Set my peer identity
1455
+ */
1456
+ setMyPeerId(peer_id: Uint8Array): void;
1457
+ /**
1458
+ * Get active peer count (seen in last 60 seconds)
1459
+ */
1460
+ activePeerCount(): number;
1461
+ /**
1462
+ * Set my capabilities and update my centroid
1463
+ */
1464
+ setMyCapabilities(capabilities: string[]): void;
1465
+ /**
1466
+ * Create a new semantic router
1467
+ */
1468
+ constructor();
1469
+ /**
1470
+ * Get statistics as JSON
1471
+ */
1472
+ getStats(): string;
1473
+ }
1474
+
1475
+ export class SessionKey {
1476
+ free(): void;
1477
+ [Symbol.dispose](): void;
1478
+ /**
1479
+ * Get ID as hex
1480
+ */
1481
+ getIdHex(): string;
1482
+ /**
1483
+ * Check if session is expired
1484
+ */
1485
+ isExpired(): boolean;
1486
+ /**
1487
+ * Get parent identity fingerprint
1488
+ */
1489
+ getParentIdentity(): Uint8Array;
1490
+ /**
1491
+ * Create a new session key linked to a Pi-Key identity
1492
+ */
1493
+ constructor(parent: PiKey, ttl_seconds: number);
1494
+ /**
1495
+ * Get the e-sized session ID
1496
+ */
1497
+ getId(): Uint8Array;
1498
+ /**
1499
+ * Decrypt data with this session key
1500
+ */
1501
+ decrypt(data: Uint8Array): Uint8Array;
1502
+ /**
1503
+ * Encrypt data with this session key
1504
+ */
1505
+ encrypt(plaintext: Uint8Array): Uint8Array;
1506
+ }
1507
+
1508
+ export class SpikeDrivenAttention {
1509
+ free(): void;
1510
+ [Symbol.dispose](): void;
1511
+ /**
1512
+ * Create with custom parameters
1513
+ */
1514
+ static withConfig(threshold: number, steps: number, refractory: number): SpikeDrivenAttention;
1515
+ /**
1516
+ * Estimate energy savings ratio compared to standard attention
1517
+ */
1518
+ energyRatio(seq_len: number, hidden_dim: number): number;
1519
+ /**
1520
+ * Create new spike-driven attention with default config
1521
+ */
1522
+ constructor();
1523
+ }
1524
+
1525
+ export class SpotChecker {
1526
+ free(): void;
1527
+ [Symbol.dispose](): void;
1528
+ /**
1529
+ * Check if a task should include a spot-check
1530
+ */
1531
+ shouldCheck(): boolean;
1532
+ /**
1533
+ * Add a known challenge-response pair
1534
+ */
1535
+ addChallenge(task_type: string, input: Uint8Array, expected_output: Uint8Array): void;
1536
+ /**
1537
+ * Get a random challenge for a task type
1538
+ */
1539
+ getChallenge(task_type: string): Uint8Array | undefined;
1540
+ /**
1541
+ * Verify a challenge response
1542
+ */
1543
+ verifyResponse(input_hash: Uint8Array, output: Uint8Array): boolean;
1544
+ constructor(check_probability: number);
1545
+ }
1546
+
1547
+ export class StakeManager {
1548
+ free(): void;
1549
+ [Symbol.dispose](): void;
1550
+ /**
1551
+ * Get number of stakers
1552
+ */
1553
+ stakerCount(): number;
1554
+ /**
1555
+ * Get total staked amount in network
1556
+ */
1557
+ totalStaked(): bigint;
1558
+ /**
1559
+ * Get minimum stake requirement
1560
+ */
1561
+ getMinStake(): bigint;
1562
+ /**
1563
+ * Check if node has sufficient stake
1564
+ */
1565
+ hasSufficientStake(node_id: Uint8Array): boolean;
1566
+ /**
1567
+ * Create a new stake manager
1568
+ */
1569
+ constructor(min_stake: bigint);
1570
+ /**
1571
+ * Get staked amount for a node
1572
+ */
1573
+ getStake(node_id: Uint8Array): bigint;
1574
+ }
1575
+
1576
+ export class SwarmIntelligence {
1577
+ free(): void;
1578
+ [Symbol.dispose](): void;
1579
+ /**
1580
+ * Get queue size
1581
+ */
1582
+ queueSize(): number;
1583
+ /**
1584
+ * Set belief for a topic's decision
1585
+ */
1586
+ setBelief(topic: string, decision_id: bigint, probability: number): void;
1587
+ /**
1588
+ * Add pattern to collective memory
1589
+ */
1590
+ addPattern(pattern_json: string): boolean;
1591
+ /**
1592
+ * Run memory consolidation
1593
+ */
1594
+ consolidate(): number;
1595
+ /**
1596
+ * Check if topic has reached consensus
1597
+ */
1598
+ hasConsensus(topic: string): boolean;
1599
+ /**
1600
+ * Get collective memory pattern count
1601
+ */
1602
+ patternCount(): number;
1603
+ /**
1604
+ * Search collective memory
1605
+ */
1606
+ searchPatterns(query_json: string, k: number): string;
1607
+ /**
1608
+ * Start a new consensus round for a topic
1609
+ */
1610
+ startConsensus(topic: string, threshold: number): void;
1611
+ /**
1612
+ * Negotiate beliefs for a topic
1613
+ */
1614
+ negotiateBeliefs(topic: string, beliefs_json: string): boolean;
1615
+ /**
1616
+ * Get consensus decision for topic
1617
+ */
1618
+ getConsensusDecision(topic: string): bigint | undefined;
1619
+ /**
1620
+ * Create new swarm intelligence coordinator
1621
+ */
1622
+ constructor(node_id: string);
1623
+ /**
1624
+ * Run hippocampal replay
1625
+ */
1626
+ replay(): number;
1627
+ /**
1628
+ * Get node ID
1629
+ */
1630
+ nodeId(): string;
1631
+ /**
1632
+ * Get combined statistics as JSON
1633
+ */
1634
+ getStats(): string;
1635
+ }
1636
+
1637
+ export class SybilDefense {
1638
+ free(): void;
1639
+ [Symbol.dispose](): void;
1640
+ /**
1641
+ * Register a node with its fingerprint
1642
+ */
1643
+ registerNode(node_id: string, fingerprint: string): boolean;
1644
+ /**
1645
+ * Get sybil score (0.0 = likely unique, 1.0 = likely sybil)
1646
+ */
1647
+ getSybilScore(node_id: string): number;
1648
+ /**
1649
+ * Check if node is likely a sybil
1650
+ */
1651
+ isSuspectedSybil(node_id: string): boolean;
1652
+ constructor();
1653
+ }
1654
+
1655
+ /**
1656
+ * Task priority levels
1657
+ */
1658
+ export enum TaskPriority {
1659
+ Low = 0,
1660
+ Normal = 1,
1661
+ High = 2,
1662
+ }
1663
+
1664
+ /**
1665
+ * Task types supported by the network
1666
+ */
1667
+ export enum TaskType {
1668
+ /**
1669
+ * Vector search in HNSW index
1670
+ */
1671
+ VectorSearch = 0,
1672
+ /**
1673
+ * Vector insertion
1674
+ */
1675
+ VectorInsert = 1,
1676
+ /**
1677
+ * Generate embeddings
1678
+ */
1679
+ Embedding = 2,
1680
+ /**
1681
+ * Semantic task-to-agent matching
1682
+ */
1683
+ SemanticMatch = 3,
1684
+ /**
1685
+ * Neural network inference
1686
+ */
1687
+ NeuralInference = 4,
1688
+ /**
1689
+ * AES encryption/decryption
1690
+ */
1691
+ Encryption = 5,
1692
+ /**
1693
+ * Data compression
1694
+ */
1695
+ Compression = 6,
1696
+ /**
1697
+ * Custom WASM module (requires verification)
1698
+ */
1699
+ CustomWasm = 7,
1700
+ }
1701
+
1702
+ export class TopKSparsifier {
1703
+ free(): void;
1704
+ [Symbol.dispose](): void;
1705
+ /**
1706
+ * Reset error feedback buffer
1707
+ */
1708
+ resetErrorFeedback(): void;
1709
+ /**
1710
+ * Get compression ratio
1711
+ */
1712
+ getCompressionRatio(): number;
1713
+ /**
1714
+ * Get error feedback buffer size
1715
+ */
1716
+ getErrorBufferSize(): number;
1717
+ /**
1718
+ * Create a new TopK sparsifier
1719
+ *
1720
+ * # Arguments
1721
+ * * `k_ratio` - Fraction of gradients to keep (0.1 = top 10%)
1722
+ */
1723
+ constructor(k_ratio: number);
1724
+ }
1725
+
1726
+ export class TrajectoryTracker {
1727
+ free(): void;
1728
+ [Symbol.dispose](): void;
1729
+ /**
1730
+ * Create a new trajectory tracker
1731
+ */
1732
+ constructor(max_size: number);
1733
+ /**
1734
+ * Get count of trajectories
1735
+ */
1736
+ count(): number;
1737
+ /**
1738
+ * Record a new trajectory
1739
+ */
1740
+ record(trajectory_json: string): boolean;
1741
+ /**
1742
+ * Get statistics as JSON
1743
+ */
1744
+ getStats(): string;
1745
+ }
1746
+
1747
+ export class WasmAdapterPool {
1748
+ free(): void;
1749
+ [Symbol.dispose](): void;
1750
+ /**
1751
+ * Get or create an adapter for a task type
1752
+ */
1753
+ getAdapter(task_type: string): any;
1754
+ /**
1755
+ * Get adapter count
1756
+ */
1757
+ adapterCount(): number;
1758
+ /**
1759
+ * Export adapter to bytes for P2P sharing
1760
+ */
1761
+ exportAdapter(task_type: string): Uint8Array;
1762
+ /**
1763
+ * Import adapter from bytes
1764
+ */
1765
+ importAdapter(task_type: string, bytes: Uint8Array): boolean;
1766
+ /**
1767
+ * Route to best adapter by task embedding
1768
+ */
1769
+ routeToAdapter(task_embedding: Float32Array): any;
1770
+ /**
1771
+ * Create a new adapter pool
1772
+ */
1773
+ constructor(hidden_dim: number, max_slots: number);
1774
+ /**
1775
+ * Apply adapter to input
1776
+ */
1777
+ forward(task_type: string, input: Float32Array): Float32Array;
1778
+ /**
1779
+ * Get pool statistics
1780
+ */
1781
+ getStats(): any;
1782
+ }
1783
+
1784
+ export class WasmCapabilities {
1785
+ free(): void;
1786
+ [Symbol.dispose](): void;
1787
+ enableHDC(): boolean;
1788
+ enableNAO(_quorum: number): boolean;
1789
+ enableWTA(_num_neurons: number, _inhibition: number, _threshold: number): boolean;
1790
+ competeWTA(_activations: Float32Array): number;
1791
+ enableBTSP(_input_dim: number, _time_constant: number): boolean;
1792
+ executeNAO(_proposal_id: string): boolean;
1793
+ /**
1794
+ * Get a summary of all enabled capabilities
1795
+ */
1796
+ getSummary(): any;
1797
+ proposeNAO(_action: string): string;
1798
+ forwardBTSP(_input: Float32Array): number;
1799
+ getNAOSync(): number;
1800
+ retrieveHDC(_key: string, _threshold: number): any;
1801
+ addNAOMember(_member_id: string, _stake: bigint): boolean;
1802
+ adaptMicroLoRA(_operator_type: string, _gradient: Float32Array): boolean;
1803
+ applyMicroLoRA(_operator_type: string, input: Float32Array): Float32Array;
1804
+ /**
1805
+ * List all available exotic capabilities
1806
+ */
1807
+ getCapabilities(): any;
1808
+ enableMicroLoRA(_dim: number, _rank: number): boolean;
1809
+ tickTimeCrystal(): any;
1810
+ growMorphogenetic(_rate: number): void;
1811
+ oneShotAssociate(_pattern: Float32Array, _target: number): boolean;
1812
+ enableTimeCrystal(_oscillators: number, _period_ms: number): boolean;
1813
+ pruneMorphogenetic(_threshold: number): void;
1814
+ enableMorphogenetic(_width: number, _height: number): boolean;
1815
+ getTimeCrystalSync(): number;
1816
+ broadcastToWorkspace(_content: Float32Array, _salience: number, _source_module: number): boolean;
1817
+ getWorkspaceContents(): any;
1818
+ isTimeCrystalStable(): boolean;
1819
+ enableGlobalWorkspace(_capacity: number): boolean;
1820
+ getMorphogeneticStats(): any;
1821
+ differentiateMorphogenetic(): void;
1822
+ getMorphogeneticCellCount(): number;
1823
+ /**
1824
+ * Create a new capabilities manager for a node
1825
+ */
1826
+ constructor(node_id: string);
1827
+ /**
1828
+ * Step all enabled capabilities forward (for main loop integration)
1829
+ */
1830
+ step(dt: number): void;
1831
+ tickNAO(_dt: number): void;
1832
+ voteNAO(_proposal_id: string, _weight: number): boolean;
1833
+ storeHDC(_key: string): boolean;
1834
+ }
1835
+
1836
+ export class WasmCreditLedger {
1837
+ free(): void;
1838
+ [Symbol.dispose](): void;
1839
+ /**
1840
+ * Get total spent
1841
+ */
1842
+ totalSpent(): bigint;
1843
+ /**
1844
+ * Export spent counter for sync
1845
+ */
1846
+ exportSpent(): Uint8Array;
1847
+ /**
1848
+ * Get total earned (before spending)
1849
+ */
1850
+ totalEarned(): bigint;
1851
+ /**
1852
+ * Export earned counter for sync
1853
+ */
1854
+ exportEarned(): Uint8Array;
1855
+ /**
1856
+ * Get staked amount
1857
+ */
1858
+ stakedAmount(): bigint;
1859
+ /**
1860
+ * Get network compute hours (for multiplier)
1861
+ */
1862
+ networkCompute(): number;
1863
+ /**
1864
+ * Get current multiplier
1865
+ */
1866
+ currentMultiplier(): number;
1867
+ /**
1868
+ * Update network compute (from P2P sync)
1869
+ */
1870
+ updateNetworkCompute(hours: number): void;
1871
+ /**
1872
+ * Create a new credit ledger
1873
+ */
1874
+ constructor(node_id: string);
1875
+ /**
1876
+ * Merge with another ledger (CRDT merge) - optimized batch processing
1877
+ */
1878
+ merge(other_earned: Uint8Array, other_spent: Uint8Array): void;
1879
+ /**
1880
+ * Slash staked credits (penalty for bad behavior)
1881
+ */
1882
+ slash(amount: bigint): bigint;
1883
+ /**
1884
+ * Stake credits for participation
1885
+ */
1886
+ stake(amount: bigint): void;
1887
+ /**
1888
+ * Credit the ledger (earn credits)
1889
+ */
1890
+ credit(amount: bigint, reason: string): void;
1891
+ /**
1892
+ * Deduct from the ledger (spend credits)
1893
+ */
1894
+ deduct(amount: bigint): void;
1895
+ /**
1896
+ * Get current balance
1897
+ */
1898
+ balance(): bigint;
1899
+ /**
1900
+ * Unstake credits
1901
+ */
1902
+ unstake(amount: bigint): void;
1903
+ }
1904
+
1905
+ export class WasmIdleDetector {
1906
+ free(): void;
1907
+ [Symbol.dispose](): void;
1908
+ /**
1909
+ * Get status summary
1910
+ */
1911
+ getStatus(): any;
1912
+ /**
1913
+ * Update FPS measurement
1914
+ */
1915
+ updateFps(fps: number): void;
1916
+ /**
1917
+ * Check if we should be working
1918
+ */
1919
+ shouldWork(): boolean;
1920
+ /**
1921
+ * Get current throttle level (0.0 - max_cpu)
1922
+ */
1923
+ getThrottle(): number;
1924
+ /**
1925
+ * Record user interaction
1926
+ */
1927
+ recordInteraction(): void;
1928
+ /**
1929
+ * Set battery status (called from JS)
1930
+ */
1931
+ setBatteryStatus(on_battery: boolean): void;
1932
+ /**
1933
+ * Create a new idle detector
1934
+ */
1935
+ constructor(max_cpu: number, min_idle_time: number);
1936
+ /**
1937
+ * Stop monitoring
1938
+ */
1939
+ stop(): void;
1940
+ /**
1941
+ * Pause contribution (user-initiated)
1942
+ */
1943
+ pause(): void;
1944
+ /**
1945
+ * Start monitoring
1946
+ */
1947
+ start(): void;
1948
+ /**
1949
+ * Resume contribution
1950
+ */
1951
+ resume(): void;
1952
+ /**
1953
+ * Check if user is idle
1954
+ */
1955
+ isIdle(): boolean;
1956
+ }
1957
+
1958
+ export class WasmMcpBroadcast {
1959
+ free(): void;
1960
+ [Symbol.dispose](): void;
1961
+ /**
1962
+ * Set as server mode (responds to requests)
1963
+ */
1964
+ setServer(server: WasmMcpServer): void;
1965
+ /**
1966
+ * Create a broadcast transport
1967
+ */
1968
+ constructor(channel_name: string);
1969
+ /**
1970
+ * Send a request (client mode)
1971
+ */
1972
+ send(request_json: string): void;
1973
+ /**
1974
+ * Close the channel
1975
+ */
1976
+ close(): void;
1977
+ /**
1978
+ * Start listening for requests (server mode)
1979
+ */
1980
+ listen(): void;
1981
+ }
1982
+
1983
+ export class WasmMcpServer {
1984
+ free(): void;
1985
+ [Symbol.dispose](): void;
1986
+ /**
1987
+ * Create with custom configuration
1988
+ */
1989
+ static withConfig(config: any): WasmMcpServer;
1990
+ /**
1991
+ * Set identity for authenticated operations
1992
+ */
1993
+ setIdentity(identity: WasmNodeIdentity): void;
1994
+ /**
1995
+ * Initialize learning engine
1996
+ */
1997
+ initLearning(): void;
1998
+ /**
1999
+ * Handle an MCP request (JSON string)
2000
+ */
2001
+ handleRequest(request_json: string): Promise<string>;
2002
+ /**
2003
+ * Get server info
2004
+ */
2005
+ getServerInfo(): any;
2006
+ /**
2007
+ * Handle MCP request from JsValue (for direct JS calls)
2008
+ */
2009
+ handleRequestJs(request: any): Promise<any>;
2010
+ /**
2011
+ * Create a new MCP server with default configuration
2012
+ */
2013
+ constructor();
2014
+ }
2015
+
2016
+ export class WasmMcpTransport {
2017
+ free(): void;
2018
+ [Symbol.dispose](): void;
2019
+ /**
2020
+ * Create transport from a Worker
2021
+ */
2022
+ constructor(worker: Worker);
2023
+ /**
2024
+ * Initialize transport (set up message handler)
2025
+ */
2026
+ init(): void;
2027
+ /**
2028
+ * Send an MCP request and get a Promise for the response
2029
+ */
2030
+ send(request: any): Promise<any>;
2031
+ /**
2032
+ * Close the transport
2033
+ */
2034
+ close(): void;
2035
+ /**
2036
+ * Create transport from existing MessagePort
2037
+ */
2038
+ static fromPort(port: MessagePort): WasmMcpTransport;
2039
+ }
2040
+
2041
+ export class WasmMcpWorkerHandler {
2042
+ free(): void;
2043
+ [Symbol.dispose](): void;
2044
+ /**
2045
+ * Create handler with MCP server
2046
+ */
2047
+ constructor(server: WasmMcpServer);
2048
+ /**
2049
+ * Start handling messages (call in worker)
2050
+ */
2051
+ start(): void;
2052
+ }
2053
+
2054
+ export class WasmNetworkManager {
2055
+ free(): void;
2056
+ [Symbol.dispose](): void;
2057
+ /**
2058
+ * Get peer count
2059
+ */
2060
+ peerCount(): number;
2061
+ /**
2062
+ * Check if connected
2063
+ */
2064
+ isConnected(): boolean;
2065
+ /**
2066
+ * Register a peer
2067
+ */
2068
+ registerPeer(node_id: string, pubkey: Uint8Array, capabilities: string[], stake: bigint): void;
2069
+ /**
2070
+ * Select workers for task execution (reputation-weighted random)
2071
+ */
2072
+ selectWorkers(capability: string, count: number): string[];
2073
+ /**
2074
+ * Get active peer count (seen in last 60s)
2075
+ */
2076
+ activePeerCount(): number;
2077
+ /**
2078
+ * Update peer reputation
2079
+ */
2080
+ updateReputation(node_id: string, delta: number): void;
2081
+ /**
2082
+ * Get peers with specific capability
2083
+ */
2084
+ getPeersWithCapability(capability: string): string[];
2085
+ constructor(node_id: string);
2086
+ /**
2087
+ * Add a relay URL
2088
+ */
2089
+ addRelay(url: string): void;
2090
+ }
2091
+
2092
+ export class WasmNodeIdentity {
2093
+ private constructor();
2094
+ free(): void;
2095
+ [Symbol.dispose](): void;
2096
+ /**
2097
+ * Verify a signature from another node
2098
+ */
2099
+ static verifyFrom(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
2100
+ /**
2101
+ * Get the public key as hex string
2102
+ */
2103
+ publicKeyHex(): string;
2104
+ /**
2105
+ * Restore identity from secret key bytes
2106
+ */
2107
+ static fromSecretKey(secret_key: Uint8Array, site_id: string): WasmNodeIdentity;
2108
+ /**
2109
+ * Get browser fingerprint
2110
+ */
2111
+ getFingerprint(): string | undefined;
2112
+ /**
2113
+ * Set browser fingerprint for anti-sybil
2114
+ */
2115
+ setFingerprint(fingerprint: string): void;
2116
+ /**
2117
+ * Get the public key as bytes
2118
+ */
2119
+ publicKeyBytes(): Uint8Array;
2120
+ /**
2121
+ * Export secret key encrypted with password (secure backup)
2122
+ * Uses Argon2id for key derivation and AES-256-GCM for encryption
2123
+ */
2124
+ exportSecretKey(password: string): Uint8Array;
2125
+ /**
2126
+ * Import secret key from encrypted backup
2127
+ */
2128
+ static importSecretKey(encrypted: Uint8Array, password: string, site_id: string): WasmNodeIdentity;
2129
+ /**
2130
+ * Sign a message
2131
+ */
2132
+ sign(message: Uint8Array): Uint8Array;
2133
+ /**
2134
+ * Verify a signature
2135
+ */
2136
+ verify(message: Uint8Array, signature: Uint8Array): boolean;
2137
+ /**
2138
+ * Get the node's unique identifier
2139
+ */
2140
+ nodeId(): string;
2141
+ /**
2142
+ * Get the site ID
2143
+ */
2144
+ siteId(): string;
2145
+ /**
2146
+ * Generate a new node identity
2147
+ */
2148
+ static generate(site_id: string): WasmNodeIdentity;
2149
+ }
2150
+
2151
+ export class WasmStigmergy {
2152
+ free(): void;
2153
+ [Symbol.dispose](): void;
2154
+ /**
2155
+ * Create with custom parameters
2156
+ */
2157
+ static withParams(decay_rate: number, deposit_rate: number, evaporation_hours: number): WasmStigmergy;
2158
+ /**
2159
+ * Export current state for P2P sharing
2160
+ */
2161
+ exportState(): string;
2162
+ /**
2163
+ * Get raw pheromone intensity
2164
+ */
2165
+ getIntensity(task_type: string): number;
2166
+ /**
2167
+ * Set minimum stake for anti-sybil
2168
+ */
2169
+ setMinStake(min_stake: bigint): void;
2170
+ /**
2171
+ * Should this node accept a task? (combined decision)
2172
+ */
2173
+ shouldAccept(task_type: string): number;
2174
+ /**
2175
+ * Check and run evaporation if due
2176
+ */
2177
+ maybeEvaporate(): boolean;
2178
+ /**
2179
+ * Get all task types ranked by attractiveness
2180
+ */
2181
+ getRankedTasks(): string;
2182
+ /**
2183
+ * Get success rate for a task type
2184
+ */
2185
+ getSuccessRate(task_type: string): number;
2186
+ /**
2187
+ * Get node's specialization score
2188
+ */
2189
+ getSpecialization(task_type: string): number;
2190
+ /**
2191
+ * Deposit with success/failure outcome
2192
+ */
2193
+ depositWithOutcome(task_type: string, peer_id: string, success: boolean, stake: bigint): void;
2194
+ /**
2195
+ * Update node specialization based on outcome
2196
+ */
2197
+ updateSpecialization(task_type: string, success: boolean): void;
2198
+ /**
2199
+ * Get best specialization recommendation
2200
+ */
2201
+ getBestSpecialization(): string | undefined;
2202
+ /**
2203
+ * Create a new stigmergy engine
2204
+ */
2205
+ constructor();
2206
+ /**
2207
+ * Merge peer pheromone state (JSON format)
2208
+ */
2209
+ merge(peer_state_json: string): boolean;
2210
+ /**
2211
+ * Get acceptance probability for a task type
2212
+ */
2213
+ follow(task_type: string): number;
2214
+ /**
2215
+ * Deposit pheromone after task completion
2216
+ */
2217
+ deposit(task_type: string, peer_id: string, success_rate: number, stake: bigint): void;
2218
+ /**
2219
+ * Run evaporation (call periodically)
2220
+ */
2221
+ evaporate(): void;
2222
+ /**
2223
+ * Get statistics as JSON
2224
+ */
2225
+ getStats(): string;
2226
+ }
2227
+
2228
+ export class WasmTaskExecutor {
2229
+ free(): void;
2230
+ [Symbol.dispose](): void;
2231
+ /**
2232
+ * Set encryption key for payload decryption
2233
+ */
2234
+ setTaskKey(key: Uint8Array): void;
2235
+ /**
2236
+ * Create a new task executor
2237
+ */
2238
+ constructor(max_memory: number);
2239
+ }
2240
+
2241
+ export class WasmTaskQueue {
2242
+ private constructor();
2243
+ free(): void;
2244
+ [Symbol.dispose](): void;
2245
+ }
2246
+
2247
+ export class WasmWorkScheduler {
2248
+ free(): void;
2249
+ [Symbol.dispose](): void;
2250
+ /**
2251
+ * Calculate how many tasks to run this frame
2252
+ */
2253
+ tasksThisFrame(throttle: number): number;
2254
+ /**
2255
+ * Set pending task count
2256
+ */
2257
+ setPendingTasks(count: number): void;
2258
+ /**
2259
+ * Record task completion for averaging
2260
+ */
2261
+ recordTaskDuration(duration_ms: number): void;
2262
+ constructor();
2263
+ }
2264
+
2265
+ export class WitnessTracker {
2266
+ free(): void;
2267
+ [Symbol.dispose](): void;
2268
+ /**
2269
+ * Get witness count for a claim
2270
+ */
2271
+ witnessCount(claim_id: string): number;
2272
+ /**
2273
+ * Get confidence score based on witness diversity
2274
+ */
2275
+ witnessConfidence(claim_id: string): number;
2276
+ /**
2277
+ * Check if claim has sufficient independent witnesses
2278
+ */
2279
+ hasSufficientWitnesses(claim_id: string): boolean;
2280
+ /**
2281
+ * Create a new witness tracker
2282
+ */
2283
+ constructor(min_witnesses: number);
2284
+ }
2285
+
2286
+ /**
2287
+ * Initialize panic hook for better error messages in console
2288
+ */
2289
+ export function init_panic_hook(): void;