Class: SharedTools::Tools::ClipboardTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::ClipboardTool
- Defined in:
- lib/shared_tools/tools/clipboard_tool.rb
Overview
Read, write, and clear the system clipboard. Supports macOS (pbcopy/pbpaste), Linux (xclip or xsel), and Windows (clip/PowerShell).
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(action:, text: nil) ⇒ Hash
Result.
-
#initialize(logger: nil) ⇒ ClipboardTool
constructor
A new instance of ClipboardTool.
Constructor Details
#initialize(logger: nil) ⇒ ClipboardTool
Returns a new instance of ClipboardTool.
34 35 36 |
# File 'lib/shared_tools/tools/clipboard_tool.rb', line 34 def initialize(logger: nil) @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
16 |
# File 'lib/shared_tools/tools/clipboard_tool.rb', line 16 def self.name = 'clipboard_tool' |
Instance Method Details
#execute(action:, text: nil) ⇒ Hash
Returns result.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/shared_tools/tools/clipboard_tool.rb', line 41 def execute(action:, text: nil) @logger.info("ClipboardTool#execute action=#{action}") case action.to_s.downcase when 'read' then read_clipboard when 'write' then write_clipboard(text) when 'clear' then clear_clipboard else { success: false, error: "Unknown action '#{action}'. Use: read, write, clear" } end rescue => e @logger.error("ClipboardTool error: #{e.}") { success: false, error: e. } end |