Class: UrlLoader
Defined in: packages/agentos/src/memory/ingestion/UrlLoader.ts:63
An IDocumentLoader that fetches a remote URL and delegates parsing
to the appropriate registered loader based on the response Content-Type.
Supported content types
| Content-Type | Delegates to |
|---|---|
text/html | HtmlLoader (registry) |
application/pdf | PdfLoader (registry) |
| Everything else | Plain UTF-8 text |
Example
const registry = new LoaderRegistry();
const urlLoader = new UrlLoader(registry);
// Register so the registry also dispatches URLs via canLoad checks.
// (Optional — UrlLoader can be used standalone too.)
if (urlLoader.canLoad('https://example.com/report.pdf')) {
const doc = await urlLoader.load('https://example.com/report.pdf');
console.log(doc.format); // 'pdf'
}
Implements
Implements
Constructors
Constructor
new UrlLoader(
registry):UrlLoader
Defined in: packages/agentos/src/memory/ingestion/UrlLoader.ts:76
Parameters
registry
The LoaderRegistry used to resolve format-specific loaders once the remote content type is known.
Returns
UrlLoader
Properties
supportedExtensions
readonlysupportedExtensions:string[] =[]
Defined in: packages/agentos/src/memory/ingestion/UrlLoader.ts:70
URLs have no file extension so this array is always empty.
Routing to this loader must be performed via canLoad rather than the registry's extension-based lookup.
Implementation of
IDocumentLoader.supportedExtensions
Methods
canLoad()
canLoad(
source):boolean
Defined in: packages/agentos/src/memory/ingestion/UrlLoader.ts:90
Returns true when source is a string that starts with http:// or
https://.
Buffer sources are always rejected — raw bytes cannot be a URL.
Parameters
source
Absolute file path, URL string, or raw bytes.
string | Buffer
Returns
boolean
Implementation of
load()
load(
source,options?):Promise<LoadedDocument>
Defined in: packages/agentos/src/memory/ingestion/UrlLoader.ts:119
Fetch source over HTTP/HTTPS and return a LoadedDocument.
The response body is buffered in memory and then handed to the appropriate
sub-loader according to the Content-Type header:
text/html→ fetched as text, passed to the HTML loader as aBuffer.application/pdf→ fetched as bytes, passed to the PDF loader as aBuffer.- Anything else → returned as plain text with format
'text'andsourcemetadata set to the URL.
Parameters
source
HTTP/HTTPS URL string.
string | Buffer
options?
Optional load hints forwarded to the delegated loader.
Returns
Promise<LoadedDocument>
A promise resolving to the LoadedDocument.
Throws
When source is a Buffer (URLs must be strings).
Throws
When the HTTP request fails (network error or non-2xx status).