/**
 * Self-Learning Engine — the autonomous learning loop.
 *
 * Inspired by the Claude Code paper:
 * - §7.2 Auto Memory: "contextually relevant memory entries"
 * - §10 OpenClaw Dreaming: "background consolidation, scoring candidates
 *   and promoting only qualified items from short-term recall into long-term memory"
 * - §2.1 Contextual Adaptability: "the relationship improves over time"
 *
 * This module provides:
 * 1. Tool usage tracking — records every tool call with outcome
 * 2. Pattern detection — finds repeated tool sequences and suggests skills
 * 3. Reflection — end-of-conversation self-assessment
 * 4. Dreaming/Consolidation — merges scattered memories into structured knowledge
 * 5. System prompt evolution — adapts the default prompt based on learned patterns
 *
 * State model: each chat / CLI run should construct its own LearningRecorder
 * bound to the project's PROJECT_DIR and a sessionId, so the tool log,
 * auto-continue counter, and active model are scoped per-session. The
 * legacy no-arg exports (`startNewSession()`, `trackToolUsage(...)` etc.)
 * are kept as backward-compat shims that delegate to a process-wide default
 * recorder bound to `process.cwd()` — they remain race-prone under
 * concurrency and should not be used from new code.
 */
interface ToolUsageEntry {
    timestamp: string;
    sessionId: string;
    tool: string;
    input: Record<string, unknown>;
    success: boolean;
    durationMs?: number;
}
interface Reflection {
    timestamp: string;
    sessionId: string;
    toolsUsed: string[];
    successRate: number;
    insights: string[];
    suggestedImprovements: string[];
}
interface DetectedPattern {
    id: string;
    toolSequence: string[];
    occurrences: number;
    firstSeen: string;
    lastSeen: string;
    suggestedSkillName: string;
    promoted: boolean;
}
/** Project-scoped, per-session learning state. Replaces the legacy module
 * globals (which races under concurrent chats and writes to whatever the
 * process cwd happens to be). */
export declare class LearningRecorder {
    readonly projectDir: string;
    readonly sessionId: string;
    readonly baseDir: string;
    readonly trackerFile: string;
    readonly patternsFile: string;
    readonly reflectionsFile: string;
    readonly evolvedPromptFile: string;
    readonly memoryDir: string;
    private toolLog;
    private autoContinueCount;
    private model;
    constructor(projectDir: string, sessionId?: string);
    getSessionTools(): ToolUsageEntry[];
    getAutoContinueCount(): number;
    getModel(): string;
    recordAutoContinue(model: string): void;
    trackToolUsage(tool: string, input: Record<string, unknown>, success: boolean, durationMs?: number): Promise<void>;
    detectPatterns(): Promise<DetectedPattern[]>;
    reflectOnSession(): Promise<Reflection>;
    consolidateMemory(): Promise<string>;
    getEvolvedPrompt(basePrompt: string): Promise<string>;
    evolvePrompt(addition: string): Promise<void>;
    getUnpromotedPatterns(): Promise<DetectedPattern[]>;
    markPatternPromoted(patternId: string): Promise<void>;
    onSessionEnd(): Promise<{
        reflection: Reflection;
        newPatterns: DetectedPattern[];
        digest?: string;
    }>;
}
/** Returns the current default recorder (bound to `process.cwd()` at first
 * use, then rebound by `startNewSession()`). New code should construct its
 * own LearningRecorder rather than relying on this. */
export declare function getDefaultLearningRecorder(): LearningRecorder;
export declare function startNewSession(): string;
export declare function recordSessionAutoContinue(model: string): void;
export declare function trackToolUsage(tool: string, input: Record<string, unknown>, success: boolean, durationMs?: number): Promise<void>;
export declare function detectPatterns(): Promise<DetectedPattern[]>;
export declare function reflectOnSession(): Promise<Reflection>;
export declare function consolidateMemory(): Promise<string>;
export declare function getEvolvedPrompt(basePrompt: string): Promise<string>;
export declare function evolvePrompt(addition: string): Promise<void>;
export declare function getUnpromotedPatterns(): Promise<DetectedPattern[]>;
export declare function markPatternPromoted(patternId: string): Promise<void>;
export declare function onSessionEnd(): Promise<{
    reflection: Reflection;
    newPatterns: DetectedPattern[];
}>;
export {};
//# sourceMappingURL=engine.d.ts.map