import type { JsonSchema } from './types'; /** * Error thrown when the Agent SDK terminates without producing a schema-valid * object (any `SDKResultError` subtype, most importantly * `error_max_structured_output_retries`, or a `success` result that carries no * `structured_output`). Carries the terminal `subtype` and the accrued * `total_cost_usd` so a caller can still account for spend on a failed call. * * In the `'prompt'` output mode the `subtype` is the synthetic marker * `prompt_parse_failed` when, after one retry, the model's raw text still could * not be parsed + validated into a schema-conforming object. */ export declare class AgentProviderError extends Error { /** The terminal SDK result subtype, or a synthetic marker when none applies. */ readonly subtype: string; /** Cost in USD accrued before the terminal failure, for cost accounting. */ readonly costUsd: number; constructor(message: string, subtype: string, costUsd: number); } /** * Build the `'prompt'`-mode user prompt: the caller's `basePrompt`, then the * raw-JSON directive, then the stringified `schema`. PURE and OFFLINE so the * exact wording is unit-testable without `query()`. The system prompt is left * untouched (the caller's `request.system` still rides as `systemPrompt`). */ export declare function buildPromptModePrompt(basePrompt: string, schema: JsonSchema): string; /** * Extract the first balanced top-level JSON OBJECT from arbitrary model text and * `JSON.parse` it. PURE and OFFLINE so the fenced / unfenced / prose-wrapped / * malformed cases are unit-testable without `query()`: * - strips a leading ```json / ``` fence and its trailing ``` when present; * - scans for the first `{`, then walks forward tracking brace depth (ignoring * braces inside JSON strings, honoring `\`-escapes) to find the MATCHING `}`; * - `JSON.parse`s exactly that `{...}` slice. * * Throws {@link AgentProviderError} (`prompt_parse_failed`) when there is no * balanced object or the slice does not parse — the `'prompt'` path treats that * as a parse failure and retries / surfaces it. */ export declare function extractJsonObject(text: string): unknown; /** * Validate (and lightly REPAIR) a parsed prompt-mode value against `schema` with * a SMALL generic validator sufficient for our schema shape: a top-level object * with `required` keys + `properties`, where an array property's `items` is an * object with `required` (string) fields. PURE and OFFLINE so the valid / * missing-required-key / array-item-filtering cases are unit-testable. * * Behavior: * - the TOP-LEVEL value must be an object carrying every top-level `required` * key; an array-typed required property must actually be an array. If either * fails this is a hard FAILURE (returns `undefined`) — the `'prompt'` path * treats it like a parse failure and retries / surfaces it. * - within a required ARRAY property, items that fail their `items` sub-schema * are DROPPED (filtered out) rather than failing the whole value, mirroring the * downstream tolerance for a few malformed candidates. * * @returns the validated (and item-filtered) value, or `undefined` if the * top-level value is invalid. */ export declare function validateAgainstSchema(value: unknown, schema: JsonSchema): unknown;