Class: SharedTools::Tools::SystemInfoTool

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/shared_tools/tools/system_info_tool.rb

Overview

A tool for retrieving system information including OS, CPU, memory, and disk details. Provides cross-platform support for macOS, Linux, and Windows.

Examples:

tool = SharedTools::Tools::SystemInfoTool.new
result = tool.execute(category: 'all')
puts result[:os][:name]        # "macOS"
puts result[:memory][:total]   # "32 GB"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil) ⇒ SystemInfoTool



58
59
60
# File 'lib/shared_tools/tools/system_info_tool.rb', line 58

def initialize(logger: nil)
  @logger = logger || RubyLLM.logger
end

Class Method Details

.nameObject



16
# File 'lib/shared_tools/tools/system_info_tool.rb', line 16

def self.name = 'system_info'

Instance Method Details

#execute(category: 'all') ⇒ Hash

Execute system info retrieval



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/shared_tools/tools/system_info_tool.rb', line 66

def execute(category: 'all')
  @logger.info("SystemInfoTool#execute category=#{category.inspect}")

  case category.to_s.downcase
  when 'all'
    get_all_info
  when 'os'
    { success: true, os: get_os_info }
  when 'cpu'
    { success: true, cpu: get_cpu_info }
  when 'memory'
    { success: true, memory: get_memory_info }
  when 'disk'
    { success: true, disk: get_disk_info }
  when 'network'
    { success: true, network: get_network_info }
  else
    {
      success: false,
      error: "Unknown category: #{category}. Valid categories are: all, os, cpu, memory, disk, network"
    }
  end
rescue => e
  @logger.error("SystemInfoTool error: #{e.message}")
  {
    success: false,
    error: e.message
  }
end