UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

136 lines 3.54 kB
/** * DeduplicatedContentStorage implementation * Provides memory-efficient storage with content deduplication * to minimize redundant memory usage for identical or similar content */ /** * Options for configuring DeduplicatedContentStorage behavior */ export interface DeduplicatedContentStorageOptions { /** * Hashing algorithm to use for content deduplication * @default 'sha256' */ hashAlgorithm?: string; /** * Whether to use a bloom filter for faster negative lookups * @default true */ useBloomFilter?: boolean; /** * Whether to track memory usage statistics * @default true */ trackStats?: boolean; /** * Size of content chunks for partial deduplication (in characters) * Set to 0 to disable chunk-level deduplication * @default 0 */ chunkSize?: number; /** * Whether to compress stored content * @default false */ compressContent?: boolean; } /** * Metadata for stored content */ export interface ContentMetadata { hash: string; size: number; originalSize: number; referenceCount: number; createdAt: number; lastAccessedAt: number; compressionRatio?: number; } /** * Content reference with metadata */ export interface ContentReference { hash: string; metadata?: Record<string, any>; } /** * DeduplicatedContentStorage class * Provides memory-efficient storage through content deduplication */ export declare class DeduplicatedContentStorage { private contentStore; private contentMetadata; private references; private bloomFilter; private contentChunks; private hashAlgorithm; private trackStats; private chunkSize; private compressContent; private stats; constructor(options?: DeduplicatedContentStorageOptions); /** * Store content with deduplication * Returns a reference ID for the stored content */ store(content: string, id?: string, metadata?: Record<string, any>): string; /** * Retrieve content by reference ID */ retrieve(id: string): string | null; /** * Get content metadata */ getMetadata(id: string): ContentMetadata | null; /** * Remove content reference * Content is only deleted when no more references exist */ remove(id: string): boolean; /** * Check if a reference exists */ has(id: string): boolean; /** * Clear all content and references */ clear(): void; /** * Get storage statistics */ getStats(): typeof this.stats; /** * Calculate the memory savings due to deduplication */ calculateDedupSavings(): number; /** * Process content for storage, including chunking or compression */ private processContentForStorage; /** * Process content for retrieval, including unchunking or decompression */ private processContentForRetrieval; /** * Chunkify content for chunk-level deduplication */ private chunkifyContent; /** * Rebuild content from chunks */ private unchunkifyContent; /** * Hash content using configured algorithm */ private hashContent; /** * Simple non-cryptographic hash function * This is faster but has more collisions than cryptographic hashes */ private simpleHash; /** * Generate a unique ID for content references */ private generateId; } //# sourceMappingURL=DeduplicatedContentStorage.d.ts.map