@dollhousemcp/mcp-server
Version:
DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.
74 lines • 2.79 kB
TypeScript
/**
* ElementStorageLayer - Coordinates index, manifest, and backend for cache-aware listing.
*
* Owns the scan lifecycle: cooldown enforcement, concurrent call deduplication,
* diff-based incremental index updates, and notifications from save/delete.
*/
import type { IStorageBackend } from './IStorageBackend.js';
import type { IStorageLayer } from './IStorageLayer.js';
import type { ElementIndexEntry, ManifestDiffResult } from './types.js';
import type { FileOperationsService } from '../services/FileOperationsService.js';
export interface ElementStorageLayerOptions {
/** Absolute path to the element directory */
elementDir: string;
/** File extension to filter (e.g. '.md') */
fileExtension: string;
/** Minimum milliseconds between full scans (default: 1000) */
scanCooldownMs?: number;
/** Override the storage backend (useful for testing) */
storageBackend?: IStorageBackend;
}
export declare class ElementStorageLayer implements IStorageLayer {
private readonly backend;
private readonly manifest;
private readonly index;
private readonly elementDir;
private readonly fileExtension;
private readonly scanCooldownMs;
private lastScanTimestamp;
private scanInProgress;
constructor(fileOperationsService: FileOperationsService, options: ElementStorageLayerOptions);
/**
* Scan the element directory for changes.
* - No-op if within cooldown period (returns empty diff)
* - Deduplicates concurrent calls (returns same promise)
* - Updates index and manifest based on diff
*/
scan(): Promise<ManifestDiffResult>;
/**
* Trigger scan and return all index entries.
*/
listSummaries(): Promise<ElementIndexEntry[]>;
/**
* Trigger scan and return all indexed file paths.
*/
getIndexedPaths(): Promise<string[]>;
/**
* O(1) name-to-path lookup from the index. Does not trigger a scan.
*/
getPathByName(name: string): string | undefined;
/**
* Returns true if at least one scan has completed (index is authoritative).
*/
hasCompletedScan(): boolean;
/**
* Notify the storage layer that a file was saved.
* Re-stats and re-parses the file to update index/manifest.
*/
notifySaved(relativePath: string, absolutePath: string): Promise<void>;
/**
* Notify the storage layer that a file was deleted.
* Removes the entry from index and manifest.
*/
notifyDeleted(relativePath: string): void;
/**
* Force the next scan() to hit disk by resetting the cooldown timer.
*/
invalidate(): void;
/**
* Reset all state (index, manifest, cooldown).
*/
clear(): void;
private performScan;
}
//# sourceMappingURL=ElementStorageLayer.d.ts.map