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

77 lines (76 loc) • 2.27 kB
import type { NeuroLinkMiddleware, MiddlewareConfig, MiddlewareContext, MiddlewareRegistrationOptions, MiddlewareExecutionResult } from "../types/index.js"; import type { LanguageModelMiddleware } from "../types/index.js"; /** * Manages the registration, configuration, and execution of middleware for a single factory instance. */ export declare class MiddlewareRegistry { private middleware; private globalConfigs; private executionStats; /** * Register a middleware */ register(middleware: NeuroLinkMiddleware, options?: MiddlewareRegistrationOptions): void; /** * Unregister a middleware */ unregister(middlewareId: string): boolean; /** * Get a registered middleware */ get(middlewareId: string): NeuroLinkMiddleware | undefined; /** * List all registered middleware */ list(): NeuroLinkMiddleware[]; /** * Get middleware IDs sorted by priority */ getSortedIds(): string[]; /** * Build middleware chain based on configuration */ buildChain(context: MiddlewareContext, config?: Record<string, MiddlewareConfig>): LanguageModelMiddleware[]; /** * Determine if middleware should be applied based on conditions */ private shouldApplyMiddleware; /** * Configure middleware with runtime configuration */ private configureMiddleware; /** * Record middleware execution statistics */ private recordExecution; /** * Get execution statistics for a middleware */ getExecutionStats(middlewareId: string): MiddlewareExecutionResult[]; /** * Get aggregated statistics for all middleware */ getAggregatedStats(): Record<string, { totalExecutions: number; successfulExecutions: number; failedExecutions: number; averageExecutionTime: number; lastExecutionTime: number; }>; /** * Clear execution statistics */ clearStats(middlewareId?: string): void; /** * Check if a middleware is registered */ has(middlewareId: string): boolean; /** * Get the number of registered middleware */ size(): number; /** * Clear all registered middleware */ clear(): void; }