Skip to main content

withGuards()

withGuards(builder, config?): GraphBuilder

Defined in: guards.ts:327

Create a guard-aware wrapper around a GraphBuilder.

The returned builder has an identical interface to the original but intercepts endNode and build calls to check for guard violations. Violations are handled according to the onViolation configuration.

Parameters​

ParameterTypeDescription
builderGraphBuilderThe original GraphBuilder to wrap.
config?GuardConfigGuard configuration.

Returns​

GraphBuilder

A GraphBuilder with identical interface but guard protection.

Example​

const raw = createGraphBuilder({ agentId: 'test' });
const guarded = withGuards(raw, { maxDepth: 5, onViolation: 'abort' });

// Use exactly like a normal builder
const root = guarded.startNode({ type: 'agent', name: 'main' });
guarded.endNode(root); // Will check for violations