/** * Public types for `@lensmcp/memory-tracker`. The tracker emits * `BaseEvent`s through a pluggable sink (same shape as * `@lensmcp/nest-instrumentation`'s EventSink) so the host process can * forward them to the LensMCP bus. */ import type { BaseEvent, MemoryContainerKind, MemoryMutationOperation } from '@lensmcp/protocol-types'; export type { MemoryContainerKind, MemoryMutationOperation }; export type MemoryEventSink = (event: BaseEvent) => void; export interface MemoryContext { sessionId: string; flowId?: string; requestId?: string; originNodeId?: string; } /** Resolved options after defaults are applied. */ export interface ResolvedMemoryOptions { sessionId: string; sink: MemoryEventSink; /** Owner growth (in items) within a flow that flips a suspected leak. Default 50. */ leakItemThreshold: number; /** Bytes retained by a disposed singleton that flags stale-generation. Default 1MB. */ staleGenerationBytesThreshold: number; /** ms to wait after flow end before checking owner shrinkage. Default 1000. */ settleMs: number; } export interface MemoryOwnerSnapshot { ownerId: string; ownerInstanceId: string; containerKind: MemoryContainerKind; fieldName: string; itemCount: number; estimatedBytes: number; growthSinceStart: number; }