@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
74 lines (73 loc) • 2.4 kB
TypeScript
/**
* TripwireEvaluator - Standalone health-check utility
*
* Evaluates blocking conditions against LLM response data to detect
* runtime issues such as empty responses, high latency, max tokens hit,
* and repetition loops.
*
* This module has no dependency on the processor pipeline system and can
* be used independently.
*
* @module utils/tripwireEvaluator
*/
import type { TripwireData, TripwireConfig, TripwireResult } from "../types/index.js";
/**
* Manages and evaluates tripwire conditions against LLM response data.
*
* @example
* ```typescript
* const evaluator = createDefaultTripwireEvaluator();
*
* const result = evaluator.evaluate({
* responseText: "",
* latencyMs: 45000,
* finishReason: "length",
* });
*
* if (result.triggered && result.action === "abort") {
* throw new Error(result.message);
* }
* ```
*/
export declare class TripwireEvaluator {
private tripwires;
/**
* Register a tripwire. Replaces any existing tripwire with the same id.
*/
register(tripwire: TripwireConfig): void;
/**
* Remove a registered tripwire by id.
* @returns true if the tripwire was found and removed, false otherwise.
*/
unregister(id: string): boolean;
/**
* Evaluate all tripwires and return the highest-priority triggered result.
*
* Priority order: "abort" > "warn" > "log"
*
* Bug fix (C1): The original implementation returned on the FIRST triggered
* tripwire regardless of action, which meant a "warn" registered before an
* "abort" would mask the abort. This implementation evaluates ALL tripwires
* and promotes the highest-severity action.
*/
evaluate(data: TripwireData): TripwireResult;
/**
* Evaluate all tripwires and return every triggered result.
*/
evaluateAll(data: TripwireData): TripwireResult[];
/**
* Return a shallow copy of all registered tripwires.
*/
getTripwires(): TripwireConfig[];
}
/**
* All built-in tripwires in default registration order.
*
* Registration order does not affect priority — `evaluate()` always promotes
* the highest-severity action ("abort" > "warn" > "log").
*/
export declare const commonTripwires: TripwireConfig[];
/**
* Create a TripwireEvaluator pre-loaded with all built-in tripwires.
*/
export declare function createDefaultTripwireEvaluator(): TripwireEvaluator;