import type { QueryParams } from './types.mts'; /** * Calculate Jaccard similarity coefficient between two strings based on word * sets. Returns a value between 0 (no overlap) and 1 (identical word sets). * * Formula: |A ∩ B| / |A ∪ B| * * @example * ;```typescript * calculateWordSetSimilarity('hello world', 'world hello') // 1.0 (same words) * calculateWordSetSimilarity('hello world', 'goodbye world') // 0.33 (1/3 overlap) * calculateWordSetSimilarity('hello', 'goodbye') // 0 (no overlap) * ``` * * @param str1 - First string to compare. * @param str2 - Second string to compare. * * @returns Similarity coefficient (0-1) */ export declare function calculateWordSetSimilarity(str1: string, str2: string): number; /** * Filter error cause based on similarity to error message. Returns undefined if * the cause should be omitted due to redundancy. * * Intelligently handles common error message patterns by: - Comparing full * messages - Splitting on colons and comparing each part - Finding the highest * similarity among all parts. * * Examples: - "Socket API Request failed (400): Bad Request" vs "Bad Request" - * "Error: Authentication: Token expired" vs "Token expired" * * @example * ;```typescript * filterRedundantCause('Invalid token', 'The token is invalid') // undefined * filterRedundantCause('Request failed', 'Rate limit exceeded') // 'Rate limit exceeded' * filterRedundantCause( * 'API Request failed (400): Bad Request', * 'Bad Request', * ) // undefined * filterRedundantCause('Error: Auth: Token expired', 'Token expired') // undefined * ``` * * @param errorMessage - Main error message. * @param errorCause - Detailed error cause/reason. * @param threshold - Similarity threshold (0-1), defaults to 0.6. * * @returns The error cause if it should be kept, undefined otherwise */ export declare function filterRedundantCause(errorMessage: string, errorCause: string | undefined, threshold?: number): string | undefined; /** * Normalize base URL by ensuring it ends with a trailing slash. Required for * proper URL joining with relative paths. Memoized for performance since base * URLs are typically reused. */ export declare const normalizeBaseUrl: (baseUrl: string) => string; /** * Normalize a string to a set of lowercase words (alphanumeric sequences). * Extracts word characters and creates a deduplicated set. * * @param s - String to normalize. * * @returns Set of normalized words */ export declare function normalizeToWordSet(s: string): Set; /** * Create a promise with externally accessible resolve/reject functions. * Polyfill for Promise.withResolvers() on older Node.js versions. */ export declare function promiseWithResolvers(): ReturnType>; /** * Convert query parameters to URLSearchParams with API-compatible key * normalization. Transforms camelCase keys to snake_case and filters out empty * values. */ export declare function queryToSearchParams(init?: URLSearchParams | string | QueryParams | Iterable<[string, unknown]> | ReadonlyArray<[string, unknown]> | null | undefined): URLSearchParams; /** * Convert relative file paths to absolute paths. Resolves paths relative to * specified base directory or current working directory. */ export declare function resolveAbsPaths(filepaths: string[], pathsRelativeTo?: string | undefined): string[]; /** * Resolve base path to an absolute directory path. Converts relative paths to * absolute using current working directory as reference. */ export declare function resolveBasePath(pathsRelativeTo?: string): string; /** * Determine if a "reason" string should be omitted due to high similarity with * error message. Uses Jaccard similarity to detect redundant phrasing. * * @example * ;```typescript * shouldOmitReason('Invalid token', 'The token is invalid') // true (high overlap) * shouldOmitReason('Request failed', 'Rate limit exceeded') // false (low overlap) * ``` * * @param errorMessage - Main error message. * @param reason - Detailed reason/cause string. * @param threshold - Similarity threshold (0-1), defaults to 0.6. * * @returns True if reason should be omitted (too similar) */ export declare function shouldOmitReason(errorMessage: string, reason: string | undefined, threshold?: number): boolean;