import type { TSchema } from "typebox"; /** * Find a JSON object/array in free-form text: a fenced ```json block if present, else the * first balanced {...} or [...]. Best-effort (the schema check is the real gate). Returns the * raw JSON string, or undefined when none is found. (Ported VERBATIM from pi agent.ts.) */ export declare function findJsonBlock(text: string): string | undefined; /** * Parse a turn's final assistant text as JSON: direct parse first (a natively-constrained * final message is pure JSON), then a balanced-block extraction when the turn also emitted * leading prose. Returns undefined when no parseable JSON is present (the caller's ladder * re-prompts). Shared by the Codex backend and every custom registry backend — the "read the * structured result off the final message" convention is the generic ACP dialect. */ export declare function parseFinalJson(text: string): unknown; /** Coerce an already-parsed value toward the schema and accept it only if it then validates. */ export declare function validateValue(value: unknown, schema: TSchema): unknown; /** * Last-resort structured-output recovery: extract a JSON block from prose, coerce it toward * the schema, and accept it only if it then validates. Never fabricates — returns undefined * unless the parsed value genuinely satisfies the schema. (Ported VERBATIM from pi agent.ts.) */ export declare function extractValidated(text: string, schema: TSchema): unknown; /** Minimal session surface the structured-output ladder needs (real ACP session or a test double). */ export interface StructuredSession { /** Send one more (re-prompt) turn and drain it. */ prompt(text: string): Promise; /** The latest turn's assistant text (for prose extraction). */ lastText(): string; /** The backend's native structured result for the latest turn (unvalidated), or undefined. */ tryNative?(): unknown; /** Captured StructuredOutput MCP tool arguments, when client-hosted injection is active. */ tryCaptured?(): unknown | undefined; } export interface ResolveOptions { /** Extra repair turns before giving up. Leaf default 2 (matches pi). */ maxSchemaRetries?: number; signal?: AbortSignal; label?: string; repromptText?: string; } /** * Resolve a schema agent's result via the ladder above. Returns the validated value (typed * unknown at this layer; the caller casts to the seam's AgentResult). Throws * SCHEMA_NONCOMPLIANCE (non-recoverable) when no valid value is produced after the retries. */ export declare function resolveStructuredOutput(session: StructuredSession, schema: TSchema, options: ResolveOptions): Promise; //# sourceMappingURL=structured-output.d.ts.map