Class: SharedTools::Tools::ClipboardTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::ClipboardTool
- Defined in:
- lib/shared_tools/tools/clipboard_tool.rb
Overview
A tool for reading from and writing to the system clipboard. Supports macOS (pbcopy/pbpaste), Linux (xclip/xsel), and Windows (clip).
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(action:, content: nil) ⇒ Hash
Execute clipboard action.
-
#initialize(logger: nil) ⇒ ClipboardTool
constructor
A new instance of ClipboardTool.
Constructor Details
#initialize(logger: nil) ⇒ ClipboardTool
Returns a new instance of ClipboardTool.
60 61 62 |
# File 'lib/shared_tools/tools/clipboard_tool.rb', line 60 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' |
Instance Method Details
#execute(action:, content: nil) ⇒ Hash
Execute clipboard action
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/shared_tools/tools/clipboard_tool.rb', line 69 def execute(action:, content: nil) @logger.info("ClipboardTool#execute action=#{action.inspect}") case action.to_s.downcase when 'read' read_clipboard when 'write' write_clipboard(content) when 'clear' clear_clipboard else { success: false, error: "Unknown action: #{action}. Valid actions are: read, write, clear" } end rescue => e @logger.error("ClipboardTool error: #{e.message}") { success: false, error: e. } end |