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

45 lines (44 loc) • 2.54 kB
/** * Exhaustiveness enforcement for the translation IR. * * A translation layer fails quietly: an unhandled content part or event variant * becomes a missing tool call, and the only symptom is the next hop rejecting a * request nobody can explain. `assertProxyIRExhaustive` makes that a compile * error instead. Passing a value whose type is not `never` does not type-check, * so a new IR variant breaks every `switch` that has not handled it. * * It throws at runtime as well, because the compile-time guarantee only holds for * values that really are typed. A wire payload narrowed from `unknown` can reach a * default branch at runtime, and failing loudly there beats translating a request * with a silently dropped element. */ import type { ProxyIRContentPart, ProxyIRResponseEvent, ProxyIRTerminalOutcome, ProxyIRUnmappableValue } from "../types/index.js"; /** * Refuse an unhandled IR variant. * * `context` names the switch that failed, since the value alone rarely says which * of several exhaustive switches over the same union let it through. */ export declare function assertProxyIRExhaustive(value: never, context: string): never; /** Mark a wire value no codec could represent, preserving it for the caller. */ export declare function proxyIRUnmappable(sourceKind: string, reason: string, raw: unknown): ProxyIRUnmappableValue; /** Narrow a collected codec result to the unmappable marker. */ export declare function isProxyIRUnmappable(value: unknown): value is ProxyIRUnmappableValue; /** * Name a content part for a diagnostic. * * This lives in `src` rather than in the suite that asserts on it because * `tsconfig.json` excludes `test`: an exhaustive switch written only in a test * gives no compile-time guarantee at all. These describers are the shipped * consumers that pin every union, so adding an IR variant fails `tsc --noEmit` * here before it can reach a codec that silently drops it. * * Deliberately excludes the payload of text, thinking and tool arguments: a * describer's output reaches logs and span attributes, and prompt content does * not belong there. */ export declare function describeProxyIRPart(part: ProxyIRContentPart): string; /** Name a stream event for a diagnostic, without its payload. */ export declare function describeProxyIRResponseEvent(event: ProxyIRResponseEvent): string; /** Name a terminal outcome, keeping an unmodelled upstream stop reason visible. */ export declare function describeProxyIRTerminalOutcome(outcome: ProxyIRTerminalOutcome): string;