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.
Example
const loader = registry.getLoader('.md');
const loader2 = registry.getLoader('README.md');
getSupportedExtensions()
getSupportedExtensions():
string[]
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:215
Return a sorted array of all extensions currently registered.
Each extension is returned with a leading dot in lower-case, e.g.
['.csv', '.htm', '.html', '.json', '.md', …].
Returns
string[]
Sorted array of registered extension strings.
loadFile()
loadFile(
filePath,options?):Promise<LoadedDocument>
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:239
Convenience method: detect format from filePath, find the matching
loader, and delegate to its load() method.
Parameters
filePath
string
Absolute (or resolvable relative) file path.
options?
Optional load hints forwarded to the loader.
Returns
Promise<LoadedDocument>
A promise resolving to the LoadedDocument.
Throws
When no loader is registered for the file's extension.
Throws
When the underlying loader's load() throws.
Example
const doc = await registry.loadFile('/notes/architecture.md');
register()
register(
loader):void
Defined in: packages/agentos/src/cognition/memory/io/ingestion/LoaderRegistry.ts:172
Register a loader for all extensions it declares.
If a previously registered loader already handles one of the extension, it is replaced. This makes it trivial to swap in a higher-fidelity implementation for any format.
Parameters
loader
The loader instance to register.
Returns
void
Example
registry.register(new PdfLoader());