Class: LoaderRegistry
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:104
Central registry mapping file extensions to IDocumentLoader implementations.
Built-in loaders (registered automatically)
| Extensions | Loader |
|---|---|
.txt, .csv, .tsv, .json, .yaml, .yml | TextLoader |
.md, .mdx | MarkdownLoader |
.html, .htm | HtmlLoader |
.pdf | PdfLoader |
.docx | DocxLoader |
Conditional loaders (registered when available)
| Condition | Loader |
|---|---|
tesseract.js installed | factory from createOcrPdfLoader (overrides PDF) |
python3 -m docling available | factory from createDoclingLoader (overrides PDF + DOCX) |
Registering a custom loader
const registry = new LoaderRegistry();
registry.register(new PdfLoader());
const doc = await registry.loadFile('/reports/q3.pdf');
Using loadFile
const registry = new LoaderRegistry();
const doc = await registry.loadFile('/notes/meeting.md');
console.log(doc.metadata.title);
Constructors
Constructor
new LoaderRegistry():
LoaderRegistry
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:130
Creates a new registry pre-populated with the built-in loaders.
Loader registration order determines conflict resolution: later registrations override earlier ones for the same extension.
Registration order:
- TextLoader, MarkdownLoader, HtmlLoader — core text formats.
- PdfLoader (with injected OCR + Docling loaders) — PDF extraction.
- DocxLoader — DOCX extraction.
- Optional: an override from createOcrPdfLoader when
tesseract.jsis installed. - Optional: an override from createDoclingLoader when Python Docling is available.
The Docling-backed loader supports both
.pdfand.docx, so it supersedes both PdfLoader and DocxLoader when present.
Returns
LoaderRegistry
Methods
getLoader()
getLoader(
extensionOrPath):IDocumentLoader|undefined
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:198
Retrieve the loader registered for extensionOrPath.
Both bare extensions (.md, md) and full file paths
(/docs/guide.md) are accepted.
Parameters
extensionOrPath
string
File extension or full path.
Returns
IDocumentLoader | undefined
The matching IDocumentLoader, or undefined when no
loader is registered for the detected extension.