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

31 lines (30 loc) • 1.45 kB
/** * Structured-output recovery ladder for the isolated-agent runner. * * Ports the production-hardened pattern the framework's consumers built by * hand: candidates are tried in a fixed order — provider `structuredData` → * raw JSON object → ```json fence → first/last-brace span → top-level array — * each passed through the caller's `coerce` normalizer and validated against * the (lenient) local schema. The first schema-valid candidate wins; * validation errors are collected for corrective re-asks. */ import type { z } from "zod"; import type { StructuredRecoveryCandidate, StructuredRecoveryResult } from "../types/index.js"; /** * Collect parse candidates from model text (and provider structuredData) in * ladder order. Never throws. */ export declare function collectStructuredCandidates(content: string | undefined, structuredData?: unknown): StructuredRecoveryCandidate[]; /** * Run the full ladder: candidates (through `coerce`) validated against * `schema`; first success wins. Never throws — coerce/validation failures * become entries in `errors`. */ export declare function recoverStructuredData(args: { content: string | undefined; structuredData?: unknown; schema: z.ZodSchema; coerce?: (candidate: unknown) => unknown; }): StructuredRecoveryResult; /** Bounded, prompt-friendly summary of a Zod validation error. */ export declare function summarizeZodError(error: z.ZodError): string;