Class: SwarmSDK::Workflow::Builder
- Inherits:
-
Builders::BaseBuilder
- Object
- Builders::BaseBuilder
- SwarmSDK::Workflow::Builder
- Defined in:
- lib/swarm_sdk/workflow/builder.rb
Overview
Builder provides DSL for building multi-node workflows This is the top-level builder accessed via SwarmSDK.workflow
The DSL enables:
- Node-based workflow configuration
- Agent delegation per node
- Input/output transformers for data flow
- Context preservation across nodes
Class Method Summary collapse
Instance Method Summary collapse
-
#build_swarm ⇒ Object
Build the actual Workflow instance.
-
#initialize(allow_filesystem_tools: nil) ⇒ Builder
constructor
A new instance of Builder.
-
#node(name) { ... } ⇒ void
Define a node (mini-swarm execution stage).
-
#start_node(name) ⇒ void
Set the starting node for workflow execution.
Methods inherited from Builders::BaseBuilder
#agent, #all_agents, #id, #name, #scratchpad, #swarms
Constructor Details
#initialize(allow_filesystem_tools: nil) ⇒ Builder
Returns a new instance of Builder.
57 58 59 60 61 |
# File 'lib/swarm_sdk/workflow/builder.rb', line 57 def initialize(allow_filesystem_tools: nil) super @nodes = {} @start_node = nil end |
Class Method Details
.build(allow_filesystem_tools: nil, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/swarm_sdk/workflow/builder.rb', line 50 def build(allow_filesystem_tools: nil, &block) builder = new(allow_filesystem_tools: allow_filesystem_tools) builder.instance_eval(&block) builder.build_swarm end |
Instance Method Details
#build_swarm ⇒ Object
Build the actual Workflow instance
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/swarm_sdk/workflow/builder.rb', line 104 def build_swarm # Returns Workflow despite method name raise ConfigurationError, "Workflow name not set. Use: name 'My Workflow'" unless @swarm_name raise ConfigurationError, "No nodes defined. Use: node :name { ... }" if @nodes.empty? raise ConfigurationError, "start_node not set. Use: start_node :name" unless @start_node # Validate filesystem tools BEFORE building validate_all_agents_filesystem_tools if @all_agents_config validate_agent_filesystem_tools build_workflow end |
#node(name) { ... } ⇒ void
This method returns an undefined value.
Define a node (mini-swarm execution stage)
Nodes enable multi-stage workflows where different agent teams collaborate in sequence. Each node is an independent swarm execution.
84 85 86 87 88 |
# File 'lib/swarm_sdk/workflow/builder.rb', line 84 def node(name, &block) builder = Workflow::NodeBuilder.new(name) builder.instance_eval(&block) @nodes[name] = builder end |
#start_node(name) ⇒ void
This method returns an undefined value.
Set the starting node for workflow execution
Required when nodes are defined. Specifies which node to execute first.
99 100 101 |
# File 'lib/swarm_sdk/workflow/builder.rb', line 99 def start_node(name) @start_node = name.to_sym end |