AI Search Expanded File Support Phase 6A: OCR Foundation Prompt
Status: Implemented for standalone PNG/JPEG OCR; PDF OCR deferred Priority: Low Dependencies: Phase 1 PDF, Phase 2 DOCX, Phase 3 XLSX, Phase 4 PPTX, Phase 5 Google Workspace Export
Implementation Summary
Phase 6A adds the OCR foundation for AI indexing under
src/lib/search/ai/extraction. OCR is disabled by default and can only run when
AI_SEARCH_OCR_ENABLED=true or when tests inject an OCR config/provider.
Implemented
- Provider-agnostic OCR port and typed
OcrExtractionError. - Namespaced OCR config:
AI_SEARCH_OCR_ENABLEDAI_SEARCH_OCR_PROVIDERAI_SEARCH_OCR_TIMEOUT_MSAI_SEARCH_OCR_MIN_CONFIDENCEAI_SEARCH_OCR_MAX_PAGESAI_SEARCH_OCR_MAX_IMAGES
- Local Tesseract.js OCR adapter using dynamic import.
- Standalone PNG/JPEG OCR extraction when OCR is enabled.
- OCR metadata preservation on successful extracted documents.
- Renderer-unavailable unsupported result for scanned PDF OCR fallback.
- Deterministic unit, extraction integration, and runner tests using mocked OCR providers.
Deferred
Scanned PDF OCR and Google Drawing PDF OCR fallback are deferred. The existing
pdfjs-dist dependency can extract embedded text, but page rendering in Node
uses @napi-rs/canvas, which adds native dependency and deployment validation
requirements for Windows, Vercel, and Fly.io.