/**
 * Server-side autofill route handler factory.
 *
 * Routes LLM extraction through hazo_files so results are persisted
 * in the hazo_files table (file_data column).
 *
 *   import { create_autofill_route } from 'hazo_collab_forms/lib';
 *   export const POST = create_autofill_route({ extraction_service, ... });
 *
 * Uses standard Web API Request/Response for portability (works in Next.js,
 * Deno, Cloudflare Workers, etc.).
 */
import 'server-only';
export interface AutofillRouteOptions {
    /** Called on errors — defaults to console.error */
    on_error?: (error: unknown, context: string) => void;
    /**
     * Resolve file content server-side by file_id.
     * Returns base64-encoded file content. Used when download_url is not
     * server-accessible (e.g. blob: URLs). Typically backed by hazo_files.
     */
    file_resolver?: (file_id: string) => Promise<string>;
    /**
     * hazo_files LLM extraction service. LLM calls route through hazo_files,
     * enabling extraction results to be persisted in the hazo_files table.
     */
    extraction_service: {
        extract(buffer: Buffer, mimeType: string, options?: {
            promptArea?: string;
            promptKey?: string;
            promptVariables?: Record<string, string>;
            customPrompt?: string;
        }): Promise<{
            success: boolean;
            data?: Record<string, unknown>;
            error?: string;
        }>;
    };
    /**
     * Optional: resolve the full prompt text for debugging.
     * Called with prompt_area, prompt_key, and variables — returns the resolved prompt string.
     */
    prompt_resolver?: (area: string, key: string, variables?: Record<string, string>) => Promise<string | null>;
    /**
     * hazo_files metadata service. Persists extraction results to file records.
     */
    metadata_service?: {
        findById(id: string): Promise<{
            file_path: string;
            storage_type: string;
        } | null>;
        addExtraction(path: string, storageType: string, data: Record<string, unknown>, options?: {
            id?: string;
            source?: string;
            mergeStrategy?: 'shallow' | 'deep';
        }): Promise<unknown>;
    };
}
/**
 * Creates a POST route handler for autofill document extraction.
 *
 * The handler:
 * 1. Validates request (prompt_area, prompt_key required)
 * 2. Resolves file content (inline base64, file_resolver, or download_url)
 * 3. Calls extraction_service.extract() for prompt-based LLM extraction
 * 4. Falls back to a generated default prompt if first attempt fails
 * 5. Persists extraction results to hazo_files via metadata_service
 * 6. Returns extracted data as JSON
 */
export declare function create_autofill_route(options: AutofillRouteOptions): (request: Request) => Promise<Response>;
//# sourceMappingURL=autofill_handler.d.ts.map