@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
55 lines (54 loc) • 1.64 kB
JavaScript
/**
* HITL (Human-in-the-Loop) Error Classes
*
* Provides structured error handling for HITL safety mechanisms.
* These errors allow applications to distinguish between different
* types of HITL failures and handle them appropriately.
*/
/**
* Base class for all HITL-related errors
*/
export class HITLError extends Error {
confirmationId;
constructor(message, confirmationId) {
super(message);
this.confirmationId = confirmationId;
this.name = "HITLError";
}
}
/**
* Thrown when a user explicitly rejects a tool execution request
* This indicates the HITL system worked correctly - the user saw the request
* and made a conscious decision to deny it.
*/
export class HITLUserRejectedError extends HITLError {
toolName;
reason;
constructor(message, toolName, reason, confirmationId) {
super(message, confirmationId);
this.toolName = toolName;
this.reason = reason;
this.name = "HITLUserRejectedError";
}
}
/**
* Thrown when a confirmation request times out without user response
* This indicates the user didn't respond within the configured timeout period.
*/
export class HITLTimeoutError extends HITLError {
timeout;
constructor(message, confirmationId, timeout) {
super(message, confirmationId);
this.timeout = timeout;
this.name = "HITLTimeoutError";
}
}
/**
* Thrown when HITL configuration is invalid or missing required properties
*/
export class HITLConfigurationError extends HITLError {
constructor(message) {
super(message);
this.name = "HITLConfigurationError";
}
}