/**
 * Session Messages Service
 *
 * Persists session messages/events to SQLite for transcript restoration.
 * Messages are saved immediately when received to prevent data loss.
 */
import type { StorageBackend } from '@stoneforge/storage';
import type { EntityId, Timestamp } from '@stoneforge/core';
export interface SessionMessage {
    id: string;
    sessionId: string;
    agentId: EntityId;
    type: 'user' | 'assistant' | 'tool_use' | 'tool_result' | 'system' | 'error' | 'result';
    content?: string;
    toolName?: string;
    toolInput?: string;
    toolOutput?: string;
    isError: boolean;
    createdAt: Timestamp;
}
export interface SessionMessageService {
    /**
     * Save a message to the database
     */
    saveMessage(message: Omit<SessionMessage, 'createdAt'> & {
        createdAt?: Timestamp;
    }): void;
    /**
     * Get all messages for a session
     */
    getSessionMessages(sessionId: string): SessionMessage[];
    /**
     * Get messages for multiple sessions (for loading related/resumed sessions)
     */
    getMessagesForSessions(sessionIds: string[]): SessionMessage[];
    /**
     * Get messages for a session after a specific message ID (for incremental loading)
     */
    getSessionMessagesAfter(sessionId: string, afterId: string): SessionMessage[];
    /**
     * Delete all messages for a session
     */
    deleteSessionMessages(sessionId: string): void;
    /**
     * Get the count of messages for a session
     */
    getMessageCount(sessionId: string): number;
    /**
     * Get the latest displayable message for a session.
     * Returns the most recent message that has content or is a tool_use event
     * (which can be displayed as "Using <tool>...").
     */
    getLatestDisplayableMessage(sessionId: string): SessionMessage | undefined;
    /**
     * Get the latest displayable messages for multiple sessions (batch).
     * Returns a map of sessionId -> latest message.
     */
    getLatestDisplayableMessages(sessionIds: string[]): Map<string, SessionMessage>;
}
export declare function createSessionMessageService(storage: StorageBackend): SessionMessageService;
//# sourceMappingURL=session-messages.d.ts.map