/**
 * parseStructuredOutput — robust JSON parser for LLM outputs.
 *
 * Promoted from forge/src/agents/shared/parse-llm-output.ts (Vague 1.B.5).
 * Extended with optional Zod schema validation and typed error on failure.
 *
 * LLMs occasionally wrap JSON in markdown code-fences or append trailing
 * commentary. This parser strips those artifacts, attempts JSON.parse, runs
 * optional Zod validation, then returns a fallback or throws on unrecoverable
 * parse errors.
 *
 * @public @since 0.18.0
 */
import type { ZodSchema } from "zod";
/**
 * Thrown by `parseStructuredOutput` when:
 * - JSON.parse fails AND no `fallback` is provided, OR
 * - Zod validation fails AND no `fallback` is provided.
 */
export declare class ParseStructuredOutputError extends Error {
    /** The raw LLM string that could not be parsed (first 500 chars). */
    readonly raw: string;
    /** The underlying parse / validation error. */
    readonly cause: unknown;
    constructor(message: string, raw: string, cause: unknown);
}
export interface ParseStructuredOutputOpts<T> {
    /**
     * Optional Zod schema for runtime validation after JSON.parse.
     * If validation fails and no `fallback` is provided,
     * `ParseStructuredOutputError` is thrown.
     */
    schema?: ZodSchema<T>;
    /**
     * Fallback value returned when JSON.parse or Zod validation fails.
     * When provided, the function never throws.
     */
    fallback?: T;
}
/**
 * Parse a raw LLM string into a typed value.
 *
 * Pipeline:
 * 1. Strip markdown ```json / ``` fences.
 * 2. `JSON.parse` the cleaned string.
 * 3. Optionally validate with a Zod schema.
 * 4. Return the value, or `fallback`, or throw `ParseStructuredOutputError`.
 *
 * @param raw   - Raw string produced by the LLM.
 * @param opts  - Optional Zod schema and/or fallback value.
 * @returns Parsed (and optionally validated) value of type `T`.
 * @throws {ParseStructuredOutputError} when parsing fails and no fallback is set.
 */
export declare function parseStructuredOutput<T>(raw: string, opts?: ParseStructuredOutputOpts<T>): T;
//# sourceMappingURL=parse-structured-output.d.ts.map