Class: Legion::CLI::Chat::Tools::KnowledgeMaintenance

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

Constant Summary collapse

DEFAULT_PORT =
4567
DEFAULT_HOST =
'127.0.0.1'
VALID_ACTIONS =
%w[decay_cycle corroboration].freeze

Instance Method Summary collapse

Instance Method Details

#execute(action:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/legion/cli/chat/tools/knowledge_maintenance.rb', line 28

def execute(action:)
  action = action.to_s.strip
  return "Invalid action: #{action}. Must be one of: #{VALID_ACTIONS.join(', ')}" unless VALID_ACTIONS.include?(action)

  data = run_maintenance(action)
  return "Apollo error: #{data[:error]}" if data[:error]

  format_result(action, data)
rescue Errno::ECONNREFUSED
  'Apollo unavailable (daemon not running).'
rescue StandardError => e
  Legion::Logging.warn("KnowledgeMaintenance#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error running maintenance: #{e.message}"
end