/**
 * OCR Processing Orchestrator
 *
 * Complete pipeline: Document -> OCR -> Provenance -> Store -> Status Update
 * FAIL-FAST: No fallbacks, errors propagate immediately
 */
import { type MarkerClientConfig } from './marker.js';
import { DatabaseService } from '../storage/database/index.js';
import type { PageOffset } from '../../models/document.js';
interface ProcessorConfig extends MarkerClientConfig {
    maxConcurrent?: number;
    defaultMode?: 'fast' | 'balanced' | 'accurate';
}
export interface ProcessResult {
    success: boolean;
    documentId: string;
    ocrResultId?: string;
    provenanceId?: string;
    pageCount?: number;
    textLength?: number;
    durationMs?: number;
    error?: string;
    /** Images extracted by Marker: {filename: base64_data} */
    images?: Record<string, string>;
    /** JSON block hierarchy from Marker (when output_format includes 'json') */
    jsonBlocks?: Record<string, unknown> | null;
    /** Marker metadata (page_stats, block_counts, etc.) */
    metadata?: Record<string, unknown> | null;
    /** Page character offsets from Marker for page-aware chunking */
    pageOffsets?: PageOffset[];
    /** Structured extraction result from page_schema */
    extractionJson?: Record<string, unknown> | unknown[] | null;
    /** Document title from metadata */
    docTitle?: string | null;
    /** Document author from metadata */
    docAuthor?: string | null;
    /** Document subject from metadata */
    docSubject?: string | null;
}
export interface BatchResult {
    processed: number;
    failed: number;
    remaining: number;
    totalDurationMs: number;
    results: ProcessResult[];
}
export declare class OCRProcessor {
    private readonly client;
    private readonly db;
    private readonly maxConcurrent;
    private readonly defaultMode;
    constructor(db: DatabaseService, config?: ProcessorConfig);
    /**
     * Process single document through OCR
     *
     * Pipeline:
     * 1. Get document from database (FAIL if not found)
     * 2. Update status to 'processing'
     * 3. Call Marker OCR via Python worker
     * 4. Create OCR_RESULT provenance record
     * 5. Store OCR result in database
     * 6. Update document status to 'complete'
     *
     * On transient failure: Keep status='pending' for retry (timeout, GPU OOM, insufficient balance)
     * On permanent failure: Update status to 'failed' (file errors, unclassified errors)
     */
    processDocument(documentId: string, mode?: 'fast' | 'balanced' | 'accurate', ocrOptions?: {
        maxPages?: number;
        pageRange?: string;
        skipCache?: boolean;
        disableImageExtraction?: boolean;
        extras?: string[];
        pageSchema?: string;
        additionalConfig?: Record<string, unknown>;
    }): Promise<ProcessResult>;
    /**
     * Process all pending documents.
     *
     * H-2 fix: Before processing, recover any documents stuck in 'processing'
     * status for longer than 30 minutes (indicates a prior server crash).
     * These are reset to 'pending' so they get re-processed.
     */
    processPending(mode?: 'fast' | 'balanced' | 'accurate'): Promise<BatchResult>;
    /**
     * H-2: Recover documents stuck in 'processing' status after a server crash.
     * Any document that has been 'processing' for longer than 30 minutes is
     * assumed to be orphaned from a crash and is reset to 'pending'.
     */
    private recoverStaleProcessingDocuments;
    /**
     * Create OCR_RESULT provenance record
     */
    private createOCRProvenance;
}
export {};
//# sourceMappingURL=processor.d.ts.map