import type { Processor } from '..';
import type { MastraDBMessage, MessageList } from '../../agent/index.js';
import type { ObservabilityContext } from '../../observability/index.js';
import type { RequestContext } from '../../request-context/index.js';
import type { MemoryStorage } from '../../storage/index.js';
/**
 * Options for the MessageHistory processor
 */
export interface MessageHistoryOptions {
    storage: MemoryStorage;
    lastMessages?: number;
}
/**
 * Hybrid processor that handles both retrieval and persistence of message history.
 * - On input: Fetches historical messages from storage and prepends them
 * - On output: Persists new messages to storage (excluding system messages)
 *
 * This processor retrieves threadId and resourceId from RequestContext at execution time,
 * making it decoupled from memory-specific context.
 */
export declare class MessageHistory implements Processor {
    readonly id = "message-history";
    readonly name = "MessageHistory";
    private storage;
    private lastMessages?;
    constructor(options: MessageHistoryOptions);
    /**
     * Get threadId and resourceId from either RequestContext or MessageList's memoryInfo
     */
    private getMemoryContext;
    private createMemorySpan;
    processInput(args: {
        messages: MastraDBMessage[];
        messageList: MessageList;
        abort: (reason?: string) => never;
        requestContext?: RequestContext;
    } & Partial<ObservabilityContext>): Promise<MessageList | MastraDBMessage[]>;
    /**
     * Filters messages before persisting to storage:
     * 1. Removes system messages - these are runtime instructions and should never be stored
     * 2. Removes streaming tool calls (state === 'partial-call') - these are intermediate states
     * 3. Removes updateWorkingMemory tool invocations (hide args from message history)
     * 4. Strips <working_memory> tags from text content
     *
     * Note: We preserve 'call' state tool invocations because:
     * - For server-side tools, 'call' should have been converted to 'result' by the time OUTPUT is processed
     * - For client-side tools (no execute function), 'call' is the final state from the server's perspective
     */
    private filterMessagesForPersistence;
    processOutputResult(args: {
        messages: MastraDBMessage[];
        messageList: MessageList;
        abort: (reason?: string) => never;
        requestContext?: RequestContext;
    } & Partial<ObservabilityContext>): Promise<MessageList>;
    /**
     * Persist messages to storage, filtering out partial tool calls and working memory tags.
     * Also ensures the thread exists (creates if needed).
     *
     * This method can be called externally by other processors (e.g., ObservationalMemory)
     * that need to save messages incrementally.
     */
    persistMessages(args: {
        messages: MastraDBMessage[];
        threadId: string;
        resourceId?: string;
    }): Promise<void>;
}
//# sourceMappingURL=message-history.d.ts.map