import type { MemoryWriter } from "./memory-writer.js";
export interface MemorySearchOptions {
    limit?: number;
    minScore?: number;
    preferredCategories?: string[];
    llmConfig?: unknown;
}
export interface MemorySearchResult {
    blockId: string;
    id?: string;
    path?: string;
    text: string;
    content?: string;
    score: number;
    source?: string;
    metadata?: Record<string, unknown>;
}
export interface MemoryIngestMessage {
    role: string;
    content: string;
    timestamp?: number;
}
export interface MemoryIngestOptions {
    llmConfig?: unknown;
    source?: string;
    sessionId?: string;
}
export interface MemoryExtractionItem {
    text: string;
    category?: string;
    importance?: number;
    confidence?: number;
    source?: string;
    event_date?: string;
    tags?: string[];
    /** Ids of already-uploaded attachments to link to this memory on commit. */
    attachmentIds?: string[];
}
export interface MemoryConsolidationWriteResult {
    memoriesAdded?: number;
    observationsAdded?: number;
    proposalsAdded?: number;
    claimsAdded?: number;
    conflictsAdded?: number;
    claimIds?: string[];
    conflictIds?: string[];
}
export interface MemoryProvider {
    readonly providerId: string;
    search(query: string, userId: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
    ingest?(messages: MemoryIngestMessage[], userId: string, options?: MemoryIngestOptions): Promise<void>;
    addText?(text: string, userId: string, options?: MemoryIngestOptions): Promise<{
        memoriesAdded: number;
    }>;
    remove?(memoryId: string): Promise<boolean>;
}
export interface MemoryLearningSink {
    ingestExtracted(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
}
export interface MemoryToolLocalProvider {
    addText(text: string, userId: string, metadata?: MemoryIngestOptions & {
        category?: string;
        importance?: number;
    }): Promise<unknown>;
    synthesizeTimeline(userId: string, startMs: number, endMs: number): string;
    feedback(ids: string[], signal: "useful" | "irrelevant" | "outdated" | "wrong"): Promise<{
        affected: number;
    }>;
}
export interface MemoryActivitySummary {
    dailyCounts: Array<{
        date: string;
        count: number;
    }>;
    highlights: Array<{
        text: string;
        category: string;
        importance: number;
        date: string;
    }>;
}
/** Lightweight attachment reference carried on atlas/detail records (no bytes). */
export interface MemoryAtlasAttachmentRef {
    id: string;
    kind: string;
    filename: string;
    mimeType: string;
    size: number;
    url: string;
}
export interface MemoryAtlasRecord {
    id: string;
    text: string;
    category?: string;
    importance?: number;
    confidence?: number;
    source?: string;
    sessionId?: string;
    eventDate?: string;
    tags?: string[];
    createdAt?: string | number;
    updatedAt?: string | number;
    accessCount?: number;
    lastAccessedAt?: string | number;
    isArchived?: boolean;
    attachments?: MemoryAtlasAttachmentRef[];
}
export interface MemoryAtlasResult {
    totalCount?: number;
    records?: MemoryAtlasRecord[];
    buckets?: unknown[];
    clusters?: unknown[];
    windowCursor?: unknown;
    timeRange?: unknown;
}
export interface MemoryUpdatePatch {
    text?: string;
    category?: string;
    importance?: number;
    source?: string;
    eventDate?: string;
    tags?: string[];
}
export interface MemoryHandlerProvider extends MemoryProvider {
    getAtlas?(userId: string, options?: Record<string, unknown>): MemoryAtlasResult;
    getActivitySummary?(userId: string, days: number): MemoryActivitySummary;
    observeExtracted?(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
    proposeExtracted?(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
    ingestExtracted?(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
    update?(id: string, patch: MemoryUpdatePatch): Promise<boolean>;
    /** Persist an uploaded attachment (orphan until linked at commit). */
    adoptAttachment?(input: {
        data?: Buffer;
        sourceUrl?: string;
        filename: string;
        mimeType: string;
        userId: string;
    }): Promise<MemoryAtlasAttachmentRef>;
    /** Resolve an attachment id to its on-disk path (for serving). */
    locateAttachment?(id: string): Promise<{
        absPath: string;
        mimeType: string;
        filename: string;
    } | null>;
    /** Drop uploads never saved to a memory. */
    purgeOrphanAttachments?(): Promise<void>;
    /** Read an attachment's bytes + mime (for multimodal understanding). */
    readAttachmentBytes?(id: string): Promise<{
        bytes: Buffer;
        mimeType: string;
    } | null>;
    /** Persist understood/extracted text on an attachment row. */
    setAttachmentText?(id: string, text: string): void;
}
export interface MemoryDreamProvider {
    search(query: string, userId: string, options?: {
        limit?: number;
    }): Promise<MemorySearchResult[]>;
    proposeExtracted?(items: MemoryExtractionItem[], userId: string, options?: {
        sessionId?: string;
        source?: string;
    }): Promise<{
        proposalsAdded?: number;
    }>;
    feedback?(memoryIds: string[], signal: "useful" | "irrelevant" | "outdated" | "wrong"): Promise<{
        affected: number;
    }>;
    getActivitySummary?(userId: string, days?: number): MemoryActivitySummary;
    synthesizeTimeline?(userId: string, startMs: number, endMs: number): string;
    getProfile?(userId: string, key: string): string | null;
    setProfile?(userId: string, key: string, value: string): void;
    getAllProfiles?(userId: string): Record<string, string>;
}
export interface MemoryDecayProvider {
    triggerDecay(userId: string, maxAgeDays?: number): Promise<{
        decayed: number;
    }>;
}
export type MemoryRuntimeHookProvider = MemoryProvider & MemoryWriter;
export type MemoryToolProvider = MemoryProvider & MemoryToolLocalProvider;
export type MemoryDreamRuntimeProvider = MemoryDreamProvider & MemoryDecayProvider;
