/**
 * Memory Boxes + Trace Weaving (v8.0 Phase 2A)
 *
 * Implements the Membox concept: a sliding topic window that forms an "open box"
 * accumulating related memories. The box is sealed on topic shift or time gap,
 * then written to memory/boxes/YYYY-MM-DD/box-<id>.md.
 *
 * Trace Weaving links recurring topic boxes with a shared traceId so that
 * cross-session continuity on the same topics is preserved and discoverable.
 */
declare const BOX_DIR = "boxes";
interface BoxFrontmatter {
    id: string;
    memoryKind: "box";
    createdAt: string;
    sealedAt: string;
    sealReason: SealReason;
    sessionKey?: string;
    topics: string[];
    memoryIds: string[];
    traceId?: string;
    /** High-level task goal for this episode (REMem-inspired). */
    goal?: string;
    /** Tools invoked during this episode. */
    toolsUsed?: string[];
    /** Episode outcome: success, failure, partial, or unknown. */
    outcome?: "success" | "failure" | "partial" | "unknown";
}
type SealReason = "topic_shift" | "time_gap" | "max_memories" | "forced" | "flush";
interface BoxBuilderConfig {
    memoryBoxesEnabled: boolean;
    traceWeaverEnabled: boolean;
    /** Jaccard threshold below which topic shift triggers seal (0-1, default 0.35) */
    boxTopicShiftThreshold: number;
    /** Time gap in ms before sealing an open box (default 30 min) */
    boxTimeGapMs: number;
    /** Max memories in one box before forced seal */
    boxMaxMemories: number;
    /** Days back to look for trace links */
    traceWeaverLookbackDays: number;
    /** Minimum topic overlap to assign same traceId (0-1, default 0.4) */
    traceWeaverOverlapThreshold: number;
}
interface ExtractionEvent {
    topics: string[];
    memoryIds: string[];
    timestamp: string;
    goal?: string;
    toolsUsed?: string[];
}
/**
 * Jaccard similarity between two topic arrays.
 * Returns 0.0 for empty inputs.
 */
declare function topicOverlapScore(a: string[], b: string[]): number;
declare function parseBoxFrontmatter(raw: string): BoxFrontmatter | null;
declare class BoxBuilder {
    private baseDir;
    private cfg;
    private openBox;
    private stateLoaded;
    constructor(baseDir: string, cfg: BoxBuilderConfig);
    private get boxBaseDir();
    private get stateDir();
    private get openBoxStatePath();
    private get tracesPath();
    private loadOpenBox;
    private saveOpenBox;
    private loadTraceIndex;
    private saveTraceIndex;
    /**
     * Called after each extraction run.
     * Decides whether to seal the current open box and/or start a new one.
     */
    onExtraction(event: ExtractionEvent): Promise<void>;
    private newBox;
    /**
     * Seal the current open box and write it to disk.
     * Also runs trace weaving if enabled.
     */
    sealCurrent(reason: SealReason): Promise<string | null>;
    /**
     * Find an existing trace that matches box topics, or create a new trace.
     * Returns the traceId to assign to this box.
     */
    private resolveTrace;
    /**
     * Read all sealed boxes from the last N days for recall injection.
     */
    readRecentBoxes(days: number): Promise<BoxFrontmatter[]>;
}

export { BOX_DIR, BoxBuilder, type BoxBuilderConfig, type BoxFrontmatter, type SealReason, parseBoxFrontmatter, topicOverlapScore };
