/** * ThinkHive SDK v3.0 - Non-Determinism API * * API for pass@k / pass^k analysis to measure LLM evaluation reliability */ export type NondeterminismRunType = 'pass_at_k' | 'pass_to_k' | 'variance' | 'reliability'; export type NondeterminismRunStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'; export interface NondeterminismRun { id: string; companyId: string; agentId: string; runType: NondeterminismRunType; kValue: number; status: NondeterminismRunStatus; traceCount: number; criterionId?: string; criteriaIds: string[]; temperature?: string; model?: string; progressPercent: number; passAtKRate?: string; passToKRate?: string; avgVariance?: string; reliabilityScore?: string; startedAt?: string; completedAt?: string; createdBy?: string; createdAt: string; } export interface NondeterminismSample { id: string; runId: string; traceId: string; criterionId: string; sampleIndex: number; score: string; passed: boolean; reasoning?: string; confidence?: string; tokensUsed?: number; costUsd?: string; model?: string; temperature?: string; latencyMs?: number; error?: string; createdAt: string; } export interface CreateRunOptions { agentId: string; criterionId?: string; criteriaIds?: string[]; kValue: number; traceIds: string[]; runType?: NondeterminismRunType; temperature?: number; model?: string; } export interface RecordSampleOptions { runId: string; traceId: string; criterionId: string; sampleIndex: number; score: number; passed: boolean; reasoning?: string; confidence?: number; tokensUsed?: number; costUsd?: number; model?: string; temperature?: number; latencyMs?: number; error?: string; } export interface TraceAnalysis { traceId: string; samples: NondeterminismSample[]; passCount: number; totalCount: number; passRate: number; scoreVariance: number; meanScore: number; isConsistent: boolean; } export interface CriterionAnalysis { criterionId: string; traceAnalyses: TraceAnalysis[]; passAtKRate: number; passToKRate: number; reliabilityScore: number; isReliable: boolean; recommendation: string; } export interface RunSummary { run: NondeterminismRun; traceAnalyses: TraceAnalysis[]; criterionAnalyses: CriterionAnalysis[]; } export interface ListRunsOptions { agentId?: string; status?: NondeterminismRunStatus; limit?: number; offset?: number; } export interface PassAtKInfo { concepts: { passAtK: { name: string; description: string; formula: string; useCase: string; }; passToK: { name: string; description: string; formula: string; useCase: string; }; variance: { name: string; description: string; useCase: string; }; reliability: { name: string; description: string; useCase: string; }; }; recommendations: Record; defaults: { kValue: number; reliabilityThreshold: number; varianceThreshold: number; }; } /** * Non-Determinism API client for pass@k analysis and reliability measurement */ export declare const nondeterminism: { /** * Create a new non-determinism analysis run * * @example * ```typescript * const run = await nondeterminism.createRun({ * agentId: 'agent_123', * criterionId: 'criterion_456', * kValue: 5, * traceIds: ['trace_1', 'trace_2', 'trace_3'], * runType: 'pass_at_k', * }); * ``` */ createRun(options: CreateRunOptions): Promise; /** * Get non-determinism runs * * @example * ```typescript * const runs = await nondeterminism.getRuns({ agentId: 'agent_123' }); * ``` */ getRuns(options?: ListRunsOptions): Promise; /** * Get a specific run * * @example * ```typescript * const run = await nondeterminism.getRun('run_123'); * ``` */ getRun(runId: string): Promise; /** * Start a run * * @example * ```typescript * await nondeterminism.startRun('run_123'); * ``` */ startRun(runId: string): Promise; /** * Complete a run * * @example * ```typescript * await nondeterminism.completeRun('run_123'); * ``` */ completeRun(runId: string): Promise; /** * Record a sample result * * @example * ```typescript * const sample = await nondeterminism.recordSample({ * runId: 'run_123', * traceId: 'trace_456', * criterionId: 'criterion_789', * sampleIndex: 0, * score: 85, * passed: true, * reasoning: 'Response meets quality criteria', * }); * ``` */ recordSample(options: RecordSampleOptions): Promise; /** * Get samples for a run * * @example * ```typescript * const samples = await nondeterminism.getSamples('run_123'); * ``` */ getSamples(runId: string): Promise; /** * Get run summary with analysis * * @example * ```typescript * const summary = await nondeterminism.getRunSummary('run_123'); * console.log(`Pass@k rate: ${summary.criterionAnalyses[0].passAtKRate}`); * ``` */ getRunSummary(runId: string): Promise; /** * Trigger analysis of a completed run * * @example * ```typescript * const summary = await nondeterminism.analyzeRun('run_123'); * ``` */ analyzeRun(runId: string): Promise; /** * Get information about pass@k analysis * * @example * ```typescript * const info = await nondeterminism.getInfo(); * console.log(info.concepts.passAtK.description); * ``` */ getInfo(): Promise; }; /** * Calculate pass@k probability * * Supports two calling conventions: * - calculatePassAtK(passRate, k) — from pass rate directly * - calculatePassAtK(n, c, k) — from n total runs, c correct, sample k * * @returns Probability that at least 1 of k runs passes * * @example * ```typescript * calculatePassAtK(0.7, 3); // ~0.973 (from pass rate) * calculatePassAtK(10, 8, 3); // ~0.983 (from 10 total, 8 correct, sample 3) * ``` */ export declare function calculatePassAtK(passRateOrN: number, kOrC: number, k?: number): number; /** * Calculate pass^k probability from pass rate * * @param passRate - Single-run pass rate (0-1) * @param k - Number of runs * @returns Probability that all k runs pass * * @example * ```typescript * const passToK = calculatePassToK(0.7, 3); // ~0.343 * ``` */ export declare function calculatePassToK(passRate: number, k: number): number; /** * Calculate required pass rate to achieve target pass@k * * @param targetPassAtK - Desired pass@k probability * @param k - Number of runs * @returns Required single-run pass rate * * @example * ```typescript * const requiredRate = requiredPassRateForPassAtK(0.95, 3); // ~0.632 * ``` */ export declare function requiredPassRateForPassAtK(targetPassAtK: number, k: number): number; /** * Determine if evaluation is reliable based on analysis * * Accepts either a CriterionAnalysis object or a raw reliability score: * - isReliableEvaluation(analysis) — from analysis result * - isReliableEvaluation(0.95, 5) — score and k value (k ignored, checks score) * - isReliableEvaluation(analysis, 0.9) — with custom threshold * * @param analysisOrScore - Criterion analysis result or raw reliability score * @param thresholdOrK - Reliability threshold (default 0.8) * @returns Whether the evaluation is considered reliable */ export declare function isReliableEvaluation(analysisOrScore: CriterionAnalysis | number, thresholdOrK?: number): boolean; /** * Get recommendation based on reliability analysis * * @param analysis - Criterion analysis result * @returns Actionable recommendation string */ export declare function getReliabilityRecommendation(analysis: CriterionAnalysis): string;