import { BaseGrader } from "./baseGrader.js"; import type { EvalRecord } from "../../eval/types.js"; import type { Grade, GraderInput, GraderOptions, Test, JSON } from "./types.js"; import type { TestInput } from "../runTypes.js"; /** What a metric function receives. `test` is the typed Test: what the agent * was given is `test.input`, the gold answer is `test.expected`, and any extra * per-test data lives under `test.metadata`. */ export type GraderContext = { output: JSON; test: Test; /** The isolated directory the agent ran in. Read files the agent wrote. */ workdir: string; /** One file from that directory, by relative path; "" when it is missing. */ workdirFile: (relativePath: string) => string; /** The test's `graderFiles/` directory: answers and notes the agent never * saw. "" when the test has none. */ graderFiles: string; /** The parsed eval record: events, metrics, tool counts, interrupts, cost. */ record: EvalRecord; /** The bundled LLM judges, one per question a grader can ask. Each * returns a full Grade (the 0..1 score, the reasoning as `feedback`), so * a metric can return it directly and the rationale is stored with the * score. `output` falls back to `run.output` for every judge. */ judges: Judges; }; export type Judges = { /** Was the output the right answer to the goal? `expected` falls back to * `test.expected`, so the judge grades against the gold answer when one * is present, matching `LlmJudge`. Extra content is penalized and any * expected text is authoritative: right for "name the capital", wrong for * grading work against a standard. */ goal: (args: { goal: string; output?: JSON; expected?: JSON; }) => Promise; /** How well does the output meet the standard? `context` is material the * standard refers to (the source text, an editor's notes, a reference * version), read as background and never as an answer to match. Use it * when the question is "does this meet the bar", such as review findings. */ rubric: (args: { standard: string; output?: JSON; context?: string; }) => Promise; }; /** A metric: return a 0..1 number, a pass/fail boolean, or a full Grade. */ export type GraderFn = (ctx: GraderContext) => number | boolean | Grade | Promise; /** Public "grader" union: a metric function or a configured grader instance. */ export type Grader = GraderFn | BaseGrader; /** Adapts a metric function into a single-shot BaseGrader so the whole grading * pipeline (sampling, gating, weighting, scoring) treats it like any grader. */ export declare class FunctionGrader extends BaseGrader { private readonly fn; protected readonly defaultName = "fn"; constructor(fn: GraderFn, options?: GraderOptions); protected _run({ test, run, runAgency, graderFiles }: GraderInput): Promise; } /** Wrap a metric function so it carries policy (mustPass/weight/threshold/samples/name). */ export declare function grader(fn: GraderFn, options?: GraderOptions): BaseGrader; /** Normalize a user-supplied grader (function or instance) into a BaseGrader. */ export declare function toGrader(spec: Grader): BaseGrader;