/** * Compressor Module * * Phase 3: Reduce token usage by extracting only essential fields * from search results based on compression level. * * Token targets: * - minimal: ~20 tokens per record (id, url, source) * - standard: ~50 tokens per record (+ title, year) * - full: ~80 tokens per record (+ type, creator) */ import type { CompressionLevel, CompressedRecord, CompressionOptions, CompressionResult } from './types.js'; /** * Estimate the number of tokens for a data structure * * Uses a simple heuristic: ~4 characters per token for English text, * plus JSON structure overhead. * * @param data - Any data structure (will be JSON stringified) * @returns Estimated token count */ export declare function estimateTokens(data: unknown): number; /** * Truncate a title at a word boundary * * Preserves word boundaries to avoid cutting mid-word. * Adds ellipsis if truncated. * * @param title - Original title * @param maxLength - Maximum length (default: 50) * @returns Truncated title */ export declare function truncateTitle(title: string, maxLength?: number): string; /** * Extract year from various date formats in a record * * Handles: * - Direct year field: { year: 1920 } * - ISO date: { date: "1920-05-12" } * - Year string: { dateCreated: "1920" } * - Decade: { period: "1920s" } * - In title: { title: "Report 1920" } * * @param record - Record with potential date fields * @returns Extracted year or undefined */ export declare function extractYear(record: Record): number | undefined; /** * Compress a single record to the specified level * * @param record - Original record with any structure * @param source - Source data provider name * @param level - Compression level * @param maxTitleLength - Maximum title length for truncation * @returns Compressed record */ export declare function compressRecord(record: Record, source: string, level: CompressionLevel, maxTitleLength?: number): CompressedRecord; /** * Compress multiple records with statistics * * @param records - Array of records to compress * @param options - Compression options * @returns Compression result with statistics */ export declare function compressRecords(records: Array<{ record: Record; source: string; }>, options?: Partial): CompressionResult; /** * Convenience function to compress an array of records with inferred source * * @param records - Array of records (must have source field) * @param options - Compression options * @returns Compression result */ export declare function compressRecordArray(records: Record[], options?: Partial): CompressionResult; //# sourceMappingURL=compressor.d.ts.map