@langchain/langgraph 1.3.6 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels/base.cjs +78 -2
- package/dist/channels/base.cjs.map +1 -1
- package/dist/channels/base.d.cts +35 -2
- package/dist/channels/base.d.cts.map +1 -1
- package/dist/channels/base.d.ts +35 -2
- package/dist/channels/base.d.ts.map +1 -1
- package/dist/channels/base.js +77 -4
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/delta.cjs +136 -0
- package/dist/channels/delta.cjs.map +1 -0
- package/dist/channels/delta.d.cts +99 -0
- package/dist/channels/delta.d.cts.map +1 -0
- package/dist/channels/delta.d.ts +99 -0
- package/dist/channels/delta.d.ts.map +1 -0
- package/dist/channels/delta.js +136 -0
- package/dist/channels/delta.js.map +1 -0
- package/dist/channels/index.cjs +5 -0
- package/dist/channels/index.d.cts +3 -2
- package/dist/channels/index.d.ts +3 -2
- package/dist/channels/index.js +3 -2
- package/dist/constants.cjs +62 -4
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +33 -2
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +33 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +59 -5
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +128 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +86 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts +86 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +123 -1
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +9 -2
- package/dist/func/index.cjs.map +1 -1
- package/dist/func/index.d.cts +14 -0
- package/dist/func/index.d.cts.map +1 -1
- package/dist/func/index.d.ts +14 -0
- package/dist/func/index.d.ts.map +1 -1
- package/dist/func/index.js +9 -2
- package/dist/func/index.js.map +1 -1
- package/dist/graph/graph.cjs +44 -7
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.d.cts +24 -2
- package/dist/graph/graph.d.cts.map +1 -1
- package/dist/graph/graph.d.ts +24 -2
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +44 -7
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/messages_reducer.cjs +55 -0
- package/dist/graph/messages_reducer.cjs.map +1 -1
- package/dist/graph/messages_reducer.d.cts +28 -1
- package/dist/graph/messages_reducer.d.cts.map +1 -1
- package/dist/graph/messages_reducer.d.ts +28 -1
- package/dist/graph/messages_reducer.d.ts.map +1 -1
- package/dist/graph/messages_reducer.js +56 -2
- package/dist/graph/messages_reducer.js.map +1 -1
- package/dist/graph/state.cjs +174 -7
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.d.cts +193 -17
- package/dist/graph/state.d.cts.map +1 -1
- package/dist/graph/state.d.ts +193 -17
- package/dist/graph/state.d.ts.map +1 -1
- package/dist/graph/state.js +175 -8
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/zod/schema.cjs +5 -0
- package/dist/graph/zod/schema.cjs.map +1 -1
- package/dist/graph/zod/schema.d.cts.map +1 -1
- package/dist/graph/zod/schema.d.ts.map +1 -1
- package/dist/graph/zod/schema.js +5 -0
- package/dist/graph/zod/schema.js.map +1 -1
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts +1 -1
- package/dist/pregel/algo.cjs +182 -21
- package/dist/pregel/algo.cjs.map +1 -1
- package/dist/pregel/algo.d.cts +1 -1
- package/dist/pregel/algo.d.cts.map +1 -1
- package/dist/pregel/algo.d.ts +1 -1
- package/dist/pregel/algo.d.ts.map +1 -1
- package/dist/pregel/algo.js +185 -25
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/call.cjs +2 -1
- package/dist/pregel/call.cjs.map +1 -1
- package/dist/pregel/call.js +2 -1
- package/dist/pregel/call.js.map +1 -1
- package/dist/pregel/index.cjs +15 -3
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +17 -5
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/loop.cjs +362 -41
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +365 -44
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages-v2.cjs +1 -1
- package/dist/pregel/messages-v2.js +1 -1
- package/dist/pregel/messages.cjs +1 -1
- package/dist/pregel/messages.js +1 -1
- package/dist/pregel/read.cjs +15 -5
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.cts +9 -0
- package/dist/pregel/read.d.cts.map +1 -1
- package/dist/pregel/read.d.ts +9 -0
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js +15 -5
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote-run-stream.cjs +107 -0
- package/dist/pregel/remote-run-stream.cjs.map +1 -0
- package/dist/pregel/remote-run-stream.d.cts +33 -0
- package/dist/pregel/remote-run-stream.d.cts.map +1 -0
- package/dist/pregel/remote-run-stream.d.ts +33 -0
- package/dist/pregel/remote-run-stream.d.ts.map +1 -0
- package/dist/pregel/remote-run-stream.js +107 -0
- package/dist/pregel/remote-run-stream.js.map +1 -0
- package/dist/pregel/remote.cjs +61 -1
- package/dist/pregel/remote.cjs.map +1 -1
- package/dist/pregel/remote.d.cts +17 -0
- package/dist/pregel/remote.d.cts.map +1 -1
- package/dist/pregel/remote.d.ts +17 -0
- package/dist/pregel/remote.d.ts.map +1 -1
- package/dist/pregel/remote.js +61 -1
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/replay.cjs +62 -0
- package/dist/pregel/replay.cjs.map +1 -0
- package/dist/pregel/replay.js +62 -0
- package/dist/pregel/replay.js.map +1 -0
- package/dist/pregel/retry.cjs +8 -6
- package/dist/pregel/retry.cjs.map +1 -1
- package/dist/pregel/retry.js +8 -6
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runnable_types.d.cts +20 -0
- package/dist/pregel/runnable_types.d.cts.map +1 -1
- package/dist/pregel/runnable_types.d.ts +20 -0
- package/dist/pregel/runnable_types.d.ts.map +1 -1
- package/dist/pregel/runner.cjs +48 -7
- package/dist/pregel/runner.cjs.map +1 -1
- package/dist/pregel/runner.js +50 -9
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/runtime.cjs +64 -0
- package/dist/pregel/runtime.cjs.map +1 -0
- package/dist/pregel/runtime.d.cts +57 -0
- package/dist/pregel/runtime.d.cts.map +1 -0
- package/dist/pregel/runtime.d.ts +57 -0
- package/dist/pregel/runtime.d.ts.map +1 -0
- package/dist/pregel/runtime.js +64 -0
- package/dist/pregel/runtime.js.map +1 -0
- package/dist/pregel/stream.cjs +2 -0
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.js +2 -0
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/timeout.cjs +216 -0
- package/dist/pregel/timeout.cjs.map +1 -0
- package/dist/pregel/timeout.js +216 -0
- package/dist/pregel/timeout.js.map +1 -0
- package/dist/pregel/types.cjs +3 -1
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.d.cts +13 -0
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts +14 -1
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/types.js +3 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/utils/config.cjs +3 -1
- package/dist/pregel/utils/config.cjs.map +1 -1
- package/dist/pregel/utils/config.d.cts.map +1 -1
- package/dist/pregel/utils/config.d.ts.map +1 -1
- package/dist/pregel/utils/config.js +3 -1
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +1 -0
- package/dist/pregel/utils/index.cjs.map +1 -1
- package/dist/pregel/utils/index.d.cts +6 -1
- package/dist/pregel/utils/index.d.cts.map +1 -1
- package/dist/pregel/utils/index.d.ts +6 -1
- package/dist/pregel/utils/index.d.ts.map +1 -1
- package/dist/pregel/utils/index.js +1 -0
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/pregel/utils/timeout.cjs +34 -0
- package/dist/pregel/utils/timeout.cjs.map +1 -0
- package/dist/pregel/utils/timeout.d.cts +45 -0
- package/dist/pregel/utils/timeout.d.cts.map +1 -0
- package/dist/pregel/utils/timeout.d.ts +45 -0
- package/dist/pregel/utils/timeout.d.ts.map +1 -0
- package/dist/pregel/utils/timeout.js +34 -0
- package/dist/pregel/utils/timeout.js.map +1 -0
- package/dist/stream/index.cjs +1 -0
- package/dist/stream/index.d.cts +2 -1
- package/dist/stream/index.d.ts +2 -1
- package/dist/stream/index.js +1 -0
- package/dist/stream/stream-channel.d.cts +9 -1
- package/dist/stream/stream-channel.d.cts.map +1 -1
- package/dist/stream/stream-channel.d.ts +9 -1
- package/dist/stream/stream-channel.d.ts.map +1 -1
- package/dist/stream/subscription.cjs +136 -0
- package/dist/stream/subscription.cjs.map +1 -0
- package/dist/stream/subscription.d.cts +94 -0
- package/dist/stream/subscription.d.cts.map +1 -0
- package/dist/stream/subscription.d.ts +94 -0
- package/dist/stream/subscription.d.ts.map +1 -0
- package/dist/stream/subscription.js +131 -0
- package/dist/stream/subscription.js.map +1 -0
- package/dist/stream/types.d.cts +1 -1
- package/dist/stream/types.d.ts +1 -1
- package/dist/stream.cjs +16 -0
- package/dist/stream.d.cts +5 -0
- package/dist/stream.d.ts +5 -0
- package/dist/stream.js +4 -0
- package/dist/web.cjs +11 -0
- package/dist/web.d.cts +11 -8
- package/dist/web.d.ts +11 -8
- package/dist/web.js +5 -3
- package/package.json +18 -6
package/dist/errors.cjs
CHANGED
|
@@ -32,6 +32,27 @@ var GraphValueError = class extends BaseLangGraphError {
|
|
|
32
32
|
return "GraphValueError";
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Raised when a graph run exits early due to a drain request.
|
|
37
|
+
*
|
|
38
|
+
* This indicates the graph stopped cooperatively at a superstep boundary
|
|
39
|
+
* because {@link RunControl#requestDrain} was called (e.g., in response to
|
|
40
|
+
* SIGTERM). The checkpoint is saved and the run can be resumed later.
|
|
41
|
+
*/
|
|
42
|
+
var GraphDrained = class extends GraphBubbleUp {
|
|
43
|
+
reason;
|
|
44
|
+
constructor(reason = "shutdown", fields) {
|
|
45
|
+
super(`Graph drained: ${reason}`, fields);
|
|
46
|
+
this.name = "GraphDrained";
|
|
47
|
+
this.reason = reason;
|
|
48
|
+
}
|
|
49
|
+
static get unminifiable_name() {
|
|
50
|
+
return "GraphDrained";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function isGraphDrained(e) {
|
|
54
|
+
return e !== void 0 && e.name === GraphDrained.unminifiable_name;
|
|
55
|
+
}
|
|
35
56
|
var GraphInterrupt = class extends GraphBubbleUp {
|
|
36
57
|
interrupts;
|
|
37
58
|
constructor(interrupts, fields) {
|
|
@@ -53,6 +74,47 @@ var NodeInterrupt = class extends GraphInterrupt {
|
|
|
53
74
|
return "NodeInterrupt";
|
|
54
75
|
}
|
|
55
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Failure context passed to a node-level error handler.
|
|
79
|
+
*
|
|
80
|
+
* A node-level error handler is registered via
|
|
81
|
+
* `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after
|
|
82
|
+
* the failing node's {@link RetryPolicy} is exhausted, so retry and handling
|
|
83
|
+
* stay decoupled. The handler receives the failed node's name and the thrown
|
|
84
|
+
* error via a `NodeError` instance, can return a state update, and can route to
|
|
85
|
+
* a recovery branch via `new Command({ goto })` (saga / compensation flows).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { NodeError } from "@langchain/langgraph";
|
|
90
|
+
*
|
|
91
|
+
* function handler(state: State, error: NodeError) {
|
|
92
|
+
* return new Command({
|
|
93
|
+
* update: { status: `recovered from ${error.node}: ${error.error.message}` },
|
|
94
|
+
* goto: "finalize",
|
|
95
|
+
* });
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
var NodeError = class {
|
|
100
|
+
/** Name of the node whose execution failed. */
|
|
101
|
+
node;
|
|
102
|
+
/** Error thrown by the failed node. */
|
|
103
|
+
error;
|
|
104
|
+
constructor(node, error) {
|
|
105
|
+
this.node = node;
|
|
106
|
+
this.error = error;
|
|
107
|
+
}
|
|
108
|
+
static get unminifiable_name() {
|
|
109
|
+
return "NodeError";
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Type guard that checks whether a value is a {@link NodeError}.
|
|
114
|
+
*/
|
|
115
|
+
function isNodeError(e) {
|
|
116
|
+
return e != null && typeof e === "object" && e.constructor != null && e.constructor.unminifiable_name === NodeError.unminifiable_name;
|
|
117
|
+
}
|
|
56
118
|
var ParentCommand = class extends GraphBubbleUp {
|
|
57
119
|
command;
|
|
58
120
|
constructor(command) {
|
|
@@ -73,6 +135,63 @@ function isGraphBubbleUp(e) {
|
|
|
73
135
|
function isGraphInterrupt(e) {
|
|
74
136
|
return e !== void 0 && [GraphInterrupt.unminifiable_name, NodeInterrupt.unminifiable_name].includes(e.name);
|
|
75
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Raised when a node invocation exceeds one of its configured timeouts.
|
|
140
|
+
*
|
|
141
|
+
* Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node
|
|
142
|
+
* error path) and is intentionally treated as retryable by the default retry
|
|
143
|
+
* policy — its message/name do not match the default `retryOn` blocklist, so a
|
|
144
|
+
* configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659).
|
|
145
|
+
*
|
|
146
|
+
* Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout}
|
|
147
|
+
* reflect the configured policy at the time of the failure (each `undefined` if
|
|
148
|
+
* not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout}
|
|
149
|
+
* identify which one fired.
|
|
150
|
+
*
|
|
151
|
+
* @category Errors
|
|
152
|
+
*/
|
|
153
|
+
var NodeTimeoutError = class extends BaseLangGraphError {
|
|
154
|
+
/** Name of the node/task that timed out. */
|
|
155
|
+
node;
|
|
156
|
+
/** Which timeout fired: a hard `"run"` cap or a progress-resetting `"idle"` cap. */
|
|
157
|
+
kind;
|
|
158
|
+
/** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */
|
|
159
|
+
timeout;
|
|
160
|
+
/** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */
|
|
161
|
+
elapsed;
|
|
162
|
+
/** Configured run timeout (ms), if any. */
|
|
163
|
+
runTimeout;
|
|
164
|
+
/** Configured idle timeout (ms), if any. */
|
|
165
|
+
idleTimeout;
|
|
166
|
+
constructor(fields, errorFields) {
|
|
167
|
+
const { node, elapsed, kind, runTimeout, idleTimeout } = fields;
|
|
168
|
+
let message;
|
|
169
|
+
let timeout;
|
|
170
|
+
if (kind === "idle") {
|
|
171
|
+
if (idleTimeout === void 0) throw new Error("idleTimeout is required when kind='idle'");
|
|
172
|
+
timeout = idleTimeout;
|
|
173
|
+
message = `Node "${node}" exceeded its idle timeout of ${idleTimeout}ms without making progress (elapsed: ${elapsed}ms).`;
|
|
174
|
+
} else {
|
|
175
|
+
if (runTimeout === void 0) throw new Error("runTimeout is required when kind='run'");
|
|
176
|
+
timeout = runTimeout;
|
|
177
|
+
message = `Node "${node}" exceeded its run timeout of ${runTimeout}ms (elapsed: ${elapsed}ms).`;
|
|
178
|
+
}
|
|
179
|
+
super(message, errorFields);
|
|
180
|
+
this.name = "NodeTimeoutError";
|
|
181
|
+
this.node = node;
|
|
182
|
+
this.kind = kind;
|
|
183
|
+
this.timeout = timeout;
|
|
184
|
+
this.elapsed = elapsed;
|
|
185
|
+
this.runTimeout = runTimeout;
|
|
186
|
+
this.idleTimeout = idleTimeout;
|
|
187
|
+
}
|
|
188
|
+
static get unminifiable_name() {
|
|
189
|
+
return "NodeTimeoutError";
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
function isNodeTimeoutError(e) {
|
|
193
|
+
return e !== void 0 && e.name === NodeTimeoutError.unminifiable_name;
|
|
194
|
+
}
|
|
76
195
|
var EmptyInputError = class extends BaseLangGraphError {
|
|
77
196
|
constructor(message, fields) {
|
|
78
197
|
super(message, fields);
|
|
@@ -84,7 +203,10 @@ var EmptyInputError = class extends BaseLangGraphError {
|
|
|
84
203
|
};
|
|
85
204
|
var EmptyChannelError = class extends BaseLangGraphError {
|
|
86
205
|
constructor(message, fields) {
|
|
206
|
+
const prevLimit = Error.stackTraceLimit;
|
|
207
|
+
Error.stackTraceLimit = 0;
|
|
87
208
|
super(message, fields);
|
|
209
|
+
Error.stackTraceLimit = prevLimit;
|
|
88
210
|
this.name = "EmptyChannelError";
|
|
89
211
|
}
|
|
90
212
|
static get unminifiable_name() {
|
|
@@ -180,19 +302,25 @@ exports.BaseLangGraphError = BaseLangGraphError;
|
|
|
180
302
|
exports.EmptyChannelError = EmptyChannelError;
|
|
181
303
|
exports.EmptyInputError = EmptyInputError;
|
|
182
304
|
exports.GraphBubbleUp = GraphBubbleUp;
|
|
305
|
+
exports.GraphDrained = GraphDrained;
|
|
183
306
|
exports.GraphInterrupt = GraphInterrupt;
|
|
184
307
|
exports.GraphRecursionError = GraphRecursionError;
|
|
185
308
|
exports.GraphValueError = GraphValueError;
|
|
186
309
|
exports.InvalidUpdateError = InvalidUpdateError;
|
|
187
310
|
exports.MultipleSubgraphsError = MultipleSubgraphsError;
|
|
311
|
+
exports.NodeError = NodeError;
|
|
188
312
|
exports.NodeInterrupt = NodeInterrupt;
|
|
313
|
+
exports.NodeTimeoutError = NodeTimeoutError;
|
|
189
314
|
exports.ParentCommand = ParentCommand;
|
|
190
315
|
exports.RemoteException = RemoteException;
|
|
191
316
|
exports.StateGraphInputError = StateGraphInputError;
|
|
192
317
|
exports.UnreachableNodeError = UnreachableNodeError;
|
|
193
318
|
exports.getSubgraphsSeenSet = getSubgraphsSeenSet;
|
|
194
319
|
exports.isGraphBubbleUp = isGraphBubbleUp;
|
|
320
|
+
exports.isGraphDrained = isGraphDrained;
|
|
195
321
|
exports.isGraphInterrupt = isGraphInterrupt;
|
|
322
|
+
exports.isNodeError = isNodeError;
|
|
323
|
+
exports.isNodeTimeoutError = isNodeTimeoutError;
|
|
196
324
|
exports.isParentCommand = isParentCommand;
|
|
197
325
|
|
|
198
326
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"StateGraphInputError\";\n this.message =\n \"Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema.\";\n }\n\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name() {\n return \"StateGraphInputError\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM,aAAa;AACnB,OAAK,gBAAgB,QAAQ;;;AAIjC,IAAa,gBAAb,cAAmC,mBAAmB;CACpD,IAAI,eAAe;AACjB,SAAO;;;AAIX,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,iBAAb,cAAoC,cAAc;CAChD;CAEA,YAAY,YAA0B,QAAmC;AACvE,QAAM,KAAK,UAAU,YAAY,MAAM,EAAE,EAAE,OAAO;AAClD,OA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O;;;AAIX,IAAa,uBAAb,cAA0C,mBAAmB;CAC3D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;;;;;;;;;;;;;;;AAqBX,IAAa,uBAAb,cAA0C,mBAAmB;;;;;;CAM3D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;AACZ,OAAK,UACH;;;;;CAMJ,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,MAAa,4BAA4B;AACvC,KAEG,WAAmB,OAAO,IAAI,4BAA4B,MAAM,KAAA,EAGhE,YAAmB,OAAO,IAAI,4BAA4B,oBAAI,IAAI,KAAK;AAG1E,QAAQ,WAAmB,OAAO,IAAI,4BAA4B"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\n/**\n * Raised when a graph run exits early due to a drain request.\n *\n * This indicates the graph stopped cooperatively at a superstep boundary\n * because {@link RunControl#requestDrain} was called (e.g., in response to\n * SIGTERM). The checkpoint is saved and the run can be resumed later.\n */\nexport class GraphDrained extends GraphBubbleUp {\n reason: string;\n\n constructor(reason: string = \"shutdown\", fields?: BaseLangGraphErrorFields) {\n super(`Graph drained: ${reason}`, fields);\n this.name = \"GraphDrained\";\n this.reason = reason;\n }\n\n static get unminifiable_name() {\n return \"GraphDrained\";\n }\n}\n\nexport function isGraphDrained(e?: unknown): e is GraphDrained {\n return (\n e !== undefined && (e as Error).name === GraphDrained.unminifiable_name\n );\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\n/**\n * Failure context passed to a node-level error handler.\n *\n * A node-level error handler is registered via\n * `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after\n * the failing node's {@link RetryPolicy} is exhausted, so retry and handling\n * stay decoupled. The handler receives the failed node's name and the thrown\n * error via a `NodeError` instance, can return a state update, and can route to\n * a recovery branch via `new Command({ goto })` (saga / compensation flows).\n *\n * @example\n * ```ts\n * import { NodeError } from \"@langchain/langgraph\";\n *\n * function handler(state: State, error: NodeError) {\n * return new Command({\n * update: { status: `recovered from ${error.node}: ${error.error.message}` },\n * goto: \"finalize\",\n * });\n * }\n * ```\n */\nexport class NodeError {\n /** Name of the node whose execution failed. */\n node: string;\n\n /** Error thrown by the failed node. */\n error: Error;\n\n constructor(node: string, error: Error) {\n this.node = node;\n this.error = error;\n }\n\n static get unminifiable_name() {\n return \"NodeError\";\n }\n}\n\n/**\n * Type guard that checks whether a value is a {@link NodeError}.\n */\nexport function isNodeError(e?: unknown): e is NodeError {\n return (\n e != null &&\n typeof e === \"object\" &&\n e.constructor != null &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (e.constructor as any).unminifiable_name === NodeError.unminifiable_name\n );\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\n/**\n * Raised when a node invocation exceeds one of its configured timeouts.\n *\n * Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node\n * error path) and is intentionally treated as retryable by the default retry\n * policy — its message/name do not match the default `retryOn` blocklist, so a\n * configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659).\n *\n * Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout}\n * reflect the configured policy at the time of the failure (each `undefined` if\n * not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout}\n * identify which one fired.\n *\n * @category Errors\n */\nexport class NodeTimeoutError extends BaseLangGraphError {\n /** Name of the node/task that timed out. */\n node: string;\n\n /** Which timeout fired: a hard `\"run\"` cap or a progress-resetting `\"idle\"` cap. */\n kind: \"run\" | \"idle\";\n\n /** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */\n timeout: number;\n\n /** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */\n elapsed: number;\n\n /** Configured run timeout (ms), if any. */\n runTimeout?: number;\n\n /** Configured idle timeout (ms), if any. */\n idleTimeout?: number;\n\n constructor(\n fields: {\n node: string;\n elapsed: number;\n kind: \"run\" | \"idle\";\n runTimeout?: number;\n idleTimeout?: number;\n },\n errorFields?: BaseLangGraphErrorFields\n ) {\n const { node, elapsed, kind, runTimeout, idleTimeout } = fields;\n let message: string;\n let timeout: number;\n if (kind === \"idle\") {\n if (idleTimeout === undefined) {\n throw new Error(\"idleTimeout is required when kind='idle'\");\n }\n timeout = idleTimeout;\n message =\n `Node \"${node}\" exceeded its idle timeout of ${idleTimeout}ms ` +\n `without making progress (elapsed: ${elapsed}ms).`;\n } else {\n if (runTimeout === undefined) {\n throw new Error(\"runTimeout is required when kind='run'\");\n }\n timeout = runTimeout;\n message =\n `Node \"${node}\" exceeded its run timeout of ${runTimeout}ms ` +\n `(elapsed: ${elapsed}ms).`;\n }\n super(message, errorFields);\n this.name = \"NodeTimeoutError\";\n this.node = node;\n this.kind = kind;\n this.timeout = timeout;\n this.elapsed = elapsed;\n this.runTimeout = runTimeout;\n this.idleTimeout = idleTimeout;\n }\n\n static get unminifiable_name() {\n return \"NodeTimeoutError\";\n }\n}\n\nexport function isNodeTimeoutError(e?: unknown): e is NodeTimeoutError {\n return (\n e !== undefined &&\n (e as NodeTimeoutError).name === NodeTimeoutError.unminifiable_name\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n // Skip expensive stack trace capture — used for control flow on channel reads.\n const prevLimit = Error.stackTraceLimit;\n Error.stackTraceLimit = 0;\n super(message, fields);\n Error.stackTraceLimit = prevLimit;\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"StateGraphInputError\";\n this.message =\n \"Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema.\";\n }\n\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name() {\n return \"StateGraphInputError\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM,aAAa;AACnB,OAAK,gBAAgB,QAAQ;;;AAIjC,IAAa,gBAAb,cAAmC,mBAAmB;CACpD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d.cts
CHANGED
|
@@ -20,6 +20,19 @@ declare class GraphValueError extends BaseLangGraphError {
|
|
|
20
20
|
constructor(message?: string, fields?: BaseLangGraphErrorFields);
|
|
21
21
|
static get unminifiable_name(): string;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Raised when a graph run exits early due to a drain request.
|
|
25
|
+
*
|
|
26
|
+
* This indicates the graph stopped cooperatively at a superstep boundary
|
|
27
|
+
* because {@link RunControl#requestDrain} was called (e.g., in response to
|
|
28
|
+
* SIGTERM). The checkpoint is saved and the run can be resumed later.
|
|
29
|
+
*/
|
|
30
|
+
declare class GraphDrained extends GraphBubbleUp {
|
|
31
|
+
reason: string;
|
|
32
|
+
constructor(reason?: string, fields?: BaseLangGraphErrorFields);
|
|
33
|
+
static get unminifiable_name(): string;
|
|
34
|
+
}
|
|
35
|
+
declare function isGraphDrained(e?: unknown): e is GraphDrained;
|
|
23
36
|
declare class GraphInterrupt extends GraphBubbleUp {
|
|
24
37
|
interrupts: Interrupt[];
|
|
25
38
|
constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);
|
|
@@ -30,6 +43,40 @@ declare class NodeInterrupt extends GraphInterrupt {
|
|
|
30
43
|
constructor(message: any, fields?: BaseLangGraphErrorFields);
|
|
31
44
|
static get unminifiable_name(): string;
|
|
32
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Failure context passed to a node-level error handler.
|
|
48
|
+
*
|
|
49
|
+
* A node-level error handler is registered via
|
|
50
|
+
* `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after
|
|
51
|
+
* the failing node's {@link RetryPolicy} is exhausted, so retry and handling
|
|
52
|
+
* stay decoupled. The handler receives the failed node's name and the thrown
|
|
53
|
+
* error via a `NodeError` instance, can return a state update, and can route to
|
|
54
|
+
* a recovery branch via `new Command({ goto })` (saga / compensation flows).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { NodeError } from "@langchain/langgraph";
|
|
59
|
+
*
|
|
60
|
+
* function handler(state: State, error: NodeError) {
|
|
61
|
+
* return new Command({
|
|
62
|
+
* update: { status: `recovered from ${error.node}: ${error.error.message}` },
|
|
63
|
+
* goto: "finalize",
|
|
64
|
+
* });
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare class NodeError {
|
|
69
|
+
/** Name of the node whose execution failed. */
|
|
70
|
+
node: string;
|
|
71
|
+
/** Error thrown by the failed node. */
|
|
72
|
+
error: Error;
|
|
73
|
+
constructor(node: string, error: Error);
|
|
74
|
+
static get unminifiable_name(): string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard that checks whether a value is a {@link NodeError}.
|
|
78
|
+
*/
|
|
79
|
+
declare function isNodeError(e?: unknown): e is NodeError;
|
|
33
80
|
declare class ParentCommand extends GraphBubbleUp {
|
|
34
81
|
command: Command;
|
|
35
82
|
constructor(command: Command);
|
|
@@ -38,6 +85,44 @@ declare class ParentCommand extends GraphBubbleUp {
|
|
|
38
85
|
declare function isParentCommand(e?: unknown): e is ParentCommand;
|
|
39
86
|
declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;
|
|
40
87
|
declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;
|
|
88
|
+
/**
|
|
89
|
+
* Raised when a node invocation exceeds one of its configured timeouts.
|
|
90
|
+
*
|
|
91
|
+
* Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node
|
|
92
|
+
* error path) and is intentionally treated as retryable by the default retry
|
|
93
|
+
* policy — its message/name do not match the default `retryOn` blocklist, so a
|
|
94
|
+
* configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659).
|
|
95
|
+
*
|
|
96
|
+
* Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout}
|
|
97
|
+
* reflect the configured policy at the time of the failure (each `undefined` if
|
|
98
|
+
* not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout}
|
|
99
|
+
* identify which one fired.
|
|
100
|
+
*
|
|
101
|
+
* @category Errors
|
|
102
|
+
*/
|
|
103
|
+
declare class NodeTimeoutError extends BaseLangGraphError {
|
|
104
|
+
/** Name of the node/task that timed out. */
|
|
105
|
+
node: string;
|
|
106
|
+
/** Which timeout fired: a hard `"run"` cap or a progress-resetting `"idle"` cap. */
|
|
107
|
+
kind: "run" | "idle";
|
|
108
|
+
/** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */
|
|
109
|
+
timeout: number;
|
|
110
|
+
/** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */
|
|
111
|
+
elapsed: number;
|
|
112
|
+
/** Configured run timeout (ms), if any. */
|
|
113
|
+
runTimeout?: number;
|
|
114
|
+
/** Configured idle timeout (ms), if any. */
|
|
115
|
+
idleTimeout?: number;
|
|
116
|
+
constructor(fields: {
|
|
117
|
+
node: string;
|
|
118
|
+
elapsed: number;
|
|
119
|
+
kind: "run" | "idle";
|
|
120
|
+
runTimeout?: number;
|
|
121
|
+
idleTimeout?: number;
|
|
122
|
+
}, errorFields?: BaseLangGraphErrorFields);
|
|
123
|
+
static get unminifiable_name(): string;
|
|
124
|
+
}
|
|
125
|
+
declare function isNodeTimeoutError(e?: unknown): e is NodeTimeoutError;
|
|
41
126
|
declare class EmptyInputError extends BaseLangGraphError {
|
|
42
127
|
constructor(message?: string, fields?: BaseLangGraphErrorFields);
|
|
43
128
|
static get unminifiable_name(): string;
|
|
@@ -102,5 +187,5 @@ declare class StateGraphInputError extends BaseLangGraphError {
|
|
|
102
187
|
*/
|
|
103
188
|
declare const getSubgraphsSeenSet: () => any;
|
|
104
189
|
//#endregion
|
|
105
|
-
export { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand };
|
|
190
|
+
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 };
|
|
106
191
|
//# sourceMappingURL=errors.d.cts.map
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;KAIY,wBAAA;EACV,aAAA;AAAA;;cAWW,kBAAA,SAA2B,KAAA;EACtC,aAAA;EAEA,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;AAAA;AAAA,cAU5B,aAAA,SAAsB,kBAAA;EAAA,IAC7B,YAAA,CAAA;AAAA;AAAA,cAKO,mBAAA,SAA4B,kBAAA;EACvC,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;EAAA,WAK5B,iBAAA,CAAA;AAAA;AAAA,cAKA,eAAA,SAAwB,kBAAA;EACnC,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;EAAA,WAK5B,iBAAA,CAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;;KAIY,wBAAA;EACV,aAAA;AAAA;;cAWW,kBAAA,SAA2B,KAAA;EACtC,aAAA;EAEA,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;AAAA;AAAA,cAU5B,aAAA,SAAsB,kBAAA;EAAA,IAC7B,YAAA,CAAA;AAAA;AAAA,cAKO,mBAAA,SAA4B,kBAAA;EACvC,WAAA,CAAY,OAAA,WAA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@ declare class GraphValueError extends BaseLangGraphError {
|
|
|
20
20
|
constructor(message?: string, fields?: BaseLangGraphErrorFields);
|
|
21
21
|
static get unminifiable_name(): string;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Raised when a graph run exits early due to a drain request.
|
|
25
|
+
*
|
|
26
|
+
* This indicates the graph stopped cooperatively at a superstep boundary
|
|
27
|
+
* because {@link RunControl#requestDrain} was called (e.g., in response to
|
|
28
|
+
* SIGTERM). The checkpoint is saved and the run can be resumed later.
|
|
29
|
+
*/
|
|
30
|
+
declare class GraphDrained extends GraphBubbleUp {
|
|
31
|
+
reason: string;
|
|
32
|
+
constructor(reason?: string, fields?: BaseLangGraphErrorFields);
|
|
33
|
+
static get unminifiable_name(): string;
|
|
34
|
+
}
|
|
35
|
+
declare function isGraphDrained(e?: unknown): e is GraphDrained;
|
|
23
36
|
declare class GraphInterrupt extends GraphBubbleUp {
|
|
24
37
|
interrupts: Interrupt[];
|
|
25
38
|
constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);
|
|
@@ -30,6 +43,40 @@ declare class NodeInterrupt extends GraphInterrupt {
|
|
|
30
43
|
constructor(message: any, fields?: BaseLangGraphErrorFields);
|
|
31
44
|
static get unminifiable_name(): string;
|
|
32
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Failure context passed to a node-level error handler.
|
|
48
|
+
*
|
|
49
|
+
* A node-level error handler is registered via
|
|
50
|
+
* `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after
|
|
51
|
+
* the failing node's {@link RetryPolicy} is exhausted, so retry and handling
|
|
52
|
+
* stay decoupled. The handler receives the failed node's name and the thrown
|
|
53
|
+
* error via a `NodeError` instance, can return a state update, and can route to
|
|
54
|
+
* a recovery branch via `new Command({ goto })` (saga / compensation flows).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { NodeError } from "@langchain/langgraph";
|
|
59
|
+
*
|
|
60
|
+
* function handler(state: State, error: NodeError) {
|
|
61
|
+
* return new Command({
|
|
62
|
+
* update: { status: `recovered from ${error.node}: ${error.error.message}` },
|
|
63
|
+
* goto: "finalize",
|
|
64
|
+
* });
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare class NodeError {
|
|
69
|
+
/** Name of the node whose execution failed. */
|
|
70
|
+
node: string;
|
|
71
|
+
/** Error thrown by the failed node. */
|
|
72
|
+
error: Error;
|
|
73
|
+
constructor(node: string, error: Error);
|
|
74
|
+
static get unminifiable_name(): string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard that checks whether a value is a {@link NodeError}.
|
|
78
|
+
*/
|
|
79
|
+
declare function isNodeError(e?: unknown): e is NodeError;
|
|
33
80
|
declare class ParentCommand extends GraphBubbleUp {
|
|
34
81
|
command: Command;
|
|
35
82
|
constructor(command: Command);
|
|
@@ -38,6 +85,44 @@ declare class ParentCommand extends GraphBubbleUp {
|
|
|
38
85
|
declare function isParentCommand(e?: unknown): e is ParentCommand;
|
|
39
86
|
declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;
|
|
40
87
|
declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;
|
|
88
|
+
/**
|
|
89
|
+
* Raised when a node invocation exceeds one of its configured timeouts.
|
|
90
|
+
*
|
|
91
|
+
* Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node
|
|
92
|
+
* error path) and is intentionally treated as retryable by the default retry
|
|
93
|
+
* policy — its message/name do not match the default `retryOn` blocklist, so a
|
|
94
|
+
* configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659).
|
|
95
|
+
*
|
|
96
|
+
* Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout}
|
|
97
|
+
* reflect the configured policy at the time of the failure (each `undefined` if
|
|
98
|
+
* not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout}
|
|
99
|
+
* identify which one fired.
|
|
100
|
+
*
|
|
101
|
+
* @category Errors
|
|
102
|
+
*/
|
|
103
|
+
declare class NodeTimeoutError extends BaseLangGraphError {
|
|
104
|
+
/** Name of the node/task that timed out. */
|
|
105
|
+
node: string;
|
|
106
|
+
/** Which timeout fired: a hard `"run"` cap or a progress-resetting `"idle"` cap. */
|
|
107
|
+
kind: "run" | "idle";
|
|
108
|
+
/** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */
|
|
109
|
+
timeout: number;
|
|
110
|
+
/** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */
|
|
111
|
+
elapsed: number;
|
|
112
|
+
/** Configured run timeout (ms), if any. */
|
|
113
|
+
runTimeout?: number;
|
|
114
|
+
/** Configured idle timeout (ms), if any. */
|
|
115
|
+
idleTimeout?: number;
|
|
116
|
+
constructor(fields: {
|
|
117
|
+
node: string;
|
|
118
|
+
elapsed: number;
|
|
119
|
+
kind: "run" | "idle";
|
|
120
|
+
runTimeout?: number;
|
|
121
|
+
idleTimeout?: number;
|
|
122
|
+
}, errorFields?: BaseLangGraphErrorFields);
|
|
123
|
+
static get unminifiable_name(): string;
|
|
124
|
+
}
|
|
125
|
+
declare function isNodeTimeoutError(e?: unknown): e is NodeTimeoutError;
|
|
41
126
|
declare class EmptyInputError extends BaseLangGraphError {
|
|
42
127
|
constructor(message?: string, fields?: BaseLangGraphErrorFields);
|
|
43
128
|
static get unminifiable_name(): string;
|
|
@@ -102,5 +187,5 @@ declare class StateGraphInputError extends BaseLangGraphError {
|
|
|
102
187
|
*/
|
|
103
188
|
declare const getSubgraphsSeenSet: () => any;
|
|
104
189
|
//#endregion
|
|
105
|
-
export { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand };
|
|
190
|
+
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 };
|
|
106
191
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;KAIY,wBAAA;EACV,aAAA;AAAA;;cAWW,kBAAA,SAA2B,KAAA;EACtC,aAAA;EAEA,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;AAAA;AAAA,cAU5B,aAAA,SAAsB,kBAAA;EAAA,IAC7B,YAAA,CAAA;AAAA;AAAA,cAKO,mBAAA,SAA4B,kBAAA;EACvC,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;EAAA,WAK5B,iBAAA,CAAA;AAAA;AAAA,cAKA,eAAA,SAAwB,kBAAA;EACnC,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;EAAA,WAK5B,iBAAA,CAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;KAIY,wBAAA;EACV,aAAA;AAAA;;cAWW,kBAAA,SAA2B,KAAA;EACtC,aAAA;EAEA,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;AAAA;AAAA,cAU5B,aAAA,SAAsB,kBAAA;EAAA,IAC7B,YAAA,CAAA;AAAA;AAAA,cAKO,mBAAA,SAA4B,kBAAA;EACvC,WAAA,CAAY,OAAA,WAAkB,MAAA,GAAS,wBAAA;EAAA,WAK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32
32
|
return "GraphValueError";
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Raised when a graph run exits early due to a drain request.
|
|
37
|
+
*
|
|
38
|
+
* This indicates the graph stopped cooperatively at a superstep boundary
|
|
39
|
+
* because {@link RunControl#requestDrain} was called (e.g., in response to
|
|
40
|
+
* SIGTERM). The checkpoint is saved and the run can be resumed later.
|
|
41
|
+
*/
|
|
42
|
+
var GraphDrained = class extends GraphBubbleUp {
|
|
43
|
+
reason;
|
|
44
|
+
constructor(reason = "shutdown", fields) {
|
|
45
|
+
super(`Graph drained: ${reason}`, fields);
|
|
46
|
+
this.name = "GraphDrained";
|
|
47
|
+
this.reason = reason;
|
|
48
|
+
}
|
|
49
|
+
static get unminifiable_name() {
|
|
50
|
+
return "GraphDrained";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function isGraphDrained(e) {
|
|
54
|
+
return e !== void 0 && e.name === GraphDrained.unminifiable_name;
|
|
55
|
+
}
|
|
35
56
|
var GraphInterrupt = class extends GraphBubbleUp {
|
|
36
57
|
interrupts;
|
|
37
58
|
constructor(interrupts, fields) {
|
|
@@ -53,6 +74,47 @@ var NodeInterrupt = class extends GraphInterrupt {
|
|
|
53
74
|
return "NodeInterrupt";
|
|
54
75
|
}
|
|
55
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Failure context passed to a node-level error handler.
|
|
79
|
+
*
|
|
80
|
+
* A node-level error handler is registered via
|
|
81
|
+
* `StateGraph.addNode(name, fn, { errorHandler })`. The handler runs ONLY after
|
|
82
|
+
* the failing node's {@link RetryPolicy} is exhausted, so retry and handling
|
|
83
|
+
* stay decoupled. The handler receives the failed node's name and the thrown
|
|
84
|
+
* error via a `NodeError` instance, can return a state update, and can route to
|
|
85
|
+
* a recovery branch via `new Command({ goto })` (saga / compensation flows).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { NodeError } from "@langchain/langgraph";
|
|
90
|
+
*
|
|
91
|
+
* function handler(state: State, error: NodeError) {
|
|
92
|
+
* return new Command({
|
|
93
|
+
* update: { status: `recovered from ${error.node}: ${error.error.message}` },
|
|
94
|
+
* goto: "finalize",
|
|
95
|
+
* });
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
var NodeError = class {
|
|
100
|
+
/** Name of the node whose execution failed. */
|
|
101
|
+
node;
|
|
102
|
+
/** Error thrown by the failed node. */
|
|
103
|
+
error;
|
|
104
|
+
constructor(node, error) {
|
|
105
|
+
this.node = node;
|
|
106
|
+
this.error = error;
|
|
107
|
+
}
|
|
108
|
+
static get unminifiable_name() {
|
|
109
|
+
return "NodeError";
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Type guard that checks whether a value is a {@link NodeError}.
|
|
114
|
+
*/
|
|
115
|
+
function isNodeError(e) {
|
|
116
|
+
return e != null && typeof e === "object" && e.constructor != null && e.constructor.unminifiable_name === NodeError.unminifiable_name;
|
|
117
|
+
}
|
|
56
118
|
var ParentCommand = class extends GraphBubbleUp {
|
|
57
119
|
command;
|
|
58
120
|
constructor(command) {
|
|
@@ -73,6 +135,63 @@ function isGraphBubbleUp(e) {
|
|
|
73
135
|
function isGraphInterrupt(e) {
|
|
74
136
|
return e !== void 0 && [GraphInterrupt.unminifiable_name, NodeInterrupt.unminifiable_name].includes(e.name);
|
|
75
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Raised when a node invocation exceeds one of its configured timeouts.
|
|
140
|
+
*
|
|
141
|
+
* Does **not** extend {@link GraphBubbleUp} (so it flows through the normal node
|
|
142
|
+
* error path) and is intentionally treated as retryable by the default retry
|
|
143
|
+
* policy — its message/name do not match the default `retryOn` blocklist, so a
|
|
144
|
+
* configured {@link RetryPolicy} will retry it (see langchain-ai/langgraph#7659).
|
|
145
|
+
*
|
|
146
|
+
* Both {@link NodeTimeoutError.runTimeout} and {@link NodeTimeoutError.idleTimeout}
|
|
147
|
+
* reflect the configured policy at the time of the failure (each `undefined` if
|
|
148
|
+
* not configured). {@link NodeTimeoutError.kind} and {@link NodeTimeoutError.timeout}
|
|
149
|
+
* identify which one fired.
|
|
150
|
+
*
|
|
151
|
+
* @category Errors
|
|
152
|
+
*/
|
|
153
|
+
var NodeTimeoutError = class extends BaseLangGraphError {
|
|
154
|
+
/** Name of the node/task that timed out. */
|
|
155
|
+
node;
|
|
156
|
+
/** Which timeout fired: a hard `"run"` cap or a progress-resetting `"idle"` cap. */
|
|
157
|
+
kind;
|
|
158
|
+
/** The value (ms) of the timeout that fired (`runTimeout` or `idleTimeout`). */
|
|
159
|
+
timeout;
|
|
160
|
+
/** Elapsed time (ms) since the attempt started, at the moment the timeout fired. */
|
|
161
|
+
elapsed;
|
|
162
|
+
/** Configured run timeout (ms), if any. */
|
|
163
|
+
runTimeout;
|
|
164
|
+
/** Configured idle timeout (ms), if any. */
|
|
165
|
+
idleTimeout;
|
|
166
|
+
constructor(fields, errorFields) {
|
|
167
|
+
const { node, elapsed, kind, runTimeout, idleTimeout } = fields;
|
|
168
|
+
let message;
|
|
169
|
+
let timeout;
|
|
170
|
+
if (kind === "idle") {
|
|
171
|
+
if (idleTimeout === void 0) throw new Error("idleTimeout is required when kind='idle'");
|
|
172
|
+
timeout = idleTimeout;
|
|
173
|
+
message = `Node "${node}" exceeded its idle timeout of ${idleTimeout}ms without making progress (elapsed: ${elapsed}ms).`;
|
|
174
|
+
} else {
|
|
175
|
+
if (runTimeout === void 0) throw new Error("runTimeout is required when kind='run'");
|
|
176
|
+
timeout = runTimeout;
|
|
177
|
+
message = `Node "${node}" exceeded its run timeout of ${runTimeout}ms (elapsed: ${elapsed}ms).`;
|
|
178
|
+
}
|
|
179
|
+
super(message, errorFields);
|
|
180
|
+
this.name = "NodeTimeoutError";
|
|
181
|
+
this.node = node;
|
|
182
|
+
this.kind = kind;
|
|
183
|
+
this.timeout = timeout;
|
|
184
|
+
this.elapsed = elapsed;
|
|
185
|
+
this.runTimeout = runTimeout;
|
|
186
|
+
this.idleTimeout = idleTimeout;
|
|
187
|
+
}
|
|
188
|
+
static get unminifiable_name() {
|
|
189
|
+
return "NodeTimeoutError";
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
function isNodeTimeoutError(e) {
|
|
193
|
+
return e !== void 0 && e.name === NodeTimeoutError.unminifiable_name;
|
|
194
|
+
}
|
|
76
195
|
var EmptyInputError = class extends BaseLangGraphError {
|
|
77
196
|
constructor(message, fields) {
|
|
78
197
|
super(message, fields);
|
|
@@ -84,7 +203,10 @@ var EmptyInputError = class extends BaseLangGraphError {
|
|
|
84
203
|
};
|
|
85
204
|
var EmptyChannelError = class extends BaseLangGraphError {
|
|
86
205
|
constructor(message, fields) {
|
|
206
|
+
const prevLimit = Error.stackTraceLimit;
|
|
207
|
+
Error.stackTraceLimit = 0;
|
|
87
208
|
super(message, fields);
|
|
209
|
+
Error.stackTraceLimit = prevLimit;
|
|
88
210
|
this.name = "EmptyChannelError";
|
|
89
211
|
}
|
|
90
212
|
static get unminifiable_name() {
|
|
@@ -176,6 +298,6 @@ const getSubgraphsSeenSet = () => {
|
|
|
176
298
|
return globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")];
|
|
177
299
|
};
|
|
178
300
|
//#endregion
|
|
179
|
-
export { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand };
|
|
301
|
+
export { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand };
|
|
180
302
|
|
|
181
303
|
//# sourceMappingURL=errors.js.map
|