import type { JSONSchema } from './types'; /** Build the instruction appended to the system prompt to elicit schema-shaped JSON. */ export declare function buildSchemaInstruction(schema: JSONSchema): string; /** Follow-up prompt when the model returned something that could not be parsed as JSON. */ export declare const REPAIR_INVALID_JSON: string; /** Follow-up prompt when the model returned valid JSON that violated the schema. */ export declare function buildSchemaRepair(errors: string[]): string; export type ParseResult = { ok: true; value: unknown; } | { ok: false; }; /** * Best-effort extraction of a JSON value from model output. * * On-device models often wrap JSON in a ```json fence or add a sentence of prose * around it. We try, in order: a fenced block, the trimmed whole string, then the * first balanced {...}/[...] block found anywhere in the text. */ export declare function extractJson(text: string): ParseResult; /** * Return the first balanced `{...}` or `[...]` substring, or null if none. * Tracks string state so braces inside JSON strings are not counted. */ export declare function sliceBalanced(text: string): string | null; /** * Validate `value` against the supported subset of `schema`. * Returns a list of human-readable error strings (empty ⇒ valid). * * Intentionally lenient: unknown keywords and extra object properties are * allowed. The goal is to catch structural mistakes worth re-prompting over * (wrong type, missing required field), not full JSON Schema conformance. */ export declare function validateAgainstSchema(value: unknown, schema: JSONSchema): string[]; //# sourceMappingURL=structured.d.ts.map