Narrows the GraphState type used in conditional-edge callbacks.
Defaults to the base GraphState when not specified.
Zod schemas for the three GraphState generic partitions.
input — shape of the frozen user-provided input passed to invoke().scratch — shape of the mutable node-to-node communication bag.artifacts — shape of the accumulated external outputs returned by invoke().Zod schema for GraphState.input.
Zod schema for GraphState.scratch.
Zod schema for GraphState.artifacts.
Optional config: { Optional graph-wide configuration overrides.
Optional reducers?: StateReducersField-level merge strategies for scratch and artifacts fields.
Optional memoryGraph-wide memory consistency mode (default: 'snapshot').
Optional checkpointGraph-wide checkpoint persistence strategy (default: 'none').
Add a node to the graph.
The node's id field is overridden with the supplied id argument so the
user-declared identifier is always canonical.
Unique node identifier within this graph. Must not equal START or END.
A GraphNode produced by one of the factory helpers in builders/nodes.ts.
this for chaining.
When id has already been registered.
Add a conditional edge whose target is determined at runtime by a callback.
The condition function receives the current GraphState and returns the id of
the next node to activate. The returned id is resolved against the edge list at
runtime; no compile-time validation of the returned id is performed.
Because conditional edges encode the target resolution in a closure, the target
field stored in the IR is set to the placeholder '__CONDITIONAL__'.
Source node id (or START).
Pure function (state: TState) => string returning the next node id.
this for chaining.
Add a discovery edge whose target is resolved at runtime via the capability discovery engine.
When discovery returns no result, execution falls back to config.fallbackTarget (if provided)
or the placeholder '__DISCOVERY__'.
Source node id.
Discovery configuration.
config.query is forwarded to the CapabilityDiscoveryEngine.
config.kind optionally restricts discovery to a specific capability kind.
config.fallbackTarget is used when discovery resolves no target.
Semantic query forwarded to the capability discovery engine.
Optional kind?: "tool" | "skill" | "extension" | "any"Optional capability kind filter ('tool', 'skill', 'extension', or 'any').
Optional fallbackFallback node id used when discovery resolves no target.
this for chaining.
Add a personality edge whose target is chosen based on the agent's current trait value.
At runtime the engine reads config.trait from the agent's HEXACO/PAD state and routes
to config.above when the value is ≥ config.threshold, or config.below otherwise.
Source node id.
Personality routing configuration.
config.trait identifies the HEXACO/PAD value to inspect.
config.threshold is the decision boundary in the 0–1 range.
config.above is used when the trait value is greater than or equal to the threshold.
config.below is used when the trait value is below the threshold.
HEXACO/PAD trait name, e.g. 'conscientiousness' or 'openness'.
Decision threshold in range 0–1.
Target node id when the trait value is at or above the threshold.
Target node id when the trait value is below the threshold.
this for chaining.
Compile the builder state into a CompiledAgentGraph ready for execution.
Compilation steps:
GraphCompiler.compile() to produce the raw CompiledExecutionGraph IR.GraphValidator.validate() to assert structural
correctness — any validation error or warning causes an exception.CompiledAgentGraph instance.Pass { validate: false } to skip validation (e.g. for cyclic graphs under construction).
Optional options: { Optional compilation flags.
options.checkpointStore overrides the default InMemoryCheckpointStore.
options.validate can be set to false to skip structural validation.
Optional checkpointCustom checkpoint persistence backend. Defaults to an in-memory store.
Optional validate?: booleanWhether to run GraphValidator.validate() before returning.
Defaults to true. Set to false for cyclic or incomplete graphs under construction.
A CompiledAgentGraph instance ready for invoke() / stream() / resume().
When validation is enabled and the graph contains structural errors or warnings.
Fluent builder for agent execution graphs.
Each mutating method returns
thisto support method chaining. All state is held in private Maps/arrays; nothing is compiled or validated until.compile()is called.