@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
41 lines (40 loc) • 2.2 kB
TypeScript
import type { ZodUnknownSchema } from "../types/index.js";
/**
* Inline a JSON Schema by recursively resolving all $ref references.
* zodToJsonSchema with 'name' option produces schemas with $ref pointing to definitions.
* Some SDKs (like @google/genai) expect flat schemas without $ref.
*
* This function handles:
* - Top-level $ref resolution
* - Nested $ref within properties, items, additionalProperties
* - $ref within allOf, anyOf, oneOf arrays
* - Deep $ref paths like "#/definitions/Foo/properties/bar"
* - Circular reference detection to prevent infinite loops
*/
export declare function inlineJsonSchema(schema: Record<string, unknown>, definitions?: Record<string, Record<string, unknown>>, visited?: Set<string>, rootSchema?: Record<string, unknown>): Record<string, unknown>;
/**
* Recursively ensure all nested schemas have a type field.
* Google Vertex AI requires ALL schema objects (including nested properties) to have a type field.
* This function walks through the schema tree and adds type:"object" to any object-like schema
* that's missing its type field.
*/
export declare function ensureNestedSchemaTypes(schema: Record<string, unknown>): Record<string, unknown>;
/**
* Convert Zod schema to JSON Schema format for provider APIs.
*
* Handles three input types:
* 1. Zod schemas (have `_def.typeName`) -- converted via zod-to-json-schema
* 2. AI SDK `jsonSchema()` wrappers (have `.jsonSchema` property) -- extracted directly
* 3. Plain JSON Schema objects (have `type`/`properties` but no `_def`) -- returned as-is
*/
export declare function convertZodToJsonSchema(zodSchema: ZodUnknownSchema, target?: "jsonSchema7" | "openApi3"): object;
export declare function normalizeJsonSchemaObject(schema: Record<string, unknown> | undefined | null): Record<string, unknown>;
/**
* Check if a value is a Zod schema
*/
export declare function isZodSchema(value: unknown): boolean;
/**
* Convert JSON Schema to Zod schema format using official json-schema-to-zod library
* This ensures complete preservation of all schema structure and validation rules
*/
export declare function convertJsonSchemaToZod(jsonSchema: Record<string, unknown>): ZodUnknownSchema;