Class: RobotLab::Task
- Inherits:
-
Object
- Object
- RobotLab::Task
- Defined in:
- lib/robot_lab/task.rb
Overview
Wraps a Robot for use as a pipeline step with per-task configuration
Task provides a way to pass step-specific context, MCP servers, tools, and memory to individual robots within a network pipeline. The task's context is deep-merged with the network's run parameters.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
The task/step name.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Instance Method Summary collapse
-
#call(result) ⇒ SimpleFlow::Result
SimpleFlow step interface.
-
#initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil, network: nil) ⇒ Task
constructor
Creates a new Task instance.
-
#to_h ⇒ Hash
Converts the task to a hash representation.
Constructor Details
#initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil, network: nil) ⇒ Task
Creates a new Task instance.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/robot_lab/task.rb', line 42 def initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil, network: nil) @name = name.to_sym @robot = robot @context = context @mcp = mcp @tools = tools @memory = memory @config = config @network = network end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns the task/step name.
31 32 33 |
# File 'lib/robot_lab/task.rb', line 31 def name @name end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
31 |
# File 'lib/robot_lab/task.rb', line 31 attr_reader :name, :robot |
Instance Method Details
#call(result) ⇒ SimpleFlow::Result
SimpleFlow step interface
Enhances the result's run_params with task-specific configuration before delegating to the wrapped robot.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/robot_lab/task.rb', line 61 def call(result) context = TaskHookContext.new( network: @network, task: self, robot: @robot, memory: @memory || @network&.memory, config: @config ) RobotLab::Hooks.run(:task, context, registries: [RobotLab.hooks, @network&.hooks]) do @robot.call(enhanced_result(result)) end end |
#to_h ⇒ Hash
Converts the task to a hash representation.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/robot_lab/task.rb', line 79 def to_h { name: @name, robot: @robot.name, context: @context, mcp: @mcp, tools: @tools, memory: @memory ? true : nil }.compact end |