Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:161
File system context provider for RLM Provides unified access to context data with memory safety guarantees
Supports two modes:
- Filesystem mode: On-demand loading from disk with LRU cache
- Memory mode: Direct string content (virtual single-file context)
Both modes enable handling massive contexts (100MB+) without OOM issues.
Constructors
Constructor
new FileSystemContext(
basePathOrContent,
filePaths?,
options?
): FileSystemContext;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:191
Create FileSystemContext from filesystem or memory
Parameters
| Parameter | Type | Description |
|---|---|---|
basePathOrContent |
string |
Filesystem: absolute path; Memory: string content |
filePaths? |
string[] |
Filesystem: relative file paths; Memory: omit/undefined |
options? |
FileSystemContextOptions |
Memory safety configuration |
Returns
FileSystemContext
Examples
Filesystem mode:
const ctx = new FileSystemContext('/project', ['src/index.ts']);
Memory mode:
const ctx = new FileSystemContext('long text content...');
Methods
getFileInfo()
getFileInfo(filePath): FileInfo;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:311
Get file metadata without reading content
Parameters
| Parameter | Type |
|---|---|
filePath |
string |
Returns
getFilesInDirectory()
getFilesInDirectory(dir): string[];
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:375
Get files by directory
Parameters
| Parameter | Type |
|---|---|
dir |
string |
Returns
string[]
getMemoryLimits()
getMemoryLimits(): MemoryLimits;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:404
Get memory limits configuration
Returns
getMemoryUsage()
getMemoryUsage(): MemoryUsage;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:390
Get current memory usage information
Returns
getStats()
getStats(): ContextStats;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:338
Get overall context statistics
Returns
listFiles()
listFiles(): string[];
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:250
List all available file paths
Returns
string[]
readFile()
readFile(filePath): string;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:259
Read a specific file with memory safety checks Filesystem: loaded from disk on-demand with LRU cache Memory: returns the stored string content
Parameters
| Parameter | Type |
|---|---|
filePath |
string |
Returns
string
resetMemoryTracking()
resetMemoryTracking(): void;
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:383
Reset memory tracking by clearing cache Call this between queries to allow reusing the same context
Returns
void
sampleFiles()
sampleFiles(pattern, limit): string[];
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:367
Get a subset of files by pattern (useful for sampling)
Parameters
| Parameter | Type |
|---|---|
pattern |
string | RegExp |
limit |
number |
Returns
string[]
searchFiles()
searchFiles(pattern): string[];
Defined in: packages/components/src/agents/rlm/FileSystemContext.ts:330
Search files by pattern (returns paths only)
Parameters
| Parameter | Type |
|---|---|
pattern |
string | RegExp |
Returns
string[]