packfs-core
Version:
Semantic filesystem operations for LLM agent frameworks with natural language understanding. See LLM_AGENT_GUIDE.md for copy-paste examples.
114 lines • 3.18 kB
TypeScript
/**
* Compression Engine for PackFS - Orchestrates multiple compression strategies
*
* This engine manages the selection and application of appropriate compression
* algorithms based on file type, access patterns, and system resources.
*/
import { CompressionStrategy, CompressedChunk } from './CompressionStrategy';
export interface CompressionProfile {
name: string;
development: boolean;
maxMemoryUsage: number;
prioritizeSpeed: boolean;
enableDictionary: boolean;
strategies: Record<string, CompressionStrategy>;
}
export interface CompressionResult {
success: boolean;
algorithm: string;
originalSize: number;
compressedSize: number;
compressionRatio: number;
compressionTime: number;
chunk?: CompressedChunk;
error?: string;
}
/**
* Main compression engine that orchestrates multiple strategies
*/
export declare class CompressionEngine {
private registry;
private profile;
private compressionStats;
constructor(profile: CompressionProfile);
/**
* Compress data using the optimal strategy
*/
compress(data: Buffer, mimeType: string, metadata?: {
path?: string;
accessFrequency?: number;
}): Promise<CompressionResult>;
/**
* Decompress a compressed chunk
*/
decompress(chunk: CompressedChunk): Promise<Buffer>;
/**
* Create a streaming decompressor
*/
createDecompressor(chunk: CompressedChunk): NodeJS.ReadableStream | null;
/**
* Analyze which compression strategy would be best for given data
*/
analyzeOptimalStrategy(data: Buffer, mimeType: string, metadata?: any): CompressionAnalysis;
/**
* Get compression statistics
*/
getStatistics(): CompressionEngineStats;
/**
* Initialize compression strategies based on profile
*/
private initializeStrategies;
/**
* Detect if a file is "hot" (frequently accessed)
*/
private isHotFile;
/**
* Detect the ecosystem based on file type and path
*/
private detectEcosystem;
/**
* Load compression dictionary for specific ecosystem
*/
private loadDictionary;
/**
* Update compression statistics
*/
private updateStats;
}
interface CompressionAnalysis {
recommendedStrategy: string;
estimations: Array<{
algorithm: string;
estimatedRatio: number;
priority: string;
suitable: boolean;
}>;
}
interface CompressionEngineStats {
totalCompressions: number;
totalDecompressions: number;
totalBytesProcessed: number;
totalBytesSaved: number;
averageCompressionRatio: number;
averageCompressionTime: number;
strategyUsage: Record<string, number>;
}
/**
* Pre-configured compression profiles
*/
export declare const CompressionProfiles: {
/**
* Development profile - prioritize speed
*/
development: CompressionProfile;
/**
* Production profile - balanced performance
*/
production: CompressionProfile;
/**
* CI profile - minimize resource usage
*/
ci: CompressionProfile;
};
export {};
//# sourceMappingURL=CompressionEngine.d.ts.map