@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/graph/state.d.cts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { BaseChannel } from "../channels/base.cjs";
|
|
2
|
+
import { TimeoutPolicy } from "../pregel/utils/timeout.cjs";
|
|
2
3
|
import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.cjs";
|
|
3
4
|
import { SchemaMetaRegistry } from "./zod/meta.cjs";
|
|
4
5
|
import { RunnableLike, Runtime } from "../pregel/runnable_types.cjs";
|
|
5
6
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.cjs";
|
|
6
7
|
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.cjs";
|
|
7
8
|
import { StreamTransformer } from "../stream/types.cjs";
|
|
8
|
-
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.cjs";
|
|
9
|
-
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.cjs";
|
|
10
|
-
import { InferWriterType } from "../writer.cjs";
|
|
11
9
|
import { AnyStateSchema } from "../state/schema.cjs";
|
|
12
10
|
import { ContextSchemaInit, ExtractStateType, ExtractUpdateType, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./types.cjs";
|
|
11
|
+
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeErrorHandler, NodeSpec } from "./graph.cjs";
|
|
12
|
+
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.cjs";
|
|
13
|
+
import { InferWriterType } from "../writer.cjs";
|
|
13
14
|
import { All, BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
14
15
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
15
16
|
|
|
@@ -22,22 +23,91 @@ interface StateGraphArgs<Channels extends object | unknown> {
|
|
|
22
23
|
__root__: Channels;
|
|
23
24
|
}>;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Retry and cache policies configurable on graph nodes.
|
|
28
|
+
*
|
|
29
|
+
* Use with {@link StateGraph.addNode} for per-node overrides, or with
|
|
30
|
+
* {@link StateGraph.setNodeDefaults} for graph-wide defaults applied at
|
|
31
|
+
* `compile()` time. Per-node values always take precedence over defaults.
|
|
32
|
+
* `setNodeDefaults` may be called before or after `addNode`, including as the
|
|
33
|
+
* last step before `compile()`.
|
|
34
|
+
*/
|
|
35
|
+
type NodePolicyOptions = {
|
|
36
|
+
/**
|
|
37
|
+
* Retry policy controlling backoff, max attempts, and which errors trigger
|
|
38
|
+
* a retry.
|
|
39
|
+
*
|
|
40
|
+
* @see {@link RetryPolicy}
|
|
41
|
+
*/
|
|
27
42
|
retryPolicy?: RetryPolicy;
|
|
28
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Cache policy controlling how node results are keyed and how long they
|
|
45
|
+
* persist.
|
|
46
|
+
*
|
|
47
|
+
* - Pass a {@link CachePolicy} object for fine-grained control (e.g. custom
|
|
48
|
+
* `keyFunc`, `ttl`).
|
|
49
|
+
* - Pass `true` to enable caching with default settings.
|
|
50
|
+
* - Pass `false` to disable caching.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link CachePolicy}
|
|
53
|
+
*/
|
|
54
|
+
cachePolicy?: CachePolicy | boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum duration for a single attempt of this node. Accepts a number of
|
|
57
|
+
* milliseconds (a hard wall-clock cap) or a {@link TimeoutPolicy} for finer
|
|
58
|
+
* control over run / idle timeouts. When exceeded, a {@link NodeTimeoutError}
|
|
59
|
+
* is raised and the node's retry policy (if any) decides whether to retry.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link TimeoutPolicy}
|
|
62
|
+
*/
|
|
63
|
+
timeout?: number | TimeoutPolicy;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolved retry and cache policies stored on a node after boolean
|
|
67
|
+
* `cachePolicy` shorthand is normalized.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
type NodePolicies = {
|
|
72
|
+
retryPolicy?: RetryPolicy; /** `false` opts out of graph defaults set via {@link StateGraph.setNodeDefaults}. */
|
|
73
|
+
cachePolicy?: CachePolicy | false; /** Resolved timeout policy after the `number` shorthand is normalized. */
|
|
74
|
+
timeout?: TimeoutPolicy;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Graph-wide node defaults captured by {@link StateGraph.setNodeDefaults} and
|
|
78
|
+
* resolved at {@link StateGraph.compile} time.
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
type ResolvedNodeDefaults = NodePolicies & {
|
|
83
|
+
/**
|
|
84
|
+
* Default error handler applied to every regular node that does not set its
|
|
85
|
+
* own via `addNode(..., { errorHandler })`. Never applied to error-handler
|
|
86
|
+
* nodes themselves — handlers must not catch their own failures.
|
|
87
|
+
*/
|
|
88
|
+
errorHandler?: NodeErrorHandler;
|
|
89
|
+
};
|
|
90
|
+
type StateGraphNodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput> & NodePolicies & {
|
|
91
|
+
input?: StateDefinition;
|
|
29
92
|
};
|
|
30
93
|
/**
|
|
31
94
|
* Options for StateGraph.addNode() method.
|
|
32
95
|
*
|
|
33
96
|
* @template Nodes - Node name constraints
|
|
34
97
|
* @template InputSchema - Per-node input schema type (inferred from options.input)
|
|
98
|
+
* @template HandlerState - State type passed to the node-level error handler
|
|
99
|
+
* @template Update - The update type the error handler may return
|
|
35
100
|
*/
|
|
36
|
-
type StateGraphAddNodeOptions<Nodes extends string = string, InputSchema extends StateDefinitionInit | undefined = StateDefinitionInit | undefined> = {
|
|
37
|
-
retryPolicy?: RetryPolicy;
|
|
38
|
-
cachePolicy?: CachePolicy | boolean;
|
|
101
|
+
type StateGraphAddNodeOptions<Nodes extends string = string, InputSchema extends StateDefinitionInit | undefined = StateDefinitionInit | undefined, HandlerState = (InputSchema extends StateDefinitionInit ? ExtractStateType<InputSchema> : unknown), Update = unknown> = {
|
|
39
102
|
input?: InputSchema;
|
|
40
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Optional node-level error handler. Runs only after this node's
|
|
105
|
+
* {@link RetryPolicy} is exhausted. Receives a {@link NodeError} with the
|
|
106
|
+
* failed node name and error, and may return a state update or `Command`.
|
|
107
|
+
*/
|
|
108
|
+
errorHandler?: NodeErrorHandler<HandlerState, Update, Nodes>;
|
|
109
|
+
} & NodePolicyOptions & AddNodeOptions<Nodes>;
|
|
110
|
+
type StateGraphAddNodeOptionsWithNodeInput<Nodes extends string, NodeInput, Update = unknown> = StateGraphAddNodeOptions<Nodes, StateDefinitionInit | undefined, NodeInput, Update>;
|
|
41
111
|
type StateGraphArgsWithStateSchema<SD extends StateDefinition, I extends StateDefinition, O extends StateDefinition> = {
|
|
42
112
|
stateSchema: AnnotationRoot<SD>;
|
|
43
113
|
input?: AnnotationRoot<I>;
|
|
@@ -176,6 +246,11 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
176
246
|
_interrupt: InterruptType;
|
|
177
247
|
/** @internal */
|
|
178
248
|
_writer: WriterType;
|
|
249
|
+
/**
|
|
250
|
+
* Graph-wide default node policies, resolved at `compile()` time.
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
_nodeDefaults: ResolvedNodeDefaults;
|
|
179
254
|
Node: StrictNodeAction<S, U, C, N, InterruptType, WriterType>;
|
|
180
255
|
/**
|
|
181
256
|
* Create a new StateGraph for building stateful, multi-step workflows.
|
|
@@ -226,6 +301,81 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
226
301
|
constructor(init: StateGraphInit<SD extends StateDefinitionInit ? SD : StateDefinitionInit, I, O, C extends ContextSchemaInit ? C : undefined, N, InterruptType, WriterType>);
|
|
227
302
|
/** @deprecated Use `Annotation.Root`, `StateSchema`, or Zod schemas instead. */
|
|
228
303
|
constructor(fields: StateGraphArgs<S>, contextSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
|
|
304
|
+
/**
|
|
305
|
+
* Set graph-wide default node policies that apply to every node in this
|
|
306
|
+
* graph.
|
|
307
|
+
*
|
|
308
|
+
* Per-node values passed to {@link addNode} always take precedence over these
|
|
309
|
+
* defaults. Defaults are resolved at {@link compile} time, so call order does
|
|
310
|
+
* not matter — you may call this before or after `addNode`, including as the
|
|
311
|
+
* last step before `compile()`. Calling it multiple times merges the provided
|
|
312
|
+
* fields, with later calls overriding earlier ones on a per-field basis.
|
|
313
|
+
*
|
|
314
|
+
* Policies set here are **not** inherited by subgraphs.
|
|
315
|
+
*
|
|
316
|
+
* `retryPolicy` and `timeout` defaults apply to **all** nodes, including
|
|
317
|
+
* auto-generated error-handler nodes. `cachePolicy` and `errorHandler`
|
|
318
|
+
* defaults apply to **regular nodes only** — caching an error-handler result
|
|
319
|
+
* is unsafe, and a handler must never catch its own (or another handler's)
|
|
320
|
+
* failure.
|
|
321
|
+
*
|
|
322
|
+
* @param defaults - The default node policies to apply.
|
|
323
|
+
* @returns The builder instance, for chaining.
|
|
324
|
+
*
|
|
325
|
+
* @example Call before `addNode`
|
|
326
|
+
* ```ts
|
|
327
|
+
* const graph = new StateGraph(State)
|
|
328
|
+
* .setNodeDefaults({
|
|
329
|
+
* retryPolicy: { maxAttempts: 3 },
|
|
330
|
+
* cachePolicy: { ttl: 60 },
|
|
331
|
+
* timeout: 60_000,
|
|
332
|
+
* errorHandler: (state, { node, error }) => ({ lastError: error.message }),
|
|
333
|
+
* })
|
|
334
|
+
* .addNode("a", nodeA)
|
|
335
|
+
* .addNode("b", nodeB, { retryPolicy: { maxAttempts: 5 } }) // overrides default
|
|
336
|
+
* .addEdge(START, "a")
|
|
337
|
+
* .compile();
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @example Call after `addNode`, immediately before `compile()`
|
|
341
|
+
* ```ts
|
|
342
|
+
* const graph = new StateGraph(State)
|
|
343
|
+
* .addNode("a", nodeA)
|
|
344
|
+
* .addNode("b", nodeB, { retryPolicy: { maxAttempts: 5 } }) // overrides default
|
|
345
|
+
* .addEdge(START, "a")
|
|
346
|
+
* .setNodeDefaults({
|
|
347
|
+
* retryPolicy: { maxAttempts: 3 },
|
|
348
|
+
* cachePolicy: { ttl: 60 },
|
|
349
|
+
* })
|
|
350
|
+
* .compile();
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
setNodeDefaults(defaults: NodePolicyOptions & {
|
|
354
|
+
/**
|
|
355
|
+
* Default node-level error handler invoked when any **regular** node
|
|
356
|
+
* raises and does not have its own handler set via
|
|
357
|
+
* `addNode(..., { errorHandler })`. Runs only after the failing node's
|
|
358
|
+
* retry policy is exhausted. It is never invoked when an error-handler
|
|
359
|
+
* node itself raises — handler failures fail the run.
|
|
360
|
+
*
|
|
361
|
+
* Because a single shared handler serves every node, its `state`
|
|
362
|
+
* argument is typed as `unknown`: at runtime it receives the **failing
|
|
363
|
+
* node's input** (see `addNode(..., { input })`), which may be a subset
|
|
364
|
+
* of the graph state and differs per node. Narrow it yourself before
|
|
365
|
+
* reading fields. The handler may still return a graph-level update (`U`)
|
|
366
|
+
* or route via `new Command({ goto })` to any node (`N`).
|
|
367
|
+
*/
|
|
368
|
+
errorHandler?: NodeErrorHandler<unknown, U, N>;
|
|
369
|
+
}): this;
|
|
370
|
+
/**
|
|
371
|
+
* Build the shared spec for a graph-wide default error handler, or
|
|
372
|
+
* `undefined` when {@link setNodeDefaults} did not configure one. The spec is
|
|
373
|
+
* installed under {@link DEFAULT_ERROR_HANDLER_NODE} for the duration of a
|
|
374
|
+
* single {@link compile} call and routes failures from every regular node
|
|
375
|
+
* that lacks its own handler.
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
protected _createDefaultErrorHandlerSpec(): StateGraphNodeSpec<S, U> | undefined;
|
|
229
379
|
/**
|
|
230
380
|
* Normalize all constructor input patterns to a unified StateGraphInit object.
|
|
231
381
|
* @internal
|
|
@@ -239,13 +389,13 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
239
389
|
get allEdges(): Set<[string, string]>;
|
|
240
390
|
_addSchema(stateDefinition: StateDefinitionInit): void;
|
|
241
391
|
addNode<K extends string, NodeMap extends Record<K, NodeAction<S, U, C, InterruptType, WriterType>>>(nodes: NodeMap): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in keyof NodeMap]: NodeMap[key] extends NodeAction<S, infer U, C, InterruptType, WriterType> ? U : never }>>;
|
|
242
|
-
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
243
|
-
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
244
|
-
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
245
|
-
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
246
|
-
addNode<K extends string, NodeInput = S>(key: K, action: NodeAction<NodeInput, U, C, InterruptType, WriterType>, options?:
|
|
392
|
+
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>][]): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
393
|
+
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema, ExtractStateType<InputSchema>, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
394
|
+
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema, ExtractStateType<InputSchema>, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
395
|
+
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
396
|
+
addNode<K extends string, NodeInput = S>(key: K, action: NodeAction<NodeInput, U, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>): StateGraph<SD, S, U, N | K, I, O, C, NodeReturnType>;
|
|
247
397
|
addEdge(startKey: typeof START | N | N[], endKey: N | typeof END): this;
|
|
248
|
-
addSequence<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
398
|
+
addSequence<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>][]): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
249
399
|
addSequence<K extends string, NodeMap extends Record<K, NodeAction<S, U, C, InterruptType, WriterType>>>(nodes: NodeMap): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in keyof NodeMap]: NodeMap[key] extends NodeAction<S, infer U, C, InterruptType, WriterType> ? U : never }>>;
|
|
250
400
|
compile<const TTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []>({
|
|
251
401
|
checkpointer,
|
|
@@ -271,6 +421,28 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
271
421
|
*/
|
|
272
422
|
transformers?: TTransformers;
|
|
273
423
|
}): CompiledStateGraph<Prettify<S>, Prettify<U>, N, I, O, C, NodeReturnType, InterruptType, WriterType, TTransformers>;
|
|
424
|
+
/** @internal */
|
|
425
|
+
protected _compileResolved<const TTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []>({
|
|
426
|
+
checkpointer,
|
|
427
|
+
store,
|
|
428
|
+
cache,
|
|
429
|
+
interruptBefore,
|
|
430
|
+
interruptAfter,
|
|
431
|
+
name,
|
|
432
|
+
description,
|
|
433
|
+
transformers,
|
|
434
|
+
defaultErrorHandlerNode
|
|
435
|
+
}: {
|
|
436
|
+
checkpointer?: BaseCheckpointSaver | boolean;
|
|
437
|
+
store?: BaseStore;
|
|
438
|
+
cache?: BaseCache;
|
|
439
|
+
interruptBefore?: N[] | All;
|
|
440
|
+
interruptAfter?: N[] | All;
|
|
441
|
+
name?: string;
|
|
442
|
+
description?: string;
|
|
443
|
+
transformers?: TTransformers;
|
|
444
|
+
defaultErrorHandlerNode?: string;
|
|
445
|
+
}): CompiledStateGraph<Prettify<S>, Prettify<U>, N, I, O, C, NodeReturnType, InterruptType, WriterType, TTransformers>;
|
|
274
446
|
}
|
|
275
447
|
/**
|
|
276
448
|
* Final result from building and compiling a {@link StateGraph}.
|
|
@@ -305,6 +477,10 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
305
477
|
*
|
|
306
478
|
* @typeParam WriterType - The type for custom stream writers. Used with the `writer`
|
|
307
479
|
* option to enable typed custom streaming from within nodes.
|
|
480
|
+
*
|
|
481
|
+
* @typeParam TStreamTransformers - Stream transformer factories registered at
|
|
482
|
+
* compile time via the `transformers` option. Used to type extensions on
|
|
483
|
+
* `streamEvents(..., { version: "v3" })`.
|
|
308
484
|
*/
|
|
309
485
|
declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends StateDefinitionInit = StateDefinition, O extends StateDefinitionInit = StateDefinition, C extends StateDefinitionInit = StateDefinition, NodeReturnType = unknown, InterruptType = unknown, WriterType = unknown, TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []> extends CompiledGraph<N, S, U, ExtractStateType<C>, ExtractUpdateType<I, ExtractStateType<I>>, ExtractStateType<O>, NodeReturnType, CommandInstance<InferInterruptResumeType<InterruptType>, Prettify<U>, N>, InferWriterType<WriterType>, TStreamTransformers> {
|
|
310
486
|
builder: StateGraph<unknown, S, U, N, I, O, C, NodeReturnType>;
|
|
@@ -334,5 +510,5 @@ declare class CompiledStateGraph<S, U, N extends string = typeof START, I extend
|
|
|
334
510
|
protected _validateContext(config: Partial<Record<string, unknown>>): Promise<Partial<Record<string, unknown>>>;
|
|
335
511
|
}
|
|
336
512
|
//#endregion
|
|
337
|
-
export { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec };
|
|
513
|
+
export { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec };
|
|
338
514
|
//# sourceMappingURL=state.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.cts","names":[],"sources":["../../src/graph/state.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"state.d.cts","names":[],"sources":["../../src/graph/state.ts"],"mappings":";;;;;;;;;;;;;;;;;KAgHY,eAAA,0CAEE,QA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{ Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.js";
|
|
3
4
|
import { SchemaMetaRegistry } from "./zod/meta.js";
|
|
4
5
|
import { RunnableLike, Runtime } from "../pregel/runnable_types.js";
|
|
5
6
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.js";
|
|
6
7
|
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
|
|
7
8
|
import { StreamTransformer } from "../stream/types.js";
|
|
8
|
-
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.js";
|
|
9
|
-
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.js";
|
|
10
|
-
import { InferWriterType } from "../writer.js";
|
|
11
9
|
import { AnyStateSchema } from "../state/schema.js";
|
|
12
10
|
import { ContextSchemaInit, ExtractStateType, ExtractUpdateType, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./types.js";
|
|
11
|
+
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeErrorHandler, NodeSpec } from "./graph.js";
|
|
12
|
+
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.js";
|
|
13
|
+
import { InferWriterType } from "../writer.js";
|
|
13
14
|
import { All, BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
14
15
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
15
16
|
|
|
@@ -22,22 +23,91 @@ interface StateGraphArgs<Channels extends object | unknown> {
|
|
|
22
23
|
__root__: Channels;
|
|
23
24
|
}>;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Retry and cache policies configurable on graph nodes.
|
|
28
|
+
*
|
|
29
|
+
* Use with {@link StateGraph.addNode} for per-node overrides, or with
|
|
30
|
+
* {@link StateGraph.setNodeDefaults} for graph-wide defaults applied at
|
|
31
|
+
* `compile()` time. Per-node values always take precedence over defaults.
|
|
32
|
+
* `setNodeDefaults` may be called before or after `addNode`, including as the
|
|
33
|
+
* last step before `compile()`.
|
|
34
|
+
*/
|
|
35
|
+
type NodePolicyOptions = {
|
|
36
|
+
/**
|
|
37
|
+
* Retry policy controlling backoff, max attempts, and which errors trigger
|
|
38
|
+
* a retry.
|
|
39
|
+
*
|
|
40
|
+
* @see {@link RetryPolicy}
|
|
41
|
+
*/
|
|
27
42
|
retryPolicy?: RetryPolicy;
|
|
28
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Cache policy controlling how node results are keyed and how long they
|
|
45
|
+
* persist.
|
|
46
|
+
*
|
|
47
|
+
* - Pass a {@link CachePolicy} object for fine-grained control (e.g. custom
|
|
48
|
+
* `keyFunc`, `ttl`).
|
|
49
|
+
* - Pass `true` to enable caching with default settings.
|
|
50
|
+
* - Pass `false` to disable caching.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link CachePolicy}
|
|
53
|
+
*/
|
|
54
|
+
cachePolicy?: CachePolicy | boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum duration for a single attempt of this node. Accepts a number of
|
|
57
|
+
* milliseconds (a hard wall-clock cap) or a {@link TimeoutPolicy} for finer
|
|
58
|
+
* control over run / idle timeouts. When exceeded, a {@link NodeTimeoutError}
|
|
59
|
+
* is raised and the node's retry policy (if any) decides whether to retry.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link TimeoutPolicy}
|
|
62
|
+
*/
|
|
63
|
+
timeout?: number | TimeoutPolicy;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolved retry and cache policies stored on a node after boolean
|
|
67
|
+
* `cachePolicy` shorthand is normalized.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
type NodePolicies = {
|
|
72
|
+
retryPolicy?: RetryPolicy; /** `false` opts out of graph defaults set via {@link StateGraph.setNodeDefaults}. */
|
|
73
|
+
cachePolicy?: CachePolicy | false; /** Resolved timeout policy after the `number` shorthand is normalized. */
|
|
74
|
+
timeout?: TimeoutPolicy;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Graph-wide node defaults captured by {@link StateGraph.setNodeDefaults} and
|
|
78
|
+
* resolved at {@link StateGraph.compile} time.
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
type ResolvedNodeDefaults = NodePolicies & {
|
|
83
|
+
/**
|
|
84
|
+
* Default error handler applied to every regular node that does not set its
|
|
85
|
+
* own via `addNode(..., { errorHandler })`. Never applied to error-handler
|
|
86
|
+
* nodes themselves — handlers must not catch their own failures.
|
|
87
|
+
*/
|
|
88
|
+
errorHandler?: NodeErrorHandler;
|
|
89
|
+
};
|
|
90
|
+
type StateGraphNodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput> & NodePolicies & {
|
|
91
|
+
input?: StateDefinition;
|
|
29
92
|
};
|
|
30
93
|
/**
|
|
31
94
|
* Options for StateGraph.addNode() method.
|
|
32
95
|
*
|
|
33
96
|
* @template Nodes - Node name constraints
|
|
34
97
|
* @template InputSchema - Per-node input schema type (inferred from options.input)
|
|
98
|
+
* @template HandlerState - State type passed to the node-level error handler
|
|
99
|
+
* @template Update - The update type the error handler may return
|
|
35
100
|
*/
|
|
36
|
-
type StateGraphAddNodeOptions<Nodes extends string = string, InputSchema extends StateDefinitionInit | undefined = StateDefinitionInit | undefined> = {
|
|
37
|
-
retryPolicy?: RetryPolicy;
|
|
38
|
-
cachePolicy?: CachePolicy | boolean;
|
|
101
|
+
type StateGraphAddNodeOptions<Nodes extends string = string, InputSchema extends StateDefinitionInit | undefined = StateDefinitionInit | undefined, HandlerState = (InputSchema extends StateDefinitionInit ? ExtractStateType<InputSchema> : unknown), Update = unknown> = {
|
|
39
102
|
input?: InputSchema;
|
|
40
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Optional node-level error handler. Runs only after this node's
|
|
105
|
+
* {@link RetryPolicy} is exhausted. Receives a {@link NodeError} with the
|
|
106
|
+
* failed node name and error, and may return a state update or `Command`.
|
|
107
|
+
*/
|
|
108
|
+
errorHandler?: NodeErrorHandler<HandlerState, Update, Nodes>;
|
|
109
|
+
} & NodePolicyOptions & AddNodeOptions<Nodes>;
|
|
110
|
+
type StateGraphAddNodeOptionsWithNodeInput<Nodes extends string, NodeInput, Update = unknown> = StateGraphAddNodeOptions<Nodes, StateDefinitionInit | undefined, NodeInput, Update>;
|
|
41
111
|
type StateGraphArgsWithStateSchema<SD extends StateDefinition, I extends StateDefinition, O extends StateDefinition> = {
|
|
42
112
|
stateSchema: AnnotationRoot<SD>;
|
|
43
113
|
input?: AnnotationRoot<I>;
|
|
@@ -176,6 +246,11 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
176
246
|
_interrupt: InterruptType;
|
|
177
247
|
/** @internal */
|
|
178
248
|
_writer: WriterType;
|
|
249
|
+
/**
|
|
250
|
+
* Graph-wide default node policies, resolved at `compile()` time.
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
_nodeDefaults: ResolvedNodeDefaults;
|
|
179
254
|
Node: StrictNodeAction<S, U, C, N, InterruptType, WriterType>;
|
|
180
255
|
/**
|
|
181
256
|
* Create a new StateGraph for building stateful, multi-step workflows.
|
|
@@ -226,6 +301,81 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
226
301
|
constructor(init: StateGraphInit<SD extends StateDefinitionInit ? SD : StateDefinitionInit, I, O, C extends ContextSchemaInit ? C : undefined, N, InterruptType, WriterType>);
|
|
227
302
|
/** @deprecated Use `Annotation.Root`, `StateSchema`, or Zod schemas instead. */
|
|
228
303
|
constructor(fields: StateGraphArgs<S>, contextSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
|
|
304
|
+
/**
|
|
305
|
+
* Set graph-wide default node policies that apply to every node in this
|
|
306
|
+
* graph.
|
|
307
|
+
*
|
|
308
|
+
* Per-node values passed to {@link addNode} always take precedence over these
|
|
309
|
+
* defaults. Defaults are resolved at {@link compile} time, so call order does
|
|
310
|
+
* not matter — you may call this before or after `addNode`, including as the
|
|
311
|
+
* last step before `compile()`. Calling it multiple times merges the provided
|
|
312
|
+
* fields, with later calls overriding earlier ones on a per-field basis.
|
|
313
|
+
*
|
|
314
|
+
* Policies set here are **not** inherited by subgraphs.
|
|
315
|
+
*
|
|
316
|
+
* `retryPolicy` and `timeout` defaults apply to **all** nodes, including
|
|
317
|
+
* auto-generated error-handler nodes. `cachePolicy` and `errorHandler`
|
|
318
|
+
* defaults apply to **regular nodes only** — caching an error-handler result
|
|
319
|
+
* is unsafe, and a handler must never catch its own (or another handler's)
|
|
320
|
+
* failure.
|
|
321
|
+
*
|
|
322
|
+
* @param defaults - The default node policies to apply.
|
|
323
|
+
* @returns The builder instance, for chaining.
|
|
324
|
+
*
|
|
325
|
+
* @example Call before `addNode`
|
|
326
|
+
* ```ts
|
|
327
|
+
* const graph = new StateGraph(State)
|
|
328
|
+
* .setNodeDefaults({
|
|
329
|
+
* retryPolicy: { maxAttempts: 3 },
|
|
330
|
+
* cachePolicy: { ttl: 60 },
|
|
331
|
+
* timeout: 60_000,
|
|
332
|
+
* errorHandler: (state, { node, error }) => ({ lastError: error.message }),
|
|
333
|
+
* })
|
|
334
|
+
* .addNode("a", nodeA)
|
|
335
|
+
* .addNode("b", nodeB, { retryPolicy: { maxAttempts: 5 } }) // overrides default
|
|
336
|
+
* .addEdge(START, "a")
|
|
337
|
+
* .compile();
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @example Call after `addNode`, immediately before `compile()`
|
|
341
|
+
* ```ts
|
|
342
|
+
* const graph = new StateGraph(State)
|
|
343
|
+
* .addNode("a", nodeA)
|
|
344
|
+
* .addNode("b", nodeB, { retryPolicy: { maxAttempts: 5 } }) // overrides default
|
|
345
|
+
* .addEdge(START, "a")
|
|
346
|
+
* .setNodeDefaults({
|
|
347
|
+
* retryPolicy: { maxAttempts: 3 },
|
|
348
|
+
* cachePolicy: { ttl: 60 },
|
|
349
|
+
* })
|
|
350
|
+
* .compile();
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
setNodeDefaults(defaults: NodePolicyOptions & {
|
|
354
|
+
/**
|
|
355
|
+
* Default node-level error handler invoked when any **regular** node
|
|
356
|
+
* raises and does not have its own handler set via
|
|
357
|
+
* `addNode(..., { errorHandler })`. Runs only after the failing node's
|
|
358
|
+
* retry policy is exhausted. It is never invoked when an error-handler
|
|
359
|
+
* node itself raises — handler failures fail the run.
|
|
360
|
+
*
|
|
361
|
+
* Because a single shared handler serves every node, its `state`
|
|
362
|
+
* argument is typed as `unknown`: at runtime it receives the **failing
|
|
363
|
+
* node's input** (see `addNode(..., { input })`), which may be a subset
|
|
364
|
+
* of the graph state and differs per node. Narrow it yourself before
|
|
365
|
+
* reading fields. The handler may still return a graph-level update (`U`)
|
|
366
|
+
* or route via `new Command({ goto })` to any node (`N`).
|
|
367
|
+
*/
|
|
368
|
+
errorHandler?: NodeErrorHandler<unknown, U, N>;
|
|
369
|
+
}): this;
|
|
370
|
+
/**
|
|
371
|
+
* Build the shared spec for a graph-wide default error handler, or
|
|
372
|
+
* `undefined` when {@link setNodeDefaults} did not configure one. The spec is
|
|
373
|
+
* installed under {@link DEFAULT_ERROR_HANDLER_NODE} for the duration of a
|
|
374
|
+
* single {@link compile} call and routes failures from every regular node
|
|
375
|
+
* that lacks its own handler.
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
protected _createDefaultErrorHandlerSpec(): StateGraphNodeSpec<S, U> | undefined;
|
|
229
379
|
/**
|
|
230
380
|
* Normalize all constructor input patterns to a unified StateGraphInit object.
|
|
231
381
|
* @internal
|
|
@@ -239,13 +389,13 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
239
389
|
get allEdges(): Set<[string, string]>;
|
|
240
390
|
_addSchema(stateDefinition: StateDefinitionInit): void;
|
|
241
391
|
addNode<K extends string, NodeMap extends Record<K, NodeAction<S, U, C, InterruptType, WriterType>>>(nodes: NodeMap): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in keyof NodeMap]: NodeMap[key] extends NodeAction<S, infer U, C, InterruptType, WriterType> ? U : never }>>;
|
|
242
|
-
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
243
|
-
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
244
|
-
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
245
|
-
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
246
|
-
addNode<K extends string, NodeInput = S>(key: K, action: NodeAction<NodeInput, U, C, InterruptType, WriterType>, options?:
|
|
392
|
+
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>][]): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
393
|
+
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema, ExtractStateType<InputSchema>, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
394
|
+
addNode<K extends string, InputSchema extends StateDefinitionInit, NodeOutput extends U = U>(key: K, action: NodeAction<ExtractStateType<InputSchema>, NodeOutput, C, InterruptType, WriterType>, options: StateGraphAddNodeOptions<N | K, InputSchema, ExtractStateType<InputSchema>, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
395
|
+
addNode<K extends string, NodeInput = S, NodeOutput extends U = U>(key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
396
|
+
addNode<K extends string, NodeInput = S>(key: K, action: NodeAction<NodeInput, U, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>): StateGraph<SD, S, U, N | K, I, O, C, NodeReturnType>;
|
|
247
397
|
addEdge(startKey: typeof START | N | N[], endKey: N | typeof END): this;
|
|
248
|
-
addSequence<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?:
|
|
398
|
+
addSequence<K extends string, NodeInput = S, NodeOutput extends U = U>(nodes: [key: K, action: NodeAction<NodeInput, NodeOutput, C, InterruptType, WriterType>, options?: StateGraphAddNodeOptionsWithNodeInput<N | K, NodeInput, U>][]): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in K]: NodeOutput }>>;
|
|
249
399
|
addSequence<K extends string, NodeMap extends Record<K, NodeAction<S, U, C, InterruptType, WriterType>>>(nodes: NodeMap): StateGraph<SD, S, U, N | K, I, O, C, MergeReturnType<NodeReturnType, { [key in keyof NodeMap]: NodeMap[key] extends NodeAction<S, infer U, C, InterruptType, WriterType> ? U : never }>>;
|
|
250
400
|
compile<const TTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []>({
|
|
251
401
|
checkpointer,
|
|
@@ -271,6 +421,28 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
271
421
|
*/
|
|
272
422
|
transformers?: TTransformers;
|
|
273
423
|
}): CompiledStateGraph<Prettify<S>, Prettify<U>, N, I, O, C, NodeReturnType, InterruptType, WriterType, TTransformers>;
|
|
424
|
+
/** @internal */
|
|
425
|
+
protected _compileResolved<const TTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []>({
|
|
426
|
+
checkpointer,
|
|
427
|
+
store,
|
|
428
|
+
cache,
|
|
429
|
+
interruptBefore,
|
|
430
|
+
interruptAfter,
|
|
431
|
+
name,
|
|
432
|
+
description,
|
|
433
|
+
transformers,
|
|
434
|
+
defaultErrorHandlerNode
|
|
435
|
+
}: {
|
|
436
|
+
checkpointer?: BaseCheckpointSaver | boolean;
|
|
437
|
+
store?: BaseStore;
|
|
438
|
+
cache?: BaseCache;
|
|
439
|
+
interruptBefore?: N[] | All;
|
|
440
|
+
interruptAfter?: N[] | All;
|
|
441
|
+
name?: string;
|
|
442
|
+
description?: string;
|
|
443
|
+
transformers?: TTransformers;
|
|
444
|
+
defaultErrorHandlerNode?: string;
|
|
445
|
+
}): CompiledStateGraph<Prettify<S>, Prettify<U>, N, I, O, C, NodeReturnType, InterruptType, WriterType, TTransformers>;
|
|
274
446
|
}
|
|
275
447
|
/**
|
|
276
448
|
* Final result from building and compiling a {@link StateGraph}.
|
|
@@ -305,6 +477,10 @@ declare class StateGraph<SD extends StateDefinitionInit | unknown, S = ExtractSt
|
|
|
305
477
|
*
|
|
306
478
|
* @typeParam WriterType - The type for custom stream writers. Used with the `writer`
|
|
307
479
|
* option to enable typed custom streaming from within nodes.
|
|
480
|
+
*
|
|
481
|
+
* @typeParam TStreamTransformers - Stream transformer factories registered at
|
|
482
|
+
* compile time via the `transformers` option. Used to type extensions on
|
|
483
|
+
* `streamEvents(..., { version: "v3" })`.
|
|
308
484
|
*/
|
|
309
485
|
declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends StateDefinitionInit = StateDefinition, O extends StateDefinitionInit = StateDefinition, C extends StateDefinitionInit = StateDefinition, NodeReturnType = unknown, InterruptType = unknown, WriterType = unknown, TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []> extends CompiledGraph<N, S, U, ExtractStateType<C>, ExtractUpdateType<I, ExtractStateType<I>>, ExtractStateType<O>, NodeReturnType, CommandInstance<InferInterruptResumeType<InterruptType>, Prettify<U>, N>, InferWriterType<WriterType>, TStreamTransformers> {
|
|
310
486
|
builder: StateGraph<unknown, S, U, N, I, O, C, NodeReturnType>;
|
|
@@ -334,5 +510,5 @@ declare class CompiledStateGraph<S, U, N extends string = typeof START, I extend
|
|
|
334
510
|
protected _validateContext(config: Partial<Record<string, unknown>>): Promise<Partial<Record<string, unknown>>>;
|
|
335
511
|
}
|
|
336
512
|
//#endregion
|
|
337
|
-
export { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec };
|
|
513
|
+
export { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec };
|
|
338
514
|
//# sourceMappingURL=state.d.ts.map
|