import { P as PrmGradedTrace, S as StepRubric, a as PrmGrader } from '../rubric-Cc6UHvUb.js';
export { G as GradedStep, b as StepContext, i as isPrmVerdict } from '../rubric-Cc6UHvUb.js';
import { T as TraceStore } from '../store-BcFXE6LG.js';
import { S as Span } from '../schema-m0gsnbt3.js';
import '../trajectory-2TkpSEVh.js';

/**
 * Export PRM-graded traces as training data for downstream reward-model
 * fine-tuning. Canonical format is NDJSON of
 * `{ trajectory_text, step_index, rubric, score }` so a small model can
 * learn to predict step rewards from step context.
 *
 * The framework doesn't train the model — we emit the data; callers
 * plug it into their preferred trainer (TRL, Unsloth, custom).
 */

interface PrmTrainingSample {
    runId: string;
    spanId: string;
    rubricId: string;
    score: number;
    /** Serialized step context — step + surrounding conversation. */
    context: {
        priorTurns: Array<{
            role: string;
            content: string;
        }>;
        step: {
            kind: Span['kind'];
            text: string;
        };
    };
    /** Optional evidence + rationale for auditability. */
    rationale?: string;
    evidence?: string;
}
declare function exportTrainingData(store: TraceStore, graded: PrmGradedTrace[], options?: {
    contextWindow?: number;
}): Promise<PrmTrainingSample[]>;
/** NDJSON serialization — write to file or stream directly to a trainer. */
declare function toNdjson(samples: PrmTrainingSample[]): string;

/**
 * Built-in reference rubrics. Consumers combine these with domain
 * rubrics. All are deterministic, rule-based — cheap to run + easy
 * to unit-test. LLM-based rubrics are trivially authored by
 * following the StepRubric contract.
 */

/** Penalize very short or very long assistant outputs. */
declare function outputLengthRubric(args?: {
    minChars?: number;
    maxChars?: number;
    weight?: number;
}): StepRubric;
/** Reward tool calls that succeeded (status='ok') with an informative result. */
declare function toolSuccessRubric(args?: {
    weight?: number;
}): StepRubric;
/** Penalize tool calls that duplicate a prior call with identical args. */
declare function toolNonRedundantRubric(args?: {
    weight?: number;
}): StepRubric;
/** Penalize LLM outputs that contain common refusal markers when a refusal
 *  is NOT expected (caller inverts weight for scenarios where refusal IS expected). */
declare function nonRefusalRubric(args?: {
    markers?: RegExp[];
    weight?: number;
}): StepRubric;
/** Reward outputs that invoke the next-step tool the trajectory actually uses
 *  (i.e. the LLM span announced "I will call X" and the following tool span IS X). */
declare function toolIntentAlignmentRubric(args?: {
    weight?: number;
}): StepRubric;

/**
 * Inference-time PRM scoring — pick the best of N candidate trajectories
 * using a trained reward model (or a rule-based PRM as a proxy).
 *
 * The canonical Best-of-N pattern: generate N completions, score each
 * with a PRM, pick the winner. Here the scoring loop is framework-agnostic
 * — supply a TraceStore + PrmGrader + N run IDs → get ranking + winner.
 */

interface BestOfNResult {
    winner: PrmGradedTrace;
    ranked: PrmGradedTrace[];
    /** Standard deviation of aggregate scores — small = candidates were homogenous. */
    stdDev: number;
}
interface PrmBestOfNOptions {
    /** Max concurrent `grader.grade` calls. Default 4. */
    concurrency?: number;
}
declare function prmBestOfN(store: TraceStore, grader: PrmGrader, runIds: string[], options?: PrmBestOfNOptions): Promise<BestOfNResult>;
/**
 * Weighted vote across multiple graders — use when you want a PRM ensemble
 * (e.g. rule-based + LLM-based + trained model). Each grader produces its
 * own ranking; we aggregate via rank-sum (Borda count) so no single grader
 * dominates via a different score scale.
 */
declare function prmEnsembleBestOfN(store: TraceStore, graders: PrmGrader[], runIds: string[], options?: PrmBestOfNOptions): Promise<BestOfNResult>;

export { type BestOfNResult, type PrmBestOfNOptions, PrmGradedTrace, PrmGrader, type PrmTrainingSample, StepRubric, exportTrainingData, nonRefusalRubric, outputLengthRubric, prmBestOfN, prmEnsembleBestOfN, toNdjson, toolIntentAlignmentRubric, toolNonRedundantRubric, toolSuccessRubric };
