/** * ThinkHive SDK v3.0 - Claims API * * Facts vs Inferences API for accessing analysis claims */ import type { Claim, ClaimType, ClaimCategory, AnalysisResult, EvidenceReference } from '../core/types'; /** * List claims query options */ export interface ListClaimsOptions { runId?: string; analysisId?: string; claimType?: ClaimType; claimCategory?: ClaimCategory; minConfidence?: number; humanVerified?: boolean; limit?: number; offset?: number; } /** * Create analysis options */ export interface CreateAnalysisOptions { runId: string; modelUsed: string; outcomeVerdict: 'success' | 'partial_success' | 'failure'; outcomeConfidence?: number; rootCauseCategory?: string; rootCauseConfidence?: number; claims?: CreateClaimInput[]; } export interface CreateClaimInput { claimType: ClaimType; claimCategory: ClaimCategory; claimText: string; confidence: number; confidenceCalibration: 'calibrated' | 'uncalibrated' | 'rule_based'; evidence: EvidenceReference[]; isExplainable?: boolean; probabilityValue?: number; } /** * Facts vs inferences summary */ export interface FactsVsInferencesSummary { analysisIds: string[]; totalClaims: number; observed: { count: number; avgConfidence: number; categories: Record; }; inferred: { count: number; avgConfidence: number; categories: Record; }; computed: { count: number; avgConfidence: number; categories: Record; }; humanVerifiedCount: number; humanRejectedCount: number; } /** * Claims API client for facts vs inferences management */ export declare const claims: { /** * Create a new analysis for a run * * @example * ```typescript * const analysis = await claims.createAnalysis({ * runId: 'run_abc123', * outcomeVerdict: 'failure', * outcomeConfidence: 0.85, * rootCauseCategory: 'retrieval_failure', * claims: [ * { * claimType: 'observed', * claimCategory: 'root_cause', * claimText: 'Vector search returned 0 results', * confidence: 1.0, * evidence: [{ type: 'span', referenceId: 'span_123', relevance: 'direct', confidence: 1.0 }], * }, * { * claimType: 'inferred', * claimCategory: 'churn_risk', * claimText: 'High churn risk due to repeated failures', * confidence: 0.7, * }, * ], * }); * ``` */ createAnalysis(options: CreateAnalysisOptions): Promise; /** * Get an analysis by ID * * @example * ```typescript * const analysis = await claims.getAnalysis('analysis_abc123'); * ``` */ getAnalysis(analysisId: string): Promise; /** * Get current analysis for a run * * @example * ```typescript * const analysis = await claims.getRunAnalysis('run_abc123'); * ``` */ getRunAnalysis(runId: string): Promise; /** * Get analysis history for a run * * @example * ```typescript * const history = await claims.getAnalysisHistory('run_abc123'); * ``` */ getAnalysisHistory(runId: string): Promise<{ runId: string; analyses: Array<{ id: string; analysisVersion: string; modelUsed: string; outcomeVerdict: string; isCurrent: boolean; supersededBy?: string; supersessionReason?: string; analyzedAt: string; }>; }>; /** * Supersede an analysis with a new one * * @example * ```typescript * const newAnalysis = await claims.supersedeAnalysis('analysis_old', { * reason: 'Improved model accuracy', * newAnalysis: { * outcomeVerdict: 'success', * outcomeConfidence: 0.95, * claims: [...], * }, * }); * ``` */ supersedeAnalysis(analysisId: string, options: { reason: string; newAnalysis: Omit; }): Promise<{ supersededAnalysisId: string; newAnalysis: AnalysisResult; }>; /** * List claims with filters * * @example * ```typescript * // Get all inferred claims with high confidence * const { claims } = await claims.list({ * claimType: 'inferred', * minConfidence: 0.8, * }); * * // Get all churn risk claims for a run * const { claims } = await claims.list({ * runId: 'run_abc123', * claimCategory: 'churn_risk', * }); * ``` */ list(options?: ListClaimsOptions): Promise<{ claims: Claim[]; limit: number; offset: number; hasMore: boolean; }>; /** * Get a claim by ID * * @example * ```typescript * const claim = await claims.get('claim_abc123'); * ``` */ get(claimId: string): Promise; /** * Verify or reject a claim (human feedback) * * @example * ```typescript * // Confirm a claim * await claims.verify('claim_abc123', { * verdict: 'confirmed', * notes: 'Verified against ticket history', * }); * * // Reject a claim * await claims.verify('claim_abc123', { * verdict: 'rejected', * notes: 'Customer context was missing', * }); * ``` */ verify(claimId: string, options: { verdict: "confirmed" | "rejected" | "modified"; notes?: string; modifiedText?: string; }): Promise<{ claimId: string; verdict: string; message: string; }>; /** * Get facts vs inferences summary * * @example * ```typescript * // Summary for a specific run * const summary = await claims.summary({ runId: 'run_abc123' }); * * // Summary for multiple analyses * const summary = await claims.summary({ * analysisIds: ['analysis_1', 'analysis_2'], * }); * ``` */ summary(options?: { runId?: string; analysisIds?: string[]; }): Promise; }; /** * Check if a claim is a fact (observed) * Accepts both { claimType: 'observed' } (API format) and { type: 'fact' } (shorthand) */ export declare function isFact(claim: Claim | { type?: string; claimType?: string; }): boolean; /** * Check if a claim is an inference * Accepts both { claimType: 'inferred' } (API format) and { type: 'inference' } (shorthand) */ export declare function isInference(claim: Claim | { type?: string; claimType?: string; }): boolean; /** * Check if a claim is computed * Accepts both { claimType: 'computed' } (API format) and { type: 'computed' } (shorthand) */ export declare function isComputed(claim: Claim | { type?: string; claimType?: string; }): boolean; /** * Get high confidence claims (>= threshold) */ export declare function getHighConfidenceClaims(claimsList: Claim[], threshold?: number): Claim[]; /** * Group claims by type * Returns groups keyed by both API names (observed/inferred/computed) * and shorthand names (fact/inference/computed) for convenience */ export declare function groupClaimsByType(claimsList: Array): Record>; /** * Group claims by category */ export declare function groupClaimsByCategory(claimsList: Claim[]): Record;