/** * Graph Workflow Builder * * Fluent API for constructing GraphWorkflowConfig programmatically. * Provides methods for adding nodes, edges, fork/join control flow, and handoff configuration. */ import type { GraphWorkflowConfig, BranchCondition } from './graph'; import type { PipelineHooks } from './pipeline'; /** * Node configuration for addNode method */ type NodeConfig = { type: 'agent'; agentId: string; expose?: string[]; } | { type: 'function'; fn: (ctx: any) => Promise | unknown; expose?: string[]; } | { type: 'conditional'; condition: (ctx: any) => boolean | Promise; expose?: string[]; } | { type: 'pipeline'; pipelineId: string; expose?: string[]; }; /** * Fluent builder for graph workflows. * * @example * const workflow = new GraphWorkflowBuilder('approval-workflow') * .addNode('review', { type: 'agent', agentId: 'reviewer', expose: ['decision'] }) * .addNode('approve', { type: 'agent', agentId: 'approver' }) * .addNode('reject', { type: 'function', fn: async (ctx) => ({ rejected: true }) }) * .addEdge('review', 'approve', { condition: { field: 'review.decision', operator: 'equals', value: 'approved' } }) * .addEdge('review', 'reject', { condition: { field: 'review.decision', operator: 'equals', value: 'rejected' } }) * .setDefaultEdge('review', 'approve') * .setEntry('review') * .build(); */ export declare class GraphWorkflowBuilder { private id; private nodes; private edges; private entryNode?; private handoffs; private hooks?; private nodeIds; constructor(id: string); /** * Add a node to the graph. * * @param id - Unique node identifier * @param config - Node configuration (type, agent/function/condition, expose fields) * @returns this for chaining * @throws Error if node ID already exists */ addNode(id: string, config: NodeConfig): this; /** * Add a fork node for explicit parallelism. * * @param id - Unique fork node identifier * @param branches - Array of node IDs to execute in parallel * @returns this for chaining * @throws Error if node ID already exists */ addForkNode(id: string, branches: string[]): this; /** * Add a join node to wait for parallel branches. * * @param id - Unique join node identifier * @param sources - Array of node IDs to wait for * @param mergeStrategy - How to merge outputs ('shallow-merge' | 'array'), defaults to 'shallow-merge' * @returns this for chaining * @throws Error if node ID already exists */ addJoinNode(id: string, sources: string[], mergeStrategy?: 'shallow-merge' | 'array'): this; /** * Add an edge connecting two nodes. * * @param from - Source node ID * @param to - Target node ID * @param options - Optional condition and/or default flag * @returns this for chaining */ addEdge(from: string, to: string, options?: { condition?: BranchCondition; default?: boolean; }): this; /** * Set a default edge from a node. * Shorthand for addEdge with default: true. * * @param from - Source node ID * @param to - Target node ID * @returns this for chaining */ setDefaultEdge(from: string, to: string): this; /** * Configure handoff permissions. * * @param sourceAgent - Source agent ID * @param targets - Array of allowed target agent IDs * @returns this for chaining */ allowHandoff(sourceAgent: string, targets: string[]): this; /** * Set the entry node where execution begins. * * @param nodeId - ID of the entry node * @returns this for chaining */ setEntry(nodeId: string): this; /** * Set lifecycle hooks for the workflow. * * @param hooks - Pipeline hooks configuration * @returns this for chaining */ setHooks(hooks: PipelineHooks): this; /** * Build and validate the graph workflow configuration. * * @returns Validated GraphWorkflowConfig * @throws Error if entry node not set * @throws GraphValidationError if validation fails */ build(): GraphWorkflowConfig; } export {}; //# sourceMappingURL=graph-builder.d.ts.map