Class: SharedTools::Tools::NotificationTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::NotificationTool
- Defined in:
- lib/shared_tools/tools/notification_tool.rb
Overview
Cross-platform notification tool for desktop banners, modal dialogs, and TTS.
Supports macOS (osascript, say) and Linux (notify-send, zenity/terminal, espeak-ng/espeak). On unsupported platforms all actions return false.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(action:, message: nil, title: nil, subtitle: nil, sound: nil, buttons: nil, default_button: nil, voice: nil, rate: nil) ⇒ Object
-
#initialize(driver: nil) ⇒ NotificationTool
constructor
A new instance of NotificationTool.
Constructor Details
#initialize(driver: nil) ⇒ NotificationTool
Returns a new instance of NotificationTool.
57 58 59 |
# File 'lib/shared_tools/tools/notification_tool.rb', line 57 def initialize(driver: nil) @driver = driver || default_driver end |
Class Method Details
.name ⇒ Object
21 |
# File 'lib/shared_tools/tools/notification_tool.rb', line 21 def self.name = 'notification_tool' |
Instance Method Details
#execute(action:, message: nil, title: nil, subtitle: nil, sound: nil, buttons: nil, default_button: nil, voice: nil, rate: nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/shared_tools/tools/notification_tool.rb', line 61 def execute(action:, message: nil, title: nil, subtitle: nil, sound: nil, buttons: nil, default_button: nil, voice: nil, rate: nil) ||= ['OK'] case action when 'notify' return missing_param('message', 'notify') if blank?() @driver.notify(message:, title:, subtitle:, sound:) when 'alert' return missing_param('message', 'alert') if blank?() @driver.alert(message:, title:, buttons:, default_button:) when 'speak' return missing_param('message', 'speak') if blank?() @driver.speak(text: , voice:, rate:) else { success: false, error: "Unknown action: #{action.inspect}. Must be notify, alert, or speak." } end end |