import { type FileUpload, type UploadScannerOptions } from '../security/upload-scanner.js'; import { type IngestionOptions, type IngestionResult } from './ingestion.js'; /** Turns one kind of file into text, such as PDF or an image through OCR. */ export interface FileTextExtractor { /** Whether it handles this file. */ supports(file: FileUpload): boolean; /** Extracts the file's text. */ extract(file: FileUpload): Promise | string; } /** Options for `ingestFilesAfterScan()`. */ export interface FileIngestionOptions extends IngestionOptions { /** Upload scan settings. Every file is scanned before any is read. */ scan?: UploadScannerOptions; /** Extractors tried in order. Text files need none. */ extractors?: FileTextExtractor[]; } /** The chunks produced from a set of files, and the files that could not be read. */ export interface FileIngestionResult extends IngestionResult { /** Files scanned. */ scannedFiles: number; /** Files skipped because no extractor handles them. */ skippedFiles: Array<{ name: string; reason: string; }>; } /** * Scans uploads, extracts their text, and splits it into chunks. Throws when the scan finds * anything `high` or `critical`. */ export declare function ingestFilesAfterScan(files: FileUpload[], options?: FileIngestionOptions): Promise; /** An extractor for PDF files, around your own PDF-to-text function. */ export declare function createPdfExtractor(extractPdfText: (file: FileUpload) => Promise | string): FileTextExtractor; /** An extractor for images, around your own OCR function. Defaults to PNG, JPEG, and WebP. */ export declare function createOcrExtractor(ocrImage: (file: FileUpload) => Promise | string, mimeTypes?: string[]): FileTextExtractor;