Documentation
¶
Overview ¶
Package local provides a ToolExecutor that executes Go functions as tools. Tools are registered at startup; their JSON schemas are derived via reflection on struct json tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes registered tools.
func NewExecutor ¶
func NewExecutor(registrations ...Registration) (*Executor, error)
NewExecutor creates an Executor with the given registered tools. Returns error if any tool names are duplicated.
func (*Executor) Describe ¶
func (e *Executor) Describe() []runtime.ToolDescriptor
Describe returns metadata for all registered tools.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, call runtime.ToolRequest) (runtime.ToolResult, error)
Execute runs the named tool with the given request. Returns ToolResult with IsError=true if the tool returns an error.
type Registration ¶
type Registration struct {
// contains filtered or unexported fields
}
Registration represents a registered tool function.
func Tool ¶
func Tool[Args any](name, description string, fn func(ctx context.Context, args Args) (any, error)) Registration
Tool registers a Go function as a tool. The function must have signature func(ctx context.Context, args Args) (any, error). Args must be a struct; its json tags are used to derive the JSON schema. Returns a Registration that can be customized with WithSemantics and WithCapabilities.
func (Registration) WithCapabilities ¶
func (r Registration) WithCapabilities(caps ...string) Registration
WithCapabilities sets the required capability tokens for this tool.
func (Registration) WithSemantics ¶
func (r Registration) WithSemantics(s action.ReplaySemantics) Registration
WithSemantics sets the replay semantics for this tool.