/**
 * Event Emitter for Memory Events
 *
 * Broadcasts memory changes to connected WebSocket clients
 * for real-time visualization updates.
 */
import { EventEmitter } from 'events';
import { Memory, ConsolidationResult } from '../memory/types.js';
export type MemoryEventType = 'memory_created' | 'memory_accessed' | 'memory_updated' | 'memory_deleted' | 'consolidation_complete' | 'decay_tick' | 'session_started' | 'session_ended' | 'worker_light_tick' | 'worker_medium_tick' | 'link_discovered' | 'predictive_consolidation' | 'defence_event' | 'kill_switch_activated' | 'kill_switch_deactivated' | 'update_started' | 'update_complete' | 'update_failed' | 'server_restarting' | 'xray_detection';
export interface MemoryEvent {
    type: MemoryEventType;
    timestamp: string;
    data: unknown;
}
export interface MemoryCreatedEvent extends MemoryEvent {
    type: 'memory_created';
    data: {
        memory: Memory;
        /**
         * IDs of ontology entities linked to this memory at creation time.
         * Required for the pulse layer (Living Constellation Graph) to map
         * a creation event to its graph nodes. Always emitted — may be empty
         * if no entities were extracted.
         */
        entity_ids: number[];
    };
}
export interface MemoryAccessedEvent extends MemoryEvent {
    type: 'memory_accessed';
    data: {
        memoryId: number;
        memory: Memory;
        newSalience: number;
        /**
         * IDs of ontology entities linked to this memory at access time.
         * Required for the pulse layer to highlight related graph nodes
         * when a memory is touched. Always emitted — may be empty.
         */
        entity_ids: number[];
    };
}
export interface MemoryUpdatedEvent extends MemoryEvent {
    type: 'memory_updated';
    data: {
        memory: Memory;
    };
}
export interface MemoryDeletedEvent extends MemoryEvent {
    type: 'memory_deleted';
    data: {
        memoryId: number;
        title: string;
    };
}
export interface ConsolidationEvent extends MemoryEvent {
    type: 'consolidation_complete';
    data: ConsolidationResult & {
        promotedMemories: number[];
        deletedMemories: number[];
    };
}
export interface DecayTickEvent extends MemoryEvent {
    type: 'decay_tick';
    data: {
        updates: Array<{
            memoryId: number;
            oldScore: number;
            newScore: number;
        }>;
    };
}
export interface WorkerLightTickEvent extends MemoryEvent {
    type: 'worker_light_tick';
    data: {
        activationsPruned: number;
        predictiveConsolidation: ConsolidationResult | null;
        timestamp: string;
    };
}
export interface WorkerMediumTickEvent extends MemoryEvent {
    type: 'worker_medium_tick';
    data: {
        linksDiscovered: number;
        contradictionsFound: number;
        contradictionsLinked: number;
        memoriesScanned: number;
        timestamp: string;
    };
}
export interface LinkDiscoveredEvent extends MemoryEvent {
    type: 'link_discovered';
    data: {
        sourceId: number;
        targetId: number;
        relationship: string;
        strength: number;
    };
}
export interface PredictiveConsolidationEvent extends MemoryEvent {
    type: 'predictive_consolidation';
    data: {
        trigger: string;
        urgency: string;
        result: ConsolidationResult;
    };
}
declare class MemoryEventEmitter extends EventEmitter {
    emit(event: MemoryEventType, data: MemoryEvent['data']): boolean;
    onMemoryEvent(callback: (event: MemoryEvent) => void): void;
    offMemoryEvent(callback: (event: MemoryEvent) => void): void;
}
export declare const memoryEvents: MemoryEventEmitter;
export declare function emitMemoryCreated(memory: Memory, entityIds?: number[]): void;
export declare function emitMemoryAccessed(memory: Memory, newSalience: number, entityIds?: number[]): void;
export declare function emitMemoryUpdated(memory: Memory): void;
export declare function emitMemoryDeleted(memoryId: number, title: string): void;
export declare function emitConsolidation(result: ConsolidationResult, promotedMemories?: number[], deletedMemories?: number[]): void;
export declare function emitDecayTick(updates: Array<{
    memoryId: number;
    oldScore: number;
    newScore: number;
}>): void;
export declare function emitWorkerLightTick(data: {
    activationsPruned: number;
    predictiveConsolidation: ConsolidationResult | null;
    timestamp: Date;
}): void;
export declare function emitWorkerMediumTick(data: {
    linksDiscovered: number;
    contradictionsFound: number;
    contradictionsLinked: number;
    memoriesScanned: number;
    timestamp: Date;
}): void;
export declare function emitLinkDiscovered(data: {
    sourceId: number;
    targetId: number;
    relationship: string;
    strength: number;
}): void;
export declare function emitDefenceEvent(data: {
    source_type: string;
    source_identifier: string;
    firewall_result: string;
    trust_score: number;
    anomaly_score: number;
    reason: string | null;
    threat_indicators: string;
    timestamp: string;
}): void;
export declare function emitPredictiveConsolidation(data: {
    trigger: string;
    urgency: string;
    result: ConsolidationResult;
}): void;
export declare function emitKillSwitchActivated(data: {
    triggeredAt: string;
    source: string;
    phrase?: string;
    reason?: string;
    memoryCountAtTrigger?: number;
}): void;
export declare function emitKillSwitchDeactivated(data: {
    reason: string;
    previousMeta: unknown;
}): void;
/**
 * Persist event to database for cross-process IPC.
 * Called by MCP server when tools are invoked.
 * The API server polls for these events and broadcasts to WebSocket clients.
 */
export declare function persistEvent(type: MemoryEventType, data?: unknown): void;
/**
 * Get unprocessed events from database.
 * Called by API server to poll for new events from MCP process.
 */
export declare function getUnprocessedEvents(limit?: number): Array<{
    id: number;
    type: MemoryEventType;
    data: unknown;
    timestamp: string;
}>;
/**
 * Mark events as processed after broadcasting.
 */
export declare function markEventsProcessed(ids: number[]): void;
/**
 * Cleanup old processed events (keep last 24 hours).
 * Called periodically by API server.
 */
export declare function cleanupOldEvents(): void;
export {};
