Class: Roast::Workflow::InputExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/workflow/input_executor.rb

Overview

Handles execution of input steps

Instance Method Summary collapse

Constructor Details

#initialize(workflow, context_path, state_manager, workflow_executor = nil) ⇒ InputExecutor

Returns a new instance of InputExecutor.



7
8
9
10
11
12
# File 'lib/roast/workflow/input_executor.rb', line 7

def initialize(workflow, context_path, state_manager, workflow_executor = nil)
  @workflow = workflow
  @context_path = context_path
  @state_manager = state_manager
  @workflow_executor = workflow_executor
end

Instance Method Details

#execute_input(input_config) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/roast/workflow/input_executor.rb', line 14

def execute_input(input_config)
  # Interpolate the prompt if workflow executor is available
  if @workflow_executor && input_config["prompt"]
    interpolated_config = input_config.dup
    interpolated_config["prompt"] = @workflow_executor.interpolate(input_config["prompt"])
  else
    interpolated_config = input_config
  end

  # Create and execute an InputStep
  input_step = InputStep.new(
    @workflow,
    config: interpolated_config,
    name: input_config["name"] || "input_#{Time.now.to_i}",
    context_path: @context_path,
  )

  result = input_step.call

  # Store in 'previous' for conditional checks
  @workflow.output["previous"] = result
  @state_manager.save_state("previous", result)

  result
end