import type { AgentMessage } from "@pk-nerdsaver-ai/pi-agent-core";
import type * as MnemopiNs from "@pk-nerdsaver-ai/pi-mnemopi";
import type { Mnemopi, RecallResult } from "@pk-nerdsaver-ai/pi-mnemopi";
import type * as MnemopiCoreNs from "@pk-nerdsaver-ai/pi-mnemopi/core";
import type { AgentSession } from "../session/agent-session";
import type { MnemopiBackendConfig } from "./config";
/** Lazily load `@pk-nerdsaver-ai/pi-mnemopi` (memoized). */
export declare function loadMnemopi(): Promise<typeof MnemopiNs>;
/** Lazily load `@pk-nerdsaver-ai/pi-mnemopi/core` (memoized). */
export declare function loadMnemopiCore(): Promise<typeof MnemopiCoreNs>;
/** Sync access for code below an async boundary that already awaited {@link loadMnemopi}. */
export declare function requireMnemopi(): typeof MnemopiNs;
/** Sync access for code below an async boundary that already awaited {@link loadMnemopiCore}. */
export declare function requireMnemopiCore(): typeof MnemopiCoreNs;
interface MnemopiScopedMemory {
    bank: string;
    memory: Mnemopi;
}
type MnemopiRememberInput = Parameters<Mnemopi["remember"]>[0];
type MnemopiRememberOptions = Parameters<Mnemopi["remember"]>[1];
export type MnemopiMemoryEditOperation = "update" | "forget" | "invalidate";
export interface MnemopiMemoryEditOptions {
    content?: string;
    importance?: number;
    replacementId?: string;
}
export interface MnemopiMemoryEditResult {
    status: "updated" | "deleted" | "invalidated" | "not_found";
    bank?: string;
    store?: "working" | "episodic";
}
export declare function getMnemopiSessionState(session: AgentSession | undefined): MnemopiSessionState | undefined;
export declare function setMnemopiSessionState(session: AgentSession, state: MnemopiSessionState | undefined): MnemopiSessionState | undefined;
export interface MnemopiSessionStateOptions {
    sessionId: string;
    config: MnemopiBackendConfig;
    session: AgentSession;
    aliasOf?: MnemopiSessionState;
    lastRetainedTurn?: number;
    hasRecalledForFirstTurn?: boolean;
}
export declare class MnemopiSessionState {
    sessionId: string;
    readonly config: MnemopiBackendConfig;
    readonly session: AgentSession;
    readonly memory: Mnemopi;
    readonly globalMemory?: Mnemopi;
    readonly aliasOf?: MnemopiSessionState;
    private readonly scoped;
    lastRetainedTurn: number;
    hasRecalledForFirstTurn: boolean;
    lastRecallSnippet?: string;
    unsubscribe?: () => void;
    constructor(options: MnemopiSessionStateOptions);
    setSessionId(sessionId: string): void;
    resetConversationTracking(): void;
    getScopedRecallTargets(): readonly MnemopiScopedMemory[];
    getScopedRetainTarget(): MnemopiScopedMemory;
    editScopedMemory(op: MnemopiMemoryEditOperation, id: string, options?: MnemopiMemoryEditOptions): MnemopiMemoryEditResult;
    formatScopedRecallWithIds(results: readonly RecallResult[]): string;
    collectScopedRecallResults(query: string): Promise<RecallResult[]>;
    recallResultsScoped(query: string): Promise<RecallResult[]>;
    formatScopedRecallContext(results: readonly RecallResult[], format?: "bullet" | "json"): string | undefined;
    formatContextScoped(results: readonly RecallResult[], format?: "bullet" | "json"): string;
    rememberInScope(memory: MnemopiRememberInput, options?: MnemopiRememberOptions): string | undefined;
    rememberScoped(memory: MnemopiRememberInput, options?: MnemopiRememberOptions): string | undefined;
    recallForContext(query: string): Promise<string | undefined>;
    beforeAgentStartPrompt(promptText: string): Promise<string | undefined>;
    recallForCompaction(messages: AgentMessage[]): Promise<string | undefined>;
    maybeRetainOnAgentEnd(_messages: AgentMessage[]): Promise<void>;
    forceRetainCurrentSession(): Promise<void>;
    retainMessages(messages: Array<{
        role: string;
        content: string;
    }>, sourceId: string): Promise<void>;
    attachSessionListeners(): void;
    maybeRecallOnAgentStart(): Promise<void>;
    /**
     * Drain in-flight fact extraction and run beam consolidation on every owned
     * bank, after capturing the current transcript. Mirrors the manual
     * `/memory enqueue` slash command, but stops short of closing the DBs so
     * callers can keep using the state. {@link dispose} composes this with the
     * close step so normal session shutdown promotes working memory to
     * episodic/gists/graph automatically (see issue #2320).
     *
     * Aliased subagent states share `scoped` (and therefore the actual SQLite
     * banks) with their parent. `consolidate()` deliberately does NOT
     * short-circuit on `aliasOf`: `forceRetainCurrentSession` already guards
     * itself, and an explicit `/memory enqueue` invoked from within a subagent
     * still needs to flush extractions and sleep the parent's shared banks —
     * otherwise enqueue would report success while leaving the subagent's
     * retained memories unconsolidated until the parent eventually shuts down
     * (PR #2327 review).
     */
    consolidate(): Promise<void>;
    /**
     * Release the per-session resources. Defaults to running {@link consolidate}
     * before closing handles so normal session shutdown promotes working memory
     * into long-term storage. Callers that are about to delete the DB files —
     * e.g. `mnemopiBackend.clear` — pass `{ consolidate: false }` to skip the
     * extraction/sleep pass, since spending tokens on memories that will be
     * wiped on the next line is wasted work (PR #2327 review).
     */
    dispose(options?: {
        consolidate?: boolean;
    }): Promise<void>;
}
export declare function getMnemopiScopedDbPaths(config: MnemopiBackendConfig): readonly string[];
export declare function getMnemopiScopedBanks(config: MnemopiBackendConfig): readonly string[];
export {};
