/** * zod → {@link JsonSchema} conversion, normalized to the shape our * {@link isSchemaSubset} algorithm accepts. * * **Why zod's built-in vs. the `zod-to-json-schema` package.** That * library only understands zod v3 internals — passing a zod v4 schema * yields an empty `{$schema}` document. The protocol package is on * zod v4, which ships its own built-in `z.toJSONSchema()` helper that * produces correct JSON Schema output for every construct we care * about. The wrapper below normalizes the v4 output — draft-2020-12 * by default, plus a small handful of zod-specific quirks — onto the * {@link JsonSchema} shape the subset algorithm consumes. * * **Normalizations applied.** * * 1. Strip the top-level `$schema` URI. Our {@link JsonSchema} does * not carry it, and the subset algorithm's "unsupported * constructs" flagging would treat unknown top-level keys as * surprises. `$schema` is metadata, not structure. * 2. Preserve draft-2020-12 `additionalProperties: {}` (zod emits * this for `.passthrough()`) as `additionalProperties: {}` — * the subset algorithm treats the empty-schema case as a * structured-but-unconstrained extras slot. Callers that want * "strictly true" must convert explicitly. * 3. Leave `anyOf` / `const` / `enum` shapes intact. The subset * algorithm flags them as P1/P2 deferred constructs — the * caller receives an honest `unsupported` violation rather * than a silent pass. * 4. `z.any()` / `z.unknown()` produce an empty schema (no keys). * The subset algorithm treats an empty schema as a wildcard * (matches `isSchemaSubset(..., {type: 'string'})` as * compatible), which mirrors JSON Schema semantics. * * **Intended call sites.** * * - render-time + blueprint-registration schema-compat checks in * `@ggui-ai/mcp-server`: a mount-registered tool handler exposes * its `inputSchema` as a {@link ZodRawShape}; wrapping it in * `z.object(shape)` and converting gives the JsonSchema that * pairs against the declared `actionSpec[name].schema`. * - Ad-hoc authoring tools (e.g. console panels) that need a * human-readable JSON shape for a zod definition. * * @see ./schema-subset.ts */ import { type ZodRawShape, type ZodType } from 'zod'; import type { JsonSchema } from '../types/data-contract.js'; /** * Convert a zod schema (or raw shape) to a {@link JsonSchema} suitable * for the subset algorithm. * * - Pass a `ZodType` to convert it directly. * - Pass a {@link ZodRawShape} (the raw `{ key: ZodType, ... }` map * shape {@link SharedHandler.inputSchema} carries) to have it * wrapped in `z.object(...)` before conversion. * * Never throws on legitimate input. If zod's native emitter returns * a non-object (it shouldn't for any supported construct), we coerce * to an empty schema `{}` so downstream comparison treats it as * unconstrained. */ export declare function zodToJsonSchema(input: ZodType | ZodRawShape): JsonSchema; //# sourceMappingURL=zod-to-json-schema.d.ts.map