import type { Usage } from "../types.js"; import { type Answer, type Judge, type JudgeOptions, type JudgmentRequest, type JudgmentResult, type JudgmentState, type Question, type Questions } from "./types.js"; export interface TextPrompt { system: string; user: string; /** Format-correction attempt; chat backends may enforce tool suppression on the wire. */ retry?: boolean; } export interface TextCompletion { text: string; /** Omitted by backends that do not meter tokens (on-device workers). */ usage?: Usage; } /** Completes a rendered judgment prompt; identifies itself for usage attribution. */ export interface TextBackend { readonly api: string; readonly provider: string; readonly model: string; /** State guard for agent-tuned chat models; on-device classifier workers may disable it. */ readonly guardState?: boolean; /** Format-correction retries after a completion cannot be parsed. */ readonly parseRetries?: number; complete(prompt: TextPrompt, options: JudgeOptions): Promise; } /** Render judgment state as top-level XML fields; nested values use block YAML. */ export declare function renderJudgmentState(state: JudgmentState): string; /** * Render a request: the system prompt carries the preamble and question * definitions (constant across states, so prompt caches hit); the user message * carries XML-field state followed by the answer-format cue. Small models act * on a bare request (answer it, emit tool calls) instead of classifying it — * explicit tags and the trailing cue keep them on task. */ export declare function renderJudgmentPrompt(request: JudgmentRequest, options?: { guardState?: boolean; }): TextPrompt; /** * Earliest option label mentioned in `text`; a longer label wins a tie at the * same position (so `xhigh` beats `high` where both start together). */ export declare function parseChoiceReply(text: string, labels: readonly L[]): L | undefined; /** `true` when a yes-word precedes any no-word, `false` for the reverse, `undefined` when neither appears. */ export declare function parseNoulReply(text: string): boolean | undefined; /** First standalone integer in `[0, levels)`, or `undefined`. */ export declare function parseScoreReply(text: string, levels: number): number | undefined; /** * Split a multi-question reply into `id → answer text`. Lines are matched as * `: ` (also `=` / `-` separators and quoted ids); unknown ids are * ignored so a chatty preamble does not poison parsing. */ export declare function splitAnswerLines(text: string, ids: readonly string[]): Map; /** Parse one question's keyword reply into its typed, one-hot answer. */ export declare function parseAnswer(id: string, question: Question, reply: string): Answer; export declare class TextJudge implements Judge { #private; readonly label: string; constructor(backend: TextBackend); judge(request: JudgmentRequest, options?: JudgeOptions): Promise>; }