/** * Smart Truncation Utilities * * Provides intelligent content truncation that preserves structure * for different content types (JSON, Markdown, plain text). * * Unlike simple string truncation, these functions: * - Preserve JSON structure (valid JSON output) * - Preserve Markdown headers and section structure * - Truncate at natural boundaries (sentences, paragraphs) * - Provide helpful truncation indicators */ /** Content type for smart truncation */ export type ContentType = 'json' | 'markdown' | 'text'; /** Options for smart truncation */ export interface SmartTruncateOptions { /** Maximum length in characters */ maxLength: number; /** Content type for appropriate truncation strategy */ contentType?: ContentType; /** Whether to preserve JSON structure (for JSON content) */ preserveJsonStructure?: boolean; /** Whether to preserve markdown headers (for markdown content) */ preserveMarkdownHeaders?: boolean; /** Minimum array items to show when truncating JSON arrays */ minArrayItems?: number; /** Custom truncation indicator */ truncationIndicator?: string; } /** Result of smart truncation */ export interface TruncationResult { /** The truncated content */ content: string; /** Whether truncation occurred */ wasTruncated: boolean; /** Original length */ originalLength: number; /** Number of characters removed */ charactersRemoved: number; /** Items omitted (for arrays/objects) */ itemsOmitted?: number; } /** * Smart truncate content based on type. * * @param content - Content to truncate * @param options - Truncation options * @returns Truncation result */ export declare function smartTruncate(content: string, options: SmartTruncateOptions): TruncationResult; /** * Simple string truncation with indicator. * * @param content - Content to truncate * @param maxLength - Maximum length * @param indicator - Truncation indicator * @returns Truncation result */ export declare function simpleTruncate(content: string, maxLength: number, indicator?: string): TruncationResult; /** * Smart truncate JSON while preserving valid structure. * * @param content - JSON string to truncate * @param maxLength - Maximum length * @param minArrayItems - Minimum array items to preserve * @param indicator - Custom truncation indicator * @returns Truncation result */ export declare function smartTruncateJson(content: string, maxLength: number, minArrayItems?: number, indicator?: string): TruncationResult; /** * Smart truncate Markdown while preserving structure. * * @param content - Markdown content to truncate * @param maxLength - Maximum length * @param indicator - Custom truncation indicator * @returns Truncation result */ export declare function smartTruncateMarkdown(content: string, maxLength: number, indicator?: string): TruncationResult; /** * Detect content type from content. * * @param content - Content to analyze * @returns Detected content type */ export declare function detectContentType(content: string): ContentType; /** * Get the appropriate example length based on options. * * @param fullExamples - Whether to use full example length * @param customLength - Custom length override * @returns Example length to use */ export declare function getExampleLength(fullExamples: boolean, customLength?: number): number; //# sourceMappingURL=smart-truncate.d.ts.map