tool

package
v1.41.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthorizer

BuildAuthorizer creates an Authorizer from config.

func DefaultBuilders

func DefaultBuilders() guardrails.ToolChainBuilders

DefaultBuilders returns the standard tool guardrail builders. Use with Config.BuildToolChain(tool.DefaultBuilders()).

Types

type ArgumentValidator

type ArgumentValidator struct {
	// contains filtered or unexported fields
}

ArgumentValidator validates tool arguments.

func NewArgumentValidator

func NewArgumentValidator() *ArgumentValidator

NewArgumentValidator creates a new argument validator.

func (*ArgumentValidator) BlockArgs

func (v *ArgumentValidator) BlockArgs(toolName string, args ...string) *ArgumentValidator

BlockArgs blocks specific arguments for a tool.

func (*ArgumentValidator) Check

func (v *ArgumentValidator) Check(_ context.Context, toolName string, args map[string]any) (*guardrails.Result, error)

Check validates tool arguments.

func (*ArgumentValidator) Name

func (v *ArgumentValidator) Name() string

Name returns the guardrail name.

func (*ArgumentValidator) RequireArgs

func (v *ArgumentValidator) RequireArgs(toolName string, args ...string) *ArgumentValidator

RequireArgs requires specific arguments for a tool.

func (*ArgumentValidator) WithAction

func (v *ArgumentValidator) WithAction(action guardrails.Action) *ArgumentValidator

WithAction sets the action to take on violation.

func (*ArgumentValidator) WithSeverity

func (v *ArgumentValidator) WithSeverity(severity guardrails.Severity) *ArgumentValidator

WithSeverity sets the severity of violations.

type Authorizer

type Authorizer struct {
	// contains filtered or unexported fields
}

Authorizer checks if tool calls are allowed based on allowed/blocked lists.

func NewAuthorizer

func NewAuthorizer() *Authorizer

NewAuthorizer creates a new tool authorizer.

func (*Authorizer) AllowOnly

func (a *Authorizer) AllowOnly(tools ...string) *Authorizer

AllowOnly sets the allowed tools (whitelist mode). Only these tools are allowed; all others are blocked. Supports glob patterns (*, ?).

func (*Authorizer) Block

func (a *Authorizer) Block(tools ...string) *Authorizer

Block adds tools to the blocklist. These tools are never allowed, even if in the allow list. Supports glob patterns (*, ?).

func (*Authorizer) Check

func (a *Authorizer) Check(_ context.Context, toolName string, _ map[string]any) (*guardrails.Result, error)

Check validates if the tool call is authorized.

func (*Authorizer) Name

func (a *Authorizer) Name() string

Name returns the guardrail name.

func (*Authorizer) WithAction

func (a *Authorizer) WithAction(action guardrails.Action) *Authorizer

WithAction sets the action to take on rejection.

func (*Authorizer) WithSeverity

func (a *Authorizer) WithSeverity(severity guardrails.Severity) *Authorizer

WithSeverity sets the severity of rejections.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL