/** * Field-Level Confidence Map (CX-002) * * Provides per-field confidence scores in MCP tool responses. * This allows LLM clients to: * - Weight different fields appropriately when making decisions * - Know which extracted data is reliable vs uncertain * - Request re-extraction for low-confidence fields * * Confidence Scale: 0.0 to 1.0 * - 1.0: Extracted from structured data (JSON-LD, API, schema) * - 0.8-0.9: Strong selector match, validated * - 0.6-0.8: Selector match, partially validated * - 0.4-0.6: Heuristic extraction, needs verification * - 0.2-0.4: Fallback extraction, low reliability * - 0.0-0.2: Best-effort guess, treat with caution */ /** * Confidence level with human-readable label */ export type ConfidenceLevel = 'very_high' | 'high' | 'medium' | 'low' | 'very_low'; /** * Single field confidence entry */ export interface FieldConfidence { /** Numeric confidence score (0.0 to 1.0) */ score: number; /** Human-readable confidence level */ level: ConfidenceLevel; /** Source that provided this data */ source: ExtractionSource; /** Optional reason explaining the confidence */ reason?: string; } /** * Source of the extracted data */ export type ExtractionSource = 'structured_data' | 'api_response' | 'graphql' | 'selector_match' | 'learned_pattern' | 'framework_data' | 'meta_tags' | 'heuristic' | 'fallback' | 'unknown'; /** * Confidence map for browse result fields */ export interface BrowseFieldConfidence { /** Confidence in extracted title */ title: FieldConfidence; /** Confidence in markdown content */ content: FieldConfidence; /** Confidence in tables (if present) */ tables?: TableConfidence[]; /** Confidence in discovered APIs */ discoveredApis?: ApiConfidence[]; /** Overall extraction confidence */ overall: FieldConfidence; } /** * Confidence for an extracted table */ export interface TableConfidence { /** Table index in the result */ index: number; /** Confidence in header detection */ headers: FieldConfidence; /** Confidence in data extraction */ data: FieldConfidence; /** Confidence in caption extraction (if present) */ caption?: FieldConfidence; } /** * Confidence for a discovered API */ export interface ApiConfidence { /** API endpoint */ endpoint: string; /** Confidence in endpoint detection */ endpointConfidence: FieldConfidence; /** Confidence in method detection */ methodConfidence: FieldConfidence; /** Confidence in bypass capability */ bypassConfidence: FieldConfidence; } /** * Convert numeric score to confidence level */ export declare function scoreToLevel(score: number): ConfidenceLevel; /** * Create a FieldConfidence object from score and source */ export declare function createFieldConfidence(score: number, source: ExtractionSource, reason?: string): FieldConfidence; /** * Combine multiple confidences into an aggregate score * Uses weighted geometric mean to penalize low confidence more heavily */ export declare function aggregateConfidence(confidences: FieldConfidence[], weights?: number[]): FieldConfidence; /** * Boost confidence based on validation */ export declare function boostForValidation(confidence: FieldConfidence, validationPassed: boolean, boost?: number): FieldConfidence; /** * Confidence scores by extraction source */ export declare const SOURCE_CONFIDENCE_SCORES: Record; /** * Create confidence from extraction source with default score */ export declare function confidenceFromSource(source: ExtractionSource, reason?: string): FieldConfidence; //# sourceMappingURL=field-confidence.d.ts.map