| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export declare const NEURAL_CONSTANTS: { |
| | readonly MAX_DRIFT_EVENTS: 1000; |
| | readonly MAX_HISTORY_SIZE: 500; |
| | readonly DEFAULT_DRIFT_THRESHOLD: 0.15; |
| | readonly DEFAULT_DRIFT_WINDOW_MS: 60000; |
| | readonly DRIFT_CRITICAL_MULTIPLIER: 2; |
| | readonly VELOCITY_WINDOW_SIZE: 10; |
| | readonly MAX_MEMORIES: 10000; |
| | readonly MAX_CONTENT_LENGTH: 10000; |
| | readonly MAX_ID_LENGTH: 256; |
| | readonly DEFAULT_MEMORY_DECAY_RATE: 0.01; |
| | readonly DEFAULT_INTERFERENCE_THRESHOLD: 0.8; |
| | readonly DEFAULT_CONSOLIDATION_RATE: 0.1; |
| | readonly MEMORY_FORGET_THRESHOLD: 0.01; |
| | readonly CONSOLIDATION_SCORE_THRESHOLD: 0.5; |
| | readonly MEMORY_CLEANUP_PERCENT: 0.1; |
| | readonly RECALL_STRENGTH_BOOST: 0.1; |
| | readonly MAX_TIME_JUMP_MINUTES: 1440; |
| | readonly MAX_AGENTS: 1000; |
| | readonly MAX_SPECIALTY_LENGTH: 100; |
| | readonly AGENT_TIMEOUT_MS: 3600000; |
| | readonly DEFAULT_AGENT_ENERGY: 1; |
| | readonly TRAJECTORY_DAMPING: 0.1; |
| | readonly MAX_TRAJECTORY_STEPS: 100; |
| | readonly MAX_CLUSTER_AGENTS: 500; |
| | readonly DEFAULT_CLUSTER_THRESHOLD: 0.7; |
| | readonly DEFAULT_WINDOW_SIZE: 100; |
| | readonly MIN_CALIBRATION_OBSERVATIONS: 10; |
| | readonly STABILITY_WINDOW_SIZE: 10; |
| | readonly ALIGNMENT_WINDOW_SIZE: 50; |
| | readonly RECENT_OBSERVATIONS_SIZE: 20; |
| | readonly DRIFT_WARNING_THRESHOLD: 0.3; |
| | readonly STABILITY_WARNING_THRESHOLD: 0.5; |
| | readonly ALIGNMENT_WARNING_THRESHOLD: 0.6; |
| | readonly COHERENCE_WARNING_THRESHOLD: 0.5; |
| | readonly EPSILON: 1e-8; |
| | readonly ZERO_VECTOR_THRESHOLD: 1e-10; |
| | readonly DEFAULT_DIMENSION: 384; |
| | readonly DEFAULT_REFLEX_LATENCY_MS: 10; |
| | }; |
| | export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; |
| | export interface NeuralLogger { |
| | log(level: LogLevel, message: string, data?: Record<string, unknown>): void; |
| | } |
| | |
| | export declare const defaultLogger: NeuralLogger; |
| | |
| | export declare const silentLogger: NeuralLogger; |
| | export interface DriftEvent { |
| | readonly timestamp: number; |
| | readonly magnitude: number; |
| | readonly direction: Float32Array; |
| | readonly category: 'normal' | 'warning' | 'critical'; |
| | readonly source?: string; |
| | } |
| | export interface NeuralMemoryEntry { |
| | readonly id: string; |
| | readonly embedding: Float32Array; |
| | readonly content: string; |
| | strength: number; |
| | lastAccess: number; |
| | accessCount: number; |
| | consolidationLevel: number; |
| | interference: number; |
| | } |
| | export interface AgentState { |
| | readonly id: string; |
| | position: Float32Array; |
| | velocity: Float32Array; |
| | attention: Float32Array; |
| | energy: number; |
| | mode: string; |
| | lastUpdate: number; |
| | } |
| | export interface CoherenceReport { |
| | readonly timestamp: number; |
| | readonly overallScore: number; |
| | readonly driftScore: number; |
| | readonly stabilityScore: number; |
| | readonly alignmentScore: number; |
| | readonly anomalies: ReadonlyArray<{ |
| | readonly type: string; |
| | readonly severity: number; |
| | readonly description: string; |
| | }>; |
| | } |
| | export interface NeuralConfig { |
| | readonly dimension?: number; |
| | readonly driftThreshold?: number; |
| | readonly driftWindowMs?: number; |
| | readonly memoryDecayRate?: number; |
| | readonly interferenceThreshold?: number; |
| | readonly consolidationRate?: number; |
| | readonly reflexLatencyMs?: number; |
| | readonly logger?: NeuralLogger; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class SemanticDriftDetector { |
| | private baseline; |
| | private history; |
| | private driftEvents; |
| | private config; |
| | private logger; |
| | private reflexes; |
| | constructor(config?: NeuralConfig); |
| | |
| | |
| | |
| | setBaseline(embedding: number[] | Float32Array): void; |
| | |
| | |
| | |
| | observe(embedding: number[] | Float32Array, source?: string): DriftEvent | null; |
| | |
| | |
| | |
| | private calculateDrift; |
| | |
| | |
| | |
| | registerReflex(name: string, callback: (event: DriftEvent) => void): void; |
| | |
| | |
| | |
| | private triggerReflexes; |
| | |
| | |
| | |
| | getVelocity(): number; |
| | |
| | |
| | |
| | getStats(): { |
| | currentDrift: number; |
| | velocity: number; |
| | criticalEvents: number; |
| | warningEvents: number; |
| | historySize: number; |
| | }; |
| | |
| | |
| | |
| | recenter(): void; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class MemoryPhysics { |
| | private memories; |
| | private config; |
| | private lastUpdate; |
| | private logger; |
| | constructor(config?: NeuralConfig); |
| | |
| | |
| | |
| | encode(id: string, embedding: number[] | Float32Array, content: string): NeuralMemoryEntry; |
| | |
| | |
| | |
| | recall(query: number[] | Float32Array, k?: number): NeuralMemoryEntry[]; |
| | |
| | |
| | |
| | private applyDecay; |
| | |
| | |
| | |
| | |
| | consolidate(): { |
| | consolidated: number; |
| | forgotten: number; |
| | }; |
| | |
| | |
| | |
| | getStats(): { |
| | totalMemories: number; |
| | avgStrength: number; |
| | avgConsolidation: number; |
| | avgInterference: number; |
| | }; |
| | private cosineSimilarity; |
| | |
| | |
| | |
| | private forceCleanup; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class EmbeddingStateMachine { |
| | private agents; |
| | private modeRegions; |
| | private config; |
| | private logger; |
| | private lastCleanup; |
| | constructor(config?: NeuralConfig); |
| | |
| | |
| | |
| | updateAgent(id: string, embedding: number[] | Float32Array): AgentState; |
| | |
| | |
| | |
| | private cleanupStaleAgents; |
| | |
| | |
| | |
| | removeAgent(id: string): boolean; |
| | |
| | |
| | |
| | defineMode(name: string, centroid: number[] | Float32Array, radius?: number): void; |
| | |
| | |
| | |
| | private determineMode; |
| | |
| | |
| | |
| | predictTrajectory(id: string, steps?: number): Float32Array[]; |
| | |
| | |
| | |
| | attendTo(agentId: string, focusEmbedding: number[] | Float32Array): void; |
| | |
| | |
| | |
| | getAgentsInMode(mode: string): AgentState[]; |
| | private euclideanDistance; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class SwarmCoordinator { |
| | private agents; |
| | private sharedContext; |
| | private config; |
| | private logger; |
| | constructor(config?: NeuralConfig); |
| | |
| | |
| | |
| | register(id: string, embedding: number[] | Float32Array, specialty?: string): void; |
| | |
| | |
| | |
| | update(id: string, embedding: number[] | Float32Array): void; |
| | |
| | |
| | |
| | private updateSharedContext; |
| | |
| | |
| | |
| | getCoordinationSignal(id: string): Float32Array; |
| | |
| | |
| | |
| | findCollaborators(id: string, k?: number): Array<{ |
| | id: string; |
| | similarity: number; |
| | specialty: string; |
| | }>; |
| | |
| | |
| | |
| | detectClusters(threshold?: number): Map<string, string[]>; |
| | |
| | |
| | |
| | getCoherence(): number; |
| | private cosineSimilarity; |
| | |
| | |
| | |
| | removeAgent(id: string): boolean; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class CoherenceMonitor { |
| | private history; |
| | private baselineDistribution; |
| | private config; |
| | private logger; |
| | constructor(config?: NeuralConfig & { |
| | windowSize?: number; |
| | }); |
| | |
| | |
| | |
| | observe(embedding: number[] | Float32Array, source?: string): void; |
| | |
| | |
| | |
| | calibrate(): void; |
| | |
| | |
| | |
| | report(): CoherenceReport; |
| | private calculateDriftScore; |
| | private calculateStabilityScore; |
| | private calculateAlignmentScore; |
| | private cosineSimilarity; |
| | } |
| | |
| | |
| | |
| | |
| | export declare class NeuralSubstrate { |
| | readonly drift: SemanticDriftDetector; |
| | readonly memory: MemoryPhysics; |
| | readonly state: EmbeddingStateMachine; |
| | readonly swarm: SwarmCoordinator; |
| | readonly coherence: CoherenceMonitor; |
| | private config; |
| | private logger; |
| | private reflexLatency; |
| | constructor(config?: NeuralConfig); |
| | |
| | |
| | |
| | process(embedding: number[] | Float32Array, options?: { |
| | agentId?: string; |
| | memoryId?: string; |
| | content?: string; |
| | source?: string; |
| | }): { |
| | drift: DriftEvent | null; |
| | memory: NeuralMemoryEntry | null; |
| | state: AgentState | null; |
| | }; |
| | |
| | |
| | |
| | query(embedding: number[] | Float32Array, k?: number): { |
| | memories: NeuralMemoryEntry[]; |
| | collaborators: Array<{ |
| | id: string; |
| | similarity: number; |
| | specialty: string; |
| | }>; |
| | coherence: CoherenceReport; |
| | }; |
| | |
| | |
| | |
| | health(): { |
| | driftStats: ReturnType<SemanticDriftDetector['getStats']>; |
| | memoryStats: ReturnType<MemoryPhysics['getStats']>; |
| | swarmCoherence: number; |
| | coherenceReport: CoherenceReport; |
| | }; |
| | |
| | |
| | |
| | consolidate(): { |
| | consolidated: number; |
| | forgotten: number; |
| | }; |
| | |
| | |
| | |
| | calibrate(): void; |
| | } |
| | export default NeuralSubstrate; |
| | |