/** * Scanned-page vision extraction (#1507). TS-native, provider-neutral port of * section9 `scripts/corpus/codex_vision_extract_pages.sh`. * * Transcribes a directory of scanned page PNGs into per-page + combined Markdown * via a pluggable vision adapter (the source script hardcoded the `codex` CLI; * per the issue this is provider-neutral). Preserves the resumable / retry / * `# Page N` contract and the `` markers. * Optionally rasterizes a PDF → page PNGs first (poppler `pdftoppm`). * * Adapters: * - `codex` — `codex exec --sandbox read-only --image … --output-last-message` * - `command` — a generic shell-command template (AIWG_VISION_COMMAND) with * {image}/{prompt_file}/{out} placeholders → works with any vision * CLI (claude, a custom script, …). Truly provider-neutral. * - a caller-supplied adapter (used by tests with a fake transcriber). * * @source historical: corpus/codex_vision_extract_pages.sh * @tests @test/unit/artifacts/vision-extract.test.ts */ export interface TranscribeResult { ok: boolean; text?: string; } export interface VisionAdapter { name: string; /** Transcribe one image given the prompt; return `{ ok, text }`. */ transcribe(imagePath: string, prompt: string, ctx: { root: string; page: number; timeoutSec: number; model?: string; }): TranscribeResult; } /** Strict-transcription prompt. `title` parameterizes the corpus-specific intro. */ export declare function buildPrompt(page: number, title?: string): string; export interface AdapterOptions { provider?: string; command?: string; } /** Resolve the vision adapter from options/env. Throws when misconfigured. */ export declare function resolveAdapter(opts?: AdapterOptions): VisionAdapter; export declare function pdftoppmAvailable(): boolean; /** * Rasterize a PDF into zero-padded `page-NNN.png` files in `outDir` via * `pdftoppm`. Returns the page count. Throws if pdftoppm is unavailable. */ export declare function rasterizePdf(pdfPath: string, outDir: string, dpi?: number): number; export interface ExtractOptions { imageDir: string; outDir: string; adapter: VisionAdapter; title?: string; start?: number; end?: number; retries?: number; timeoutSec?: number; /** Cooldown seconds between pages / after a failure (default 0 — set for real-provider politeness). */ sleepSec?: number; force?: boolean; model?: string; /** Injected sleeper (tests pass a no-op). */ sleep?: (sec: number) => void; } export interface ExtractResult { processed: number; completed: number; failed: number; combinedMd: string; combinedTxt: string; } export declare function extractPages(opts: ExtractOptions): Promise; export declare function renderExtract(r: ExtractResult): string; //# sourceMappingURL=vision-extract.d.ts.map