import { Command, Interrupt } from "./constants.js"; //#region src/errors.d.ts type BaseLangGraphErrorFields = { lc_error_code?: "GRAPH_RECURSION_LIMIT" | "INVALID_CONCURRENT_GRAPH_UPDATE" | "INVALID_GRAPH_NODE_RETURN_VALUE" | "MISSING_CHECKPOINTER" | "MULTIPLE_SUBGRAPHS" | "UNREACHABLE_NODE"; }; /** @category Errors */ declare class BaseLangGraphError extends Error { lc_error_code?: string; constructor(message?: string, fields?: BaseLangGraphErrorFields); } declare class GraphBubbleUp extends BaseLangGraphError { get is_bubble_up(): boolean; } declare class GraphRecursionError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare class GraphValueError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** * Raised when a graph run exits early due to a drain request. * * This indicates the graph stopped cooperatively at a superstep boundary * because {@link RunControl#requestDrain} was called (e.g., in response to * SIGTERM). The checkpoint is saved and the run can be resumed later. */ declare class GraphDrained extends GraphBubbleUp { reason: string; constructor(reason?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare function isGraphDrained(e?: unknown): e is GraphDrained; declare class GraphInterrupt extends GraphBubbleUp { interrupts: Interrupt[]; constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** Raised by a node to interrupt execution. */ declare class NodeInterrupt extends GraphInterrupt { constructor(message: any, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** * Failure context passed to a node-level error handler. * * A node-level error handler is registered via * `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after * the failing node's {@link RetryPolicy} is exhausted, so retry and handling * stay decoupled. The handler receives the failed node's name and the thrown * error via a `NodeError` instance, can return a state update, and can route to * a recovery branch via `new Command({ goto })` (saga / compensation flows). * * @example * ```ts * import { NodeError } from "@langchain/langgraph"; * * function handler(state: State, error: NodeError) { * return new Command({ * update: { status: `recovered from ${error.node}: ${error.error.message}` }, * goto: "finalize", * }); * } * ``` */ declare class NodeError { /** Name of the node whose execution failed. */ node: string; /** Error thrown by the failed node. */ error: Error; constructor(node: string, error: Error); static get unminifiable_name(): string; } /** * Type guard that checks whether a value is a {@link NodeError}. */ declare function isNodeError(e?: unknown): e is NodeError; declare class ParentCommand extends GraphBubbleUp { command: Command; constructor(command: Command); static get unminifiable_name(): string; } declare function isParentCommand(e?: unknown): e is ParentCommand; declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp; declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt; /** * Raised when a node invocation exceeds one of its configured timeouts. * * Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node * error path) and is intentionally treated as retryable by the default retry * policy — its message/name do not match the default `retryOn` blocklist, so a * configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659). * * Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout} * reflect the configured policy at the time of the failure (each `undefined` if * not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout} * identify which one fired. * * @category Errors */ declare class NodeTimeoutError extends BaseLangGraphError { /** Name of the node/task that timed out. */ node: string; /** Which timeout fired: a hard `"run"` cap or a progress-resetting `"idle"` cap. */ kind: "run" | "idle"; /** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */ timeout: number; /** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */ elapsed: number; /** Configured run timeout (ms), if any. */ runTimeout?: number; /** Configured idle timeout (ms), if any. */ idleTimeout?: number; constructor(fields: { node: string; elapsed: number; kind: "run" | "idle"; runTimeout?: number; idleTimeout?: number; }, errorFields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare function isNodeTimeoutError(e?: unknown): e is NodeTimeoutError; declare class EmptyInputError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare class EmptyChannelError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare class InvalidUpdateError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** * @deprecated This exception type is no longer thrown. */ declare class MultipleSubgraphsError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } declare class UnreachableNodeError extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** * Exception raised when an error occurs in the remote graph. */ declare class RemoteException extends BaseLangGraphError { constructor(message?: string, fields?: BaseLangGraphErrorFields); static get unminifiable_name(): string; } /** * Error thrown when invalid input is provided to a StateGraph. * * This typically means that the input to the StateGraph constructor or builder * did not match the required types. A valid input should be a * StateDefinition, an Annotation.Root, or a Zod schema. * * @example * // Example of incorrect usage: * try { * new StateGraph({ foo: "bar" }); // Not a valid input * } catch (err) { * if (err instanceof StateGraphInputError) { * console.error(err.message); * } * } */ declare class StateGraphInputError extends BaseLangGraphError { /** * Create a new StateGraphInputError. * @param message - Optional custom error message. * @param fields - Optional additional error fields. */ constructor(message?: string, fields?: BaseLangGraphErrorFields); /** * The unminifiable (static, human-readable) error name for this error class. */ static get unminifiable_name(): string; } /** * Used for subgraph detection. */ declare const getSubgraphsSeenSet: () => any; //#endregion export { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand }; //# sourceMappingURL=errors.d.ts.map