UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

27 lines (26 loc) • 1.38 kB
/** * Gemini function-calling schema sanitizer. * * Normalises an MCP tool's JSON Schema into the subset Gemini's function-calling * accepts. `@google/genai`'s processJsonSchema crashes on untyped nodes, * `$ref`/`$defs`, and some `anyOf`/`oneOf` shapes, so we rebuild a clean tree: * every node gets a concrete `type`, unions collapse to their first concrete * branch, and unsupported keywords are dropped. * * Pure, dependency-free, and assertion-free — values arrive as `unknown` and are * narrowed with the `isRecord` guard. Safe to reuse for any Gemini tool path. */ /** * Rebuild a JSON Schema node into the Gemini-safe subset. Returns a fresh object * with a concrete `type` on every node. */ export declare function sanitizeSchema(node: unknown): Record<string, unknown>; /** Tool parameters must be an object schema; force it and sanitize the tree. */ export declare function sanitizeToolParameters(schema: unknown): Record<string, unknown>; /** * Walk a (sanitized) schema and return the first node the google plugin would * turn into `undefined` — which genai then crashes on. Returns a human-readable * path/reason, or `null` if the schema is safe. After `sanitizeSchema` this * should always be `null`; if not, it names the exact offending path. */ export declare function findSchemaIssue(node: unknown, pathPrefix?: string): string | null;