Class: Legion::CLI::Chat::Tools::ManageTasks

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/legion/cli/chat/tools/manage_tasks.rb

Constant Summary collapse

VALID_ACTIONS =
%w[list show logs trigger].freeze
DEFAULT_PORT =
4567
DEFAULT_HOST =
'127.0.0.1'

Instance Method Summary collapse

Instance Method Details

#execute(action:) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/cli/chat/tools/manage_tasks.rb', line 47

def execute(action:, **)
  action = action.to_s.strip
  return "Invalid action: #{action}. Use: #{VALID_ACTIONS.join(', ')}" unless VALID_ACTIONS.include?(action)

  send(:"handle_#{action}", **)
rescue Errno::ECONNREFUSED
  'Legion daemon not running (cannot reach task API).'
rescue StandardError => e
  Legion::Logging.warn("ManageTasks#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error managing tasks: #{e.message}"
end