Class: Legion::CLI::Chat::Tools::ManageSchedules

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#execute(action:) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/legion/cli/chat/tools/manage_schedules.rb', line 32

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 schedules API).'
rescue StandardError => e
  Legion::Logging.warn("ManageSchedules#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error managing schedules: #{e.message}"
end