Documentation
¶
Index ¶
- func BuildAuthorizer(cfg *guardrails.AuthorizationConfig) guardrails.ToolGuardrail
- func DefaultBuilders() guardrails.ToolChainBuilders
- type ArgumentValidator
- func (v *ArgumentValidator) BlockArgs(toolName string, args ...string) *ArgumentValidator
- func (v *ArgumentValidator) Check(_ context.Context, toolName string, args map[string]any) (*guardrails.Result, error)
- func (v *ArgumentValidator) Name() string
- func (v *ArgumentValidator) RequireArgs(toolName string, args ...string) *ArgumentValidator
- func (v *ArgumentValidator) WithAction(action guardrails.Action) *ArgumentValidator
- func (v *ArgumentValidator) WithSeverity(severity guardrails.Severity) *ArgumentValidator
- type Authorizer
- func (a *Authorizer) AllowOnly(tools ...string) *Authorizer
- func (a *Authorizer) Block(tools ...string) *Authorizer
- func (a *Authorizer) Check(_ context.Context, toolName string, _ map[string]any) (*guardrails.Result, error)
- func (a *Authorizer) Name() string
- func (a *Authorizer) WithAction(action guardrails.Action) *Authorizer
- func (a *Authorizer) WithSeverity(severity guardrails.Severity) *Authorizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAuthorizer ¶
func BuildAuthorizer(cfg *guardrails.AuthorizationConfig) guardrails.ToolGuardrail
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 (*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) 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.