Class: Kward::Tools::Base
- Inherits:
-
Object
- Object
- Kward::Tools::Base
- Defined in:
- lib/kward/tools/base.rb
Overview
Base class for model-callable tools and their JSON schemas.
Concrete built-in tools initialize this class with their model-facing name,
description, and strict argument schema, then implement call to perform
the operation. Tool execution is coordinated by Kward::ToolRegistry.
Direct Known Subclasses
AskUserQuestion, CodeSearch, ContextBudgetStats, ContextForTask, DateTime, EditEditorBuffer, EditFile, FetchContent, FetchRaw, GenerateImage, GitCommit, ListDirectory, MCPTool, OpenEditor, PluginTool, PrepareShellCommand, ReadFile, ReadSkill, ReplaceEditorBuffer, RetrieveToolOutput, RunShellCommand, SummarizeFileStructure, TypeSafeEvaluate, WebSearch, WriteFile
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Function name exposed to the model.
Instance Method Summary collapse
-
#initialize(name, description, properties: {}, required: []) ⇒ Base
constructor
Creates a tool schema definition shared by all concrete tool wrappers.
-
#schema ⇒ Hash
Returns the strict JSON schema advertised to model providers.
Constructor Details
#initialize(name, description, properties: {}, required: []) ⇒ Base
Creates a tool schema definition shared by all concrete tool wrappers.
24 25 26 27 28 29 |
# File 'lib/kward/tools/base.rb', line 24 def initialize(name, description, properties: {}, required: []) @name = name @description = description @properties = properties @required = required end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns function name exposed to the model.
16 17 18 |
# File 'lib/kward/tools/base.rb', line 16 def name @name end |
Instance Method Details
#schema ⇒ Hash
Returns the strict JSON schema advertised to model providers.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kward/tools/base.rb', line 35 def schema { type: "function", function: { name: @name, description: @description, parameters: { type: "object", properties: sorted_properties, required: @required.sort, additionalProperties: false } } } end |