Class: Nanobot::Agent::Tools::ScheduleList
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Nanobot::Agent::Tools::ScheduleList
- Defined in:
- lib/nanobot/agent/tools/schedule.rb
Overview
Tool for listing all scheduled tasks
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(store:) ⇒ ScheduleList
constructor
A new instance of ScheduleList.
Constructor Details
#initialize(store:) ⇒ ScheduleList
Returns a new instance of ScheduleList.
52 53 54 55 |
# File 'lib/nanobot/agent/tools/schedule.rb', line 52 def initialize(store:) super() @store = store end |
Instance Method Details
#execute ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/nanobot/agent/tools/schedule.rb', line 57 def execute schedules = @store.list return 'No scheduled tasks.' if schedules.empty? lines = schedules.map do |s| status = s.enabled ? 'active' : 'disabled' prompt_preview = s.prompt.length > 80 ? "#{s.prompt[0..77]}..." : s.prompt "- [#{s.id[0..7]}] #{s.kind}(#{s.expression}) #{status} | " \ "next: #{s.next_run_at || 'n/a'} | #{prompt_preview}" end "Scheduled tasks (#{schedules.size}):\n#{lines.join("\n")}" end |