Files
agents_and_robots/pkg/tools/registry.go
T
2026-03-03 23:19:23 +00:00

59 lines
1.4 KiB
Go

// Package tools defines pure, declarative tool specifications.
// No execution happens here — only data describing what tools exist and their contracts.
package tools
// ToolKind identifies the category of a tool.
type ToolKind string
const (
ToolKindSSH ToolKind = "ssh"
ToolKindHTTP ToolKind = "http"
ToolKindScript ToolKind = "script"
ToolKindFileOps ToolKind = "file_ops"
ToolKindMCP ToolKind = "mcp"
)
// ToolSpec is a pure description of a tool — what it does and what it accepts.
// The actual execution lives in shell/effects/.
type ToolSpec struct {
Name string
Kind ToolKind
Description string
Parameters []ParameterSpec
}
type ParameterSpec struct {
Name string
Type string
Description string
Required bool
}
// Registry is a map of available tools, keyed by name.
type Registry map[string]ToolSpec
// Add returns a new Registry with the given spec added.
func (r Registry) Add(spec ToolSpec) Registry {
out := make(Registry, len(r)+1)
for k, v := range r {
out[k] = v
}
out[spec.Name] = spec
return out
}
// Get looks up a tool spec by name.
func (r Registry) Get(name string) (ToolSpec, bool) {
spec, ok := r[name]
return spec, ok
}
// Names returns all registered tool names.
func (r Registry) Names() []string {
names := make([]string, 0, len(r))
for k := range r {
names = append(names, k)
}
return names
}