import type { AgentRecord } from '../tools/agent/index.js';
import type { SessionReturnContextSummary } from '../runtime/session-return-context.js';
import type { ConversationTitleSource } from '../core/conversation.js';
/**
 * Metadata for a saved session (the first JSONL line).
 */
export interface SessionMeta {
    title: string;
    model: string;
    provider: string;
    timestamp: number;
    titleSource?: ConversationTitleSource | undefined;
    returnContext?: SessionReturnContextSummary | undefined;
}
/**
 * Summary info for listing saved sessions.
 */
export interface SessionInfo {
    name: string;
    title: string;
    model: string;
    provider: string;
    timestamp: number;
    messageCount: number;
    filePath: string;
    titleSource?: ConversationTitleSource | undefined;
    returnContext?: SessionReturnContextSummary | undefined;
}
/**
 * SessionManager - Handles saving and loading named conversation sessions
 * as JSONL files under the configured surface session directory.
 *
 * Format: each line is a JSON object.
 *   Line 0: { type: 'meta', ...SessionMeta }
 *   Line N: { type: 'message', ...message fields }
 */
export declare class SessionManager {
    private sessionsDir;
    constructor(baseDir: string, options?: {
        readonly surfaceRoot?: string | undefined;
        readonly sessionsDir?: string | undefined;
    });
    /**
     * Remove any `.tmp-*` files left behind by a crashed write.
     * Cleanup errors are logged and startup continues.
     */
    private _cleanupOrphanTempFiles;
    /**
     * Atomically write content to filePath via a temp file + fsync + rename.
     * Protects against partial writes on crash.
     */
    private _atomicWrite;
    /**
     * Save conversation messages to a JSONL session file.
     * Overwrites if file already exists.
     * Returns the sanitized filename used (may differ from input name).
     */
    save(name: string, messages: object[], meta: SessionMeta, agentRecords?: AgentRecord[]): {
        filePath: string;
        sanitizedName: string;
    };
    /**
     * Load a session from JSONL. Returns meta and messages (excluding removed ones).
     * Throws if the file does not exist or cannot be parsed.
     */
    load(name: string): {
        meta: SessionMeta;
        messages: object[];
        agentRecords: AgentRecord[];
    };
    /**
     * List all saved sessions with metadata, sorted by most recent first.
     */
    list(): SessionInfo[];
    /**
     * Get just the metadata for a session without loading all messages.
     * Returns null if the session does not exist or meta cannot be parsed.
     */
    getMeta(name: string): SessionMeta | null;
    /**
     * Rename a session by rewriting its meta line with a new title.
     * The file is stored under the sanitized name — rename updates the title
     * field inside the file but does NOT rename the file itself.
     * Throws if the session does not exist.
     */
    rename(name: string, newTitle: string): void;
    /**
     * Delete a session file.
     * Throws if the session does not exist.
     */
    delete(name: string): void;
    /**
     * Search all sessions for messages containing the query string (case-insensitive).
     * Returns sessions with match count and up to 3 context snippets per session.
     */
    search(query: string): Array<{
        session: SessionInfo;
        matchCount: number;
        snippets: string[];
    }>;
    /**
     * Sanitize a session name into a safe filename.
     * Replaces spaces with hyphens, strips non-alphanumeric/hyphen/underscore chars,
     * collapses multiple hyphens, trims leading/trailing hyphens.
     */
    sanitizeName(name: string): string;
}
//# sourceMappingURL=manager.d.ts.map