import { z } from 'zod'; import type { JSONSchema } from 'zod/v4/core'; /** * JSON Schema → zod for the generated MCP tool inputs. * * The generator (`packages/app/scripts/mcp-tools-gen.ts`) inlines `$ref`s it * walks through `properties`/`items`, but it does NOT recurse into `allOf` / * `anyOf` / `oneOf`. So a schema composed with `allOf` (for example, * `RequestSelectionTemplate = * allOf[ RequestSelection, { multiple, required } ]`, * surfaced by the proof tools' `allowedJsRequests`) can carry a dangling * `#/components/schemas/…` `$ref` that points outside the standalone schema * object handed to `z.fromJSONSchema`. zod then throws `Reference not found` * at module-load time, taking down every tool. * * We pre-process here (rather than hand-editing the generated file, which * regen would clobber): flatten `allOf` compositions into a single object * schema and neutralize any remaining unresolvable `#/components/schemas/…` * `$ref` to a permissive `{}`. The schemas affected are deep proof-tool inputs * the model rarely hand-builds, so loosening leaf validation there is * acceptable; the common tool inputs (uuids, version patterns, contexts) keep * their full constraints. */ export declare function toZod(schema: JSONSchema.Schema): z.ZodType>;