import { type JsonSchema } from "../../json-schema/subschemas.js"; export interface FlattenOptions { /** * Writes "any JSON value" for a key some open branch leaves unconstrained. * Defaults to the bounded union the in-app providers accept. */ anyValue?: () => JsonSchema; } /** * Rewrites a root anyOf/oneOf/allOf into one object schema, because Anthropic * rejects a composed root ("input_schema does not support oneOf, allOf, or * anyOf at the top level"). The result accepts every object the original * accepts and may accept more: a key one open branch leaves unconstrained * stays unconstrained, and keywords a flat object cannot express are * dropped. That holds only when nothing below the root uses `oneOf`, `not` * or `if`: a reference back to the root reads the wider result, and under * one of those a wider subschema can reject a value the original accepted. * MCP and the in-app path run `stripUnsupportedSchemaKeywords` first, which * removes all three. * * The other exception is the default `anyValue`, which the in-app path uses. * It admits no array directly inside an array, so there a key one open * branch leaves unconstrained rejects `{ x: [[1]] }`; stripping writes the * same bound into every typeless position. Without `$ref` a schema can move * that limit deeper but never remove it, and that path has no `$ref`: * `@ai-sdk/google` drops it, the Builder gateway's OpenAI validator needs a * `type` at every position, and Gemini's OpenAPI `parameters` need `items` on * every array. MCP passes the unbounded `$ref` form instead. Callers validate * against the action's own schema, not this copy, so the bound only keeps * nested arrays out of what the model is offered. * * Local references into the removed compositions are rebased into root * `$defs` first, and a reference that does not resolve throws * `SchemaReferenceError`. A root no object satisfies throws * `UnusableSchemaError` rather than going out as any object. An empty `anyOf` * or `oneOf` is skipped here, which would widen a schema that accepts nothing, * so callers refuse one first with `assertUsableSchema`. */ export declare function flattenComposedRootSchema(schema: JsonSchema, options?: FlattenOptions): JsonSchema;