/**
 * BackgroundReviewCoordinator — owns the per-session counters that decide when
 * to nudge the model into running a quiet "review memory / review skills" follow-up
 * after a normal user turn finishes.
 *
 * Previously the nudge state, the `agent.subscribe` plumbing for the skill counter,
 * and the call to `runBackgroundReviewTurn` lived as private methods + a per-instance
 * field on `AgentManager`. Extracted so:
 *   - `AgentInstance` no longer carries an inline counter object.
 *   - The agent-event subscription used to count `tool_execution_end` events is
 *     owned by the coordinator; teardown is automatic on `forgetSession`.
 *   - Future changes to the nudge cadence (per-agent intervals, per-tool counters,
 *     etc.) only touch this file.
 */
import type { Agent } from '@earendil-works/pi-agent-core';
import type { Config } from '../../config/schema.js';
import type { WorkspaceRuntime } from '../workspace-runtime/registry.js';
export interface BackgroundReviewCoordinatorOptions {
    /** Effective config snapshot used to look up review-cadence settings. */
    getConfig: () => Config | undefined;
    /** Trigger after the review turn writes skill files (lets agents reload prompts). */
    onSkillsFilesystemMutate: () => void;
}
export interface ScheduleReviewContext {
    sessionKey: string;
    agent: Agent;
    registeredToolNames: readonly string[];
    skillAllowlist?: readonly string[];
    workspacePath: string;
    /** Last assistant text — review is skipped when empty. */
    lastAssistantText: string | null;
    workspaceRuntime: WorkspaceRuntime;
}
export declare class BackgroundReviewCoordinator {
    private readonly opts;
    private readonly states;
    constructor(opts: BackgroundReviewCoordinatorOptions);
    /**
     * Called before the main `agent.prompt` for a user turn — bumps the memory
     * counter and arms `pendingMemoryReview` when the cadence interval is hit.
     */
    beginUserTurn(sessionKey: string, registeredToolNames: readonly string[]): void;
    /**
     * Subscribe to the agent's events to update the skill counter as the
     * conversation progresses. Idempotent per session — the previous subscription
     * is torn down before installing the new one.
     */
    attachToAgent(sessionKey: string, agent: Agent, registeredToolNames: readonly string[]): void;
    /**
     * Fire-and-forget review after the main user turn. Decides whether to run a
     * memory and/or skills sweep based on the counter state + last assistant text,
     * and delegates the actual review to {@link runBackgroundReviewTurn}.
     */
    scheduleAfterUserTurn(ctx: ScheduleReviewContext): void;
    /** Tear down state for a session (called by `AgentManager.removeAgent`). */
    forgetSession(sessionKey: string): void;
    /** Tear down every subscription (`AgentManager.dispose` / hot reload). */
    clear(): void;
    private ensureState;
    private runReviewIfNeeded;
}
