blob: c99fa561e2ea1da6d032c4fb3cd36df4501dab4f [file] [log] [blame]
package tools
import (
"github.com/invopop/jsonschema"
)
type Tool interface {
Name() string
Description() string
InputSchema() *jsonschema.Schema
Call(inp string) (string, error)
}
type Registry interface {
All() []Tool
Add(tool Tool)
Get(name string) Tool
}
type InMemoryRegistry struct {
tools map[string]Tool
}
func NewInMemoryRegistry() *InMemoryRegistry {
return &InMemoryRegistry{
make(map[string]Tool),
}
}
func (r *InMemoryRegistry) Add(tool Tool) {
r.tools[tool.Name()] = tool
}
func (r *InMemoryRegistry) All() []Tool {
var ret []Tool
for _, t := range r.tools {
ret = append(ret, t)
}
return ret
}
func (r *InMemoryRegistry) Get(name string) Tool {
return r.tools[name]
}