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

83 lines (82 loc) • 3.15 kB
/** * Error classes surfaced by the generation pipeline. * * These used to be re-exported from the `ai` package. They are now declared * here, because every path that threw them upstream is gone: generation is * native end to end, and the only one this repo still constructs is * NoOutputGeneratedError. * * The marker symbols are deliberately identical to the upstream ones * (`Symbol.for("vercel.ai.error.<name>")`). `isInstance` is a marker check, not * an `instanceof`, precisely so it survives across duplicate module copies — * and keeping the same symbol means an error raised by any remaining upstream * code is still recognised by these classes, and vice versa. Switching to a * private symbol would have silently broken that recognition at exactly the * points that matter: retry classification and the no-output sentinel. */ /** Base for the generation errors; stamps the upstream-compatible marker. */ declare class GenerationError extends Error { readonly cause?: unknown; constructor(markerName: string, message: string, cause?: unknown); } export declare class NoOutputGeneratedError extends GenerationError { constructor(options?: { message?: string; cause?: unknown; }); static isInstance(error: unknown): error is NoOutputGeneratedError; } export declare class NoObjectGeneratedError extends GenerationError { readonly text?: string; readonly finishReason?: string; constructor(options?: { message?: string; cause?: unknown; text?: string; finishReason?: string; }); static isInstance(error: unknown): error is NoObjectGeneratedError; } export declare class NoSuchToolError extends GenerationError { readonly toolName?: string; constructor(options?: { message?: string; toolName?: string; }); static isInstance(error: unknown): error is NoSuchToolError; } export declare class InvalidToolInputError extends GenerationError { readonly toolName?: string; constructor(options?: { message?: string; toolName?: string; cause?: unknown; }); static isInstance(error: unknown): error is InvalidToolInputError; } /** * Transport-level failure. This repo only ever CATCHES and classifies these — * `providerRetry` and the error classifier duck-type `.statusCode` — so the * class exists to keep those `isInstance` checks working for errors raised by * the provider clients, which stamp the same marker. */ export declare class APICallError extends GenerationError { readonly url?: string; readonly statusCode?: number; readonly responseBody?: string; readonly responseHeaders?: Record<string, string>; readonly isRetryable: boolean; readonly requestBodyValues?: unknown; constructor(options?: { message?: string; url?: string; statusCode?: number; responseBody?: string; responseHeaders?: Record<string, string>; isRetryable?: boolean; requestBodyValues?: unknown; cause?: unknown; }); static isInstance(error: unknown): error is APICallError; } export {};