import { AgentEvent } from "@graphorin/core"; //#region src/evaluator-optimizer/index.d.ts /** * Rubric discriminator. Pick the variant that matches your * Evaluator's contract. * * @stable */ type Rubric = { readonly kind: 'free-form'; readonly instructions: string; } | { readonly kind: 'zod'; readonly instructions: string; } | { readonly kind: 'llm-judge'; readonly promptTemplate: string; }; /** * Per-iteration evaluation outcome returned by the Evaluator. * * @stable */ interface EvaluatorOutcome { readonly score: number; readonly pass: boolean; readonly critique: string; } /** * Generator callable shape. Receives the original user input plus * the previous iteration's critique (or `undefined` on the first * iteration) and returns the new candidate output. * * @stable */ type GeneratorCallable = (input: string, priorCritique: string | undefined, iteration: number) => Promise; /** * Evaluator callable shape. Receives the original user input + the * candidate output and returns the structured outcome. * * @stable */ type EvaluatorCallable = (input: string, candidate: TOutput, rubric: Rubric, iteration: number) => Promise; /** * Options accepted by {@link evaluatorOptimizer}. `maxIterations` * is REQUIRED - the helper asserts `>= 1` at construction time. * * @stable */ interface EvaluatorOptimizerOptions { readonly generator: GeneratorCallable; readonly evaluator: EvaluatorCallable; readonly maxIterations: number; readonly rubric: Rubric; readonly mergeStrategy?: 'last-iteration' | 'best-score'; readonly signal?: AbortSignal; /** Optional event emitter for `agent.evaluator.iteration / converged`. */ readonly emit?: (event: AgentEvent) => void; readonly runId: string; readonly sessionId: string; readonly agentId: string; } /** * Aggregate outcome of an `evaluatorOptimizer({...})` run. * * @stable */ interface EvaluatorOptimizerOutcome { readonly output: TOutput; readonly iterations: ReadonlyArray<{ readonly iteration: number; readonly candidate: TOutput; readonly score: number; readonly pass: boolean; readonly critique: string; readonly durationMs: number; }>; readonly terminationReason: 'pass' | 'maxIterations' | 'generator-exhausted' | 'cancelled'; readonly finalScore: number; } /** * Run the Generator → Evaluator iteration loop. * * @stable */ declare function evaluatorOptimizer(input: string, options: EvaluatorOptimizerOptions): Promise>; //#endregion export { EvaluatorCallable, EvaluatorOptimizerOptions, EvaluatorOptimizerOutcome, EvaluatorOutcome, GeneratorCallable, Rubric, evaluatorOptimizer }; //# sourceMappingURL=index.d.ts.map