import type { MessageList } from '@mastra/core/agent';
import type { ObservabilityContext } from '@mastra/core/observability';
import type { ProcessorStreamWriter } from '@mastra/core/processors';
import type { RequestContext } from '@mastra/core/request-context';
import type { MemoryStorage, ObservationalMemoryRecord } from '@mastra/core/storage';
import { BufferingCoordinator } from './buffering-coordinator.js';
import type { ModelByInputTokens } from './model-by-input-tokens.js';
import type { CompressionLevel } from './reflector-agent.js';
import type { TokenCounter } from './token-counter.js';
import type { ObservationDebugEvent, ObservationModelContext, ObserveHooks, ResolvedObservationConfig, ResolvedReflectionConfig } from './types.js';
type ConcreteReflectionModel = Exclude<ResolvedReflectionConfig['model'], ModelByInputTokens>;
type ReflectionModelResolver = (inputTokens: number) => {
    model: ConcreteReflectionModel;
    selectedThreshold?: number;
    routingStrategy?: 'model-by-input-tokens';
    routingThresholds?: string;
};
/**
 * Runs the Reflector agent for compressing observations.
 * Handles synchronous reflection, async buffered reflection, and activation.
 */
export declare class ReflectorRunner {
    private readonly reflectionConfig;
    private readonly observationConfig;
    private readonly tokenCounter;
    private readonly resolveModel;
    private readonly storage;
    private readonly scope;
    private readonly buffering;
    private readonly emitDebugEvent;
    private readonly persistMarkerToStorage;
    private readonly persistMarkerToMessage;
    private readonly getCompressionStartLevel;
    constructor(opts: {
        reflectionConfig: ResolvedReflectionConfig;
        observationConfig: ResolvedObservationConfig;
        tokenCounter: TokenCounter;
        storage: MemoryStorage;
        scope: 'thread' | 'resource';
        buffering: BufferingCoordinator;
        emitDebugEvent: (event: ObservationDebugEvent) => void;
        persistMarkerToStorage: (marker: {
            type: string;
            data: unknown;
        }, threadId: string, resourceId?: string) => Promise<void>;
        persistMarkerToMessage: (marker: {
            type: string;
            data: unknown;
        }, messageList: MessageList | undefined, threadId: string, resourceId?: string) => Promise<void>;
        getCompressionStartLevel: (requestContext?: RequestContext) => Promise<CompressionLevel>;
        resolveModel: ReflectionModelResolver;
    });
    private createAgent;
    private getObservationMarkerConfig;
    /**
     * Resolve the effective reflection observationTokens for a record.
     * Only explicit per-record overrides (stored under `_overrides`) win;
     * the initial config snapshot is ignored so instance-level changes
     * still take effect for existing records.
     */
    private getEffectiveReflectionTokens;
    /**
     * Call the Reflector agent with escalating compression levels.
     */
    call(observations: string, manualPrompt?: string, streamContext?: {
        writer?: ProcessorStreamWriter;
        cycleId: string;
        startedAt: string;
        recordId: string;
        threadId: string;
        resourceId?: string;
    }, observationTokensThreshold?: number, abortSignal?: AbortSignal, skipContinuationHints?: boolean, compressionStartLevel?: CompressionLevel, requestContext?: RequestContext, observabilityContext?: ObservabilityContext, model?: ConcreteReflectionModel): Promise<{
        observations: string;
        suggestedContinuation?: string;
        usage?: {
            inputTokens?: number;
            outputTokens?: number;
            totalTokens?: number;
        };
    }>;
    /**
     * Start an async buffered reflection in the background.
     */
    private startAsyncBufferedReflection;
    /**
     * Perform async buffered reflection — reflects observations and stores to bufferedReflection.
     * Does NOT create a new generation or update activeObservations.
     */
    private doAsyncBufferedReflection;
    /**
     * Try to activate buffered reflection when threshold is reached.
     * Returns a discriminated result so the caller can distinguish between
     * "activated", "no buffer present", and "suppressed by overshoot guard"
     * without re-deriving that state.
     */
    private tryActivateBufferedReflection;
    /**
     * Check if reflection needed and trigger if so.
     * Supports both synchronous reflection and async buffered reflection.
     * @internal Used by observation strategies. Do not call directly.
     */
    maybeReflect(opts: {
        record: ObservationalMemoryRecord;
        observationTokens: number;
        threadId?: string;
        writer?: ProcessorStreamWriter;
        abortSignal?: AbortSignal;
        messageList?: MessageList;
        currentModel?: ObservationModelContext;
        reflectionHooks?: Pick<ObserveHooks, 'onReflectionStart' | 'onReflectionEnd'>;
        requestContext?: RequestContext;
        observabilityContext?: ObservabilityContext;
        lastActivityAt?: number;
    }): Promise<void>;
}
export {};
//# sourceMappingURL=reflector-runner.d.ts.map