30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/legion/cli/chat/tools/cost_summary.rb', line 30
def execute(action: 'summary', worker_id: nil, limit: 5)
case action.to_s
when 'top'
handle_top(limit.to_i.clamp(1, 20))
when 'worker'
return 'worker_id is required for the "worker" action.' if worker_id.nil? || worker_id.strip.empty?
handle_worker(worker_id.strip)
else
handle_summary
end
rescue Errno::ECONNREFUSED
'Legion daemon not running (cannot reach cost API).'
rescue StandardError => e
Legion::Logging.warn("CostSummary#execute failed: #{e.message}") if defined?(Legion::Logging)
"Error fetching cost data: #{e.message}"
end
|