//#region src/utils/json-schema-walk.d.ts /** * Generic, reusable JSON Schema walker. * * Turns a JSON Schema into a normalized, `$ref`-resolved, cycle-safe tree of nodes * that callers can render or introspect without re-implementing ref resolution, * nullability unwrapping, or recursion guards. Format-specific emitting (XML, etc.) * is left to the caller. * * Handles the shapes Pydantic-style MCP tool schemas produce: `$ref`/`$defs`, * nested objects, array `items`, `anyOf`/`oneOf` nullables (`anyOf [t, null]` and * `type: [t, "null"]`), and `enum`/`const`. */ interface NormalizedSchemaNode { /** Property name (or `"item"` for an array element). */ name: string; /** Resolved JSON Schema type (non-null branch of a nullable), defaults to `string`. */ type: string; required: boolean; nullable: boolean; description?: string; enumValues?: unknown[]; /** Present for object nodes. */ properties?: NormalizedSchemaNode[]; /** Present for array nodes. */ items?: NormalizedSchemaNode; /** Present for multi-branch unions (`anyOf`/`oneOf` with more than one non-null branch). */ variants?: NormalizedSchemaNode[]; /** Set when a `$ref` cycle or the depth cap stopped the walk at this node. */ recursive?: boolean; } interface WalkJsonSchemaOptions { /** Backstop against pathological/cyclic schemas. Defaults to 12. */ maxDepth?: number; } /** * Normalize a schema's top-level `properties` into ref-resolved, cycle-safe nodes. * `$defs`/`definitions` and `$ref: "#"` are resolved against the passed schema root. */ declare function normalizeJsonSchemaProperties(schema: any, options?: WalkJsonSchemaOptions): NormalizedSchemaNode[]; /** * Unwrap an AI SDK `jsonSchema()` wrapper (`{ jsonSchema, validate, _type }`) to the * underlying JSON Schema. The MCP ingestion fallback wraps a raw schema this way; without * unwrapping, downstream readers (provider tool def, prompt renderer, manage UI) see the * wrapper's top-level keys instead of the real `properties`/`$defs`. A non-wrapper value * (plain JSON Schema, or a Zod schema, which has no `jsonSchema` property) passes through. */ declare function unwrapJsonSchemaWrapper(value: T): T | Record; //#endregion export { NormalizedSchemaNode, WalkJsonSchemaOptions, normalizeJsonSchemaProperties, unwrapJsonSchemaWrapper };