import type { Message, Model } from "@pie-lab/ai";
import type { SkillManager } from "./skill-manager.ts";
export interface SkillCuratorPolicy {
    staleAfterDays: number;
    archiveAfterDays: number;
    autoArchive: boolean;
    backupBeforeRun: boolean;
    pruneAfterDays: number;
    consolidateIntervalDays: number;
}
export interface CuratedSkillStatus {
    name: string;
    location: string;
    state: "active" | "stale" | "archived" | "pinned";
    pinned: boolean;
    createdAt?: string;
    updatedAt?: string;
    lastUsedAt?: string;
    useCount: number;
    viewCount: number;
    patchCount: number;
    idleDays?: number;
    archivedAt?: string;
}
export interface CuratorRunResult {
    checked: number;
    stale: CuratedSkillStatus[];
    archived: Array<{
        name: string;
        archivedTo: string;
    }>;
    skipped: Array<{
        name: string;
        reason: string;
    }>;
    dryRun: boolean;
    backupPath?: string;
    wouldArchive: CuratedSkillStatus[];
}
export interface CuratorPruneResult {
    checked: number;
    removed: Array<{
        name: string;
        path: string;
    }>;
    skipped: Array<{
        name: string;
        reason: string;
    }>;
    dryRun: boolean;
    wouldRemove: CuratedSkillStatus[];
}
export interface CuratorRollbackResult {
    backupPath: string;
    restoredActive: number;
    restoredArchived: number;
}
export interface CuratorConsolidateOptions {
    dryRun?: boolean;
    onLog?: (msg: string) => void;
}
export interface ConsolidationEntry {
    from: string;
    into: string;
    reason: string;
}
export interface PruningEntry {
    name: string;
    reason: string;
}
export interface CuratorConsolidateResult {
    dryRun: boolean;
    backupPath?: string;
    rawOutput: string;
    consolidations: ConsolidationEntry[];
    prunings: PruningEntry[];
    iterations: number;
}
interface CuratorState {
    lastConsolidatedAt: string | null;
    consolidationCount: number;
    lastConsolidationSummary: string | null;
}
export declare const DEFAULT_CURATOR_POLICY: SkillCuratorPolicy;
type StreamFn = (model: Model<any>, context: {
    systemPrompt?: string;
    messages: Message[];
}, options?: any) => any;
export declare class SkillCurator {
    private readonly manager;
    private readonly policy;
    constructor(options: {
        skillManager: SkillManager;
        policy?: Partial<SkillCuratorPolicy>;
    });
    status(): CuratedSkillStatus[];
    run(options?: {
        dryRun?: boolean;
    }): CuratorRunResult;
    prune(options?: {
        dryRun?: boolean;
        pruneAfterDays?: number;
    }): CuratorPruneResult;
    pin(name: string): CuratedSkillStatus;
    unpin(name: string): CuratedSkillStatus;
    archive(name: string): string;
    restore(name: string): string;
    backup(): string;
    rollback(backupPath?: string): CuratorRollbackResult;
    /**
     * Run the LLM umbrella-building consolidation pass.
     *
     * The curator LLM reviews all active agent-created skills and identifies
     * clusters of narrow skills that should be merged into class-level umbrella
     * skills. This is the primary mechanism for keeping the skill library
     * manageable as it grows over time.
     *
     * @param streamFn - The same streamFn used by BackgroundLearningReview.
     *   In session context, this is `agent.streamFn`. In CLI context, create
     *   one via createAgentSession().session.agent.streamFn.
     * @param options - Dry run flag and optional log callback.
     */
    consolidate(streamFn: StreamFn, options?: CuratorConsolidateOptions): Promise<CuratorConsolidateResult>;
    /**
     * Whether an automatic consolidation pass should run now. True when the
     * configured interval has elapsed since the last pass, or — if a pass has
     * never run — when there are enough active skills to be worth one.
     */
    isConsolidationDue(): boolean;
    /**
     * Run consolidation if the interval since last run has passed.
     * Returns null if consolidation was not needed.
     */
    maybeConsolidate(streamFn: StreamFn, options?: CuratorConsolidateOptions): Promise<CuratorConsolidateResult | null>;
    /**
     * Return the curator state (last consolidation time, count, etc.)
     */
    getConsolidationState(): CuratorState;
    private requireStatus;
    private archivedStatuses;
    private latestBackupPath;
    private removeCurrentAgentCreatedSkills;
    private restoreBackupGroup;
    private toStatus;
    private buildConsolidationSkillContext;
    private stateFilePath;
    private loadState;
    private saveState;
}
export {};
//# sourceMappingURL=skill-curator.d.ts.map