Documentation
¶
Overview ¶
Package tools provides ToolRegistry implementation and schema helpers for building JSON Schema parameter definitions in a type-safe way.
Example:
func (t *SearchTool) Parameters() interfaces.JSONSchema {
return tools.Params(
map[string]interfaces.JSONSchema{
"query": tools.ParamString("Search query"),
"limit": tools.ParamInteger("Max results (default 10)"),
},
"query",
)
}
Index ¶
- func ParamArray(description string, items interfaces.JSONSchema) interfaces.JSONSchema
- func ParamBool(description string) interfaces.JSONSchema
- func ParamEnum(description string, values ...any) interfaces.JSONSchema
- func ParamInteger(description string) interfaces.JSONSchema
- func ParamNumber(description string) interfaces.JSONSchema
- func ParamString(description string) interfaces.JSONSchema
- func Params(properties map[string]interfaces.JSONSchema, required ...string) interfaces.JSONSchema
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParamArray ¶
func ParamArray(description string, items interfaces.JSONSchema) interfaces.JSONSchema
ParamArray returns a JSON Schema for an array parameter.
func ParamBool ¶
func ParamBool(description string) interfaces.JSONSchema
ParamBool returns a JSON Schema for a boolean parameter.
func ParamEnum ¶
func ParamEnum(description string, values ...any) interfaces.JSONSchema
ParamEnum returns a JSON Schema for an enum parameter.
func ParamInteger ¶
func ParamInteger(description string) interfaces.JSONSchema
ParamInteger returns a JSON Schema for an integer parameter.
func ParamNumber ¶
func ParamNumber(description string) interfaces.JSONSchema
ParamNumber returns a JSON Schema for a number parameter.
func ParamString ¶
func ParamString(description string) interfaces.JSONSchema
ParamString returns a JSON Schema for a string parameter.
func Params ¶
func Params(properties map[string]interfaces.JSONSchema, required ...string) interfaces.JSONSchema
Params builds the full parameters schema for a tool. Properties is a map of parameter name to its schema. Required lists parameter names that must be provided.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is an in-memory ToolRegistry implementation.
func (*Registry) Get ¶
func (r *Registry) Get(name string) (interfaces.Tool, bool)
Get returns the tool by name, or (nil, false) if not found.
func (*Registry) Register ¶
func (r *Registry) Register(tool interfaces.Tool)
Register adds a tool. Overwrites if a tool with the same name exists.
func (*Registry) Tools ¶
func (r *Registry) Tools() []interfaces.Tool
Tools returns all registered tools in registration order.