/** * Compute the wire (JSON Schema) representation of a tool's parameters and * convert TypeBox-style schemas into Zod for internal validation. * * Tools may author parameters in two shapes: * 1. Zod (canonical going forward) — converted to JSON Schema on demand. * 2. TypeBox / plain JSON Schema (legacy + extension compat) — upgraded to * draft 2020-12 without converting through Zod. * * Both are normalized at the boundary so providers and validators see the same * JSON Schema dialect. */ import { type ZodType } from "zod/v4"; import type { Tool } from "../../types"; /** * True when `value` is a live Zod schema instance. * * The check is stricter than "has a `_zod` property" because a JSON * round-trip preserves the `_zod` key as a plain object and would otherwise * fool the predicate — see issue #1101, where MCP servers ship * `JSON.stringify(zodSchemaInstance)` as a tool's `inputSchema` and the * resulting plain object then explodes `z.toJSONSchema` because the prototype * (and every Zod parsing method) is gone. * * Live Zod instances always carry a `.parse` function on the prototype; * impostors do not. */ export declare function isZodSchema(value: unknown): value is ZodType; /** * Normalize `{}` (empty JSON Schema = `z.unknown()` / unconstrained value) to * boolean `true` in every schema-valued position. JSON Schema draft 2020-12 * §4.3.1: `{}` and `true` are semantically equivalent ("any JSON value"). * Grammar-constrained samplers (llama.cpp, etc.) treat the object form as * "generate an empty object" rather than "any JSON value", causing open-typed * fields like `extra.title` (from `z.record(z.string(), z.unknown())`) to * always emit `{}` instead of the intended string/number/etc. (issue #1179). * * Mutates in place. Provider-agnostic — applied to every tool wire schema so * Anthropic, Google, OpenAI, Ollama, Bedrock, and Cursor all see the * normalized form, regardless of whether the source was Zod or TypeBox. */ export declare function normalizeEmptySchemas(node: unknown): void; /** Convert a Zod schema into the JSON Schema shape providers consume. */ export declare function zodToWireSchema(schema: ZodType): Record; /** * Resolve a tool's parameters to a JSON Schema object suitable for sending * over the wire. Zod schemas are converted (and cached); legacy TypeBox / raw * JSON Schema parameters are upgraded to draft 2020-12 (and cached). * * Both branches finish with `normalizeEmptySchemas` so every provider — * OpenAI, Anthropic, Google, Ollama, Bedrock, Cursor — sees `{}` normalized * to `true` in schema-valued positions (issue #1179). */ export declare function toolWireSchema(tool: Tool): Record;