Class: Smith::Workflow::RunResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/smith/workflow/run_result.rb

Overview

rubocop:disable Style/RedundantStructKeywordInit

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def context
  @context
end

#outcomeObject

Returns the value of attribute outcome

Returns:

  • (Object)

    the current value of outcome



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def outcome
  @outcome
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def output
  @output
end

#session_messagesObject

Returns the value of attribute session_messages

Returns:

  • (Object)

    the current value of session_messages



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def session_messages
  @session_messages
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def state
  @state
end

#stepsObject

Returns the value of attribute steps

Returns:

  • (Object)

    the current value of steps



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def steps
  @steps
end

#tool_resultsObject

Returns the value of attribute tool_results

Returns:

  • (Object)

    the current value of tool_results



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def tool_results
  @tool_results
end

#total_costObject

Returns the value of attribute total_cost

Returns:

  • (Object)

    the current value of total_cost



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def total_cost
  @total_cost
end

#total_tokensObject

Returns the value of attribute total_tokens

Returns:

  • (Object)

    the current value of total_tokens



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def total_tokens
  @total_tokens
end

#usage_entriesObject

Returns the value of attribute usage_entries

Returns:

  • (Object)

    the current value of usage_entries



6
7
8
# File 'lib/smith/workflow/run_result.rb', line 6

def usage_entries
  @usage_entries
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/smith/workflow/run_result.rb', line 8

def done?
  state_named?(:done)
end

#failed?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/smith/workflow/run_result.rb', line 12

def failed?
  state_named?(:failed)
end

#failed_transitionObject



36
37
38
# File 'lib/smith/workflow/run_result.rb', line 36

def failed_transition
  failure_detail&.fetch(:transition)
end

#failure_detailObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/smith/workflow/run_result.rb', line 40

def failure_detail
  failed_step = steps.reverse.find { |step| step[:error] }
  return nil unless failed_step

  {
    transition: failed_step[:transition],
    from: failed_step[:from],
    to: failed_step[:to],
    error: failed_step[:error]
  }
end

#last_errorObject



32
33
34
# File 'lib/smith/workflow/run_result.rb', line 32

def last_error
  steps.reverse.map { |step| step[:error] }.compact.first
end

#outcome_kindObject



24
25
26
# File 'lib/smith/workflow/run_result.rb', line 24

def outcome_kind
  outcome&.dig(:kind)
end

#outcome_payloadObject



28
29
30
# File 'lib/smith/workflow/run_result.rb', line 28

def outcome_payload
  outcome&.dig(:payload)
end

#state_named?(name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/smith/workflow/run_result.rb', line 16

def state_named?(name)
  state == name || state.to_s == name.to_s
end

#terminal_outputObject



20
21
22
# File 'lib/smith/workflow/run_result.rb', line 20

def terminal_output
  output
end