Documentation
¶
Index ¶
- func RegisterBuiltins(r *Registry) error
- func RegisterOutputsTool[T any](r *Registry, tool spec.Tool, ...) error
- func RegisterTypedAsTextTool[T, R any](r *Registry, tool spec.Tool, fn func(context.Context, T) (R, error)) error
- type CallOption
- type Registry
- func (r *Registry) Call(ctx context.Context, funcID spec.FuncID, in json.RawMessage, ...) ([]spec.ToolOutputUnion, error)
- func (r *Registry) Lookup(funcID spec.FuncID) (spec.ToolFunc, bool)
- func (r *Registry) RegisterTool(tool spec.Tool, fn spec.ToolFunc) error
- func (r *Registry) Tools() []spec.Tool
- type RegistryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterBuiltins ¶
RegisterBuiltins registers the built-in tools into r.
func RegisterOutputsTool ¶
func RegisterOutputsTool[T any]( r *Registry, tool spec.Tool, fn func(context.Context, T) ([]spec.ToolOutputUnion, error), ) error
RegisterOutputsTool registers a typed tool function that directly returns []ToolOutputUnion. This is a function and not a method on struct as methods cannot have type params in go.
func RegisterTypedAsTextTool ¶
func RegisterTypedAsTextTool[T, R any]( r *Registry, tool spec.Tool, fn func(context.Context, T) (R, error), ) error
RegisterTypedAsTextTool registers a typed tool function whose output R is JSON-encodable. The JSON representation of R is wrapped into a single text block. This is a function and not a method on struct as methods cannot have type params in go.
Types ¶
type CallOption ¶
type CallOption func(*callOptions)
CallOption configures per-call behavior.
func WithCallTimeout ¶
func WithCallTimeout(d time.Duration) CallOption
WithCallTimeout overrides the timeout for this single call. 0 means "no timeout" for this call (even if tool/registry default is non-zero).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry provides lookup/register for Go tools by funcID, with json.RawMessage I/O.
func NewBuiltinRegistry ¶
func NewBuiltinRegistry(opts ...RegistryOption) (*Registry, error)
NewBuiltinRegistry returns a Registry with all built-in tools registered. By default it applies a 10mins timeout, but callers can override it by passing WithDefaultCallTimeout as a later option.
func NewRegistry ¶
func NewRegistry(opts ...RegistryOption) (*Registry, error)
func (*Registry) Call ¶
func (r *Registry) Call( ctx context.Context, funcID spec.FuncID, in json.RawMessage, callOpts ...CallOption, ) ([]spec.ToolOutputUnion, error)
func (*Registry) RegisterTool ¶
type RegistryOption ¶
func WithDefaultCallTimeout ¶
func WithDefaultCallTimeout(d time.Duration) RegistryOption
func WithLogger ¶
func WithLogger(logger *slog.Logger) RegistryOption