Class: Clacky::Tools::Base
- Inherits:
-
Object
- Object
- Clacky::Tools::Base
- Defined in:
- lib/clacky/tools/base.rb
Direct Known Subclasses
Browser, Edit, FileReader, Glob, Grep, Hello, InvokeSkill, RequestUserFeedback, Terminal, TodoManager, TrashManager, WebFetch, WebSearch, Write
Class Attribute Summary collapse
-
.tool_category ⇒ Object
Returns the value of attribute tool_category.
-
.tool_description ⇒ Object
Returns the value of attribute tool_description.
-
.tool_name ⇒ Object
Returns the value of attribute tool_name.
-
.tool_parameters ⇒ Object
Returns the value of attribute tool_parameters.
Instance Attribute Summary collapse
-
#agent ⇒ Object
Host agent, injected at registration for extension tools so they can reach its public API (fan_out_labeled, fork_subagent, skill_loader).
Instance Method Summary collapse
- #category ⇒ Object
- #description ⇒ Object
-
#execute(**_args) ⇒ Object
Execute the tool - must be implemented by subclasses.
-
#format_call(args) ⇒ String
Format tool call for display - can be overridden by subclasses.
-
#format_result(result) ⇒ String
Format tool result for display - can be overridden by subclasses.
- #name ⇒ Object
- #parameters ⇒ Object
-
#to_function_definition ⇒ Object
Convert to OpenAI function calling format.
Class Attribute Details
.tool_category ⇒ Object
Returns the value of attribute tool_category.
9 10 11 |
# File 'lib/clacky/tools/base.rb', line 9 def tool_category @tool_category end |
.tool_description ⇒ Object
Returns the value of attribute tool_description.
9 10 11 |
# File 'lib/clacky/tools/base.rb', line 9 def tool_description @tool_description end |
.tool_name ⇒ Object
Returns the value of attribute tool_name.
9 10 11 |
# File 'lib/clacky/tools/base.rb', line 9 def tool_name @tool_name end |
.tool_parameters ⇒ Object
Returns the value of attribute tool_parameters.
9 10 11 |
# File 'lib/clacky/tools/base.rb', line 9 def tool_parameters @tool_parameters end |
Instance Attribute Details
#agent ⇒ Object
Host agent, injected at registration for extension tools so they can reach its public API (fan_out_labeled, fork_subagent, skill_loader).
14 15 16 |
# File 'lib/clacky/tools/base.rb', line 14 def agent @agent end |
Instance Method Details
#category ⇒ Object
28 29 30 |
# File 'lib/clacky/tools/base.rb', line 28 def category self.class.tool_category || "general" end |
#description ⇒ Object
20 21 22 |
# File 'lib/clacky/tools/base.rb', line 20 def description self.class.tool_description end |
#execute(**_args) ⇒ Object
Execute the tool - must be implemented by subclasses
33 34 35 |
# File 'lib/clacky/tools/base.rb', line 33 def execute(**_args) raise NotImplementedError, "#{self.class.name} must implement #execute" end |
#format_call(args) ⇒ String
Format tool call for display - can be overridden by subclasses
64 65 66 |
# File 'lib/clacky/tools/base.rb', line 64 def format_call(args) "#{name}(...)" end |
#format_result(result) ⇒ String
Format tool result for display - can be overridden by subclasses
71 72 73 74 75 76 77 78 79 |
# File 'lib/clacky/tools/base.rb', line 71 def format_result(result) if result.is_a?(Hash) && result[:message] result[:message] elsif result.is_a?(String) result.length > 100 ? "#{result[0..100]}..." : result else "Done" end end |
#name ⇒ Object
16 17 18 |
# File 'lib/clacky/tools/base.rb', line 16 def name self.class.tool_name end |
#parameters ⇒ Object
24 25 26 |
# File 'lib/clacky/tools/base.rb', line 24 def parameters self.class.tool_parameters end |
#to_function_definition ⇒ Object
Convert to OpenAI function calling format
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/clacky/tools/base.rb', line 82 def to_function_definition { type: "function", function: { name: name, description: description, parameters: parameters } } end |