Documentation
¶
Index ¶
- type ApprovalDecision
- type ApprovalHook
- type EventHook
- type Hook
- type HookAction
- type HookDecision
- type HookManager
- func (m *HookManager) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
- func (m *HookManager) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
- func (m *HookManager) ApproveTool(ctx context.Context, req *ToolApprovalRequest) (ApprovalDecision, error)
- func (m *HookManager) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
- func (m *HookManager) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
- func (m *HookManager) OnEvent(ctx context.Context, evt bus.Event) error
- func (m *HookManager) Register(reg HookRegistration) error
- type HookRegistration
- type HookSource
- type LLMHook
- type LLMHookRequest
- type LLMHookResponse
- type MessageFilterHook
- func (h *MessageFilterHook) AddBlockedPattern(pattern string) error
- func (h *MessageFilterHook) AddWarnPattern(pattern string) error
- func (h *MessageFilterHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
- func (h *MessageFilterHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
- func (h *MessageFilterHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
- func (h *MessageFilterHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
- func (h *MessageFilterHook) Name() string
- type PrivacyHook
- func (h *PrivacyHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
- func (h *PrivacyHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
- func (h *PrivacyHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
- func (h *PrivacyHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
- func (h *PrivacyHook) Name() string
- type RateLimitHook
- func (h *RateLimitHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
- func (h *RateLimitHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
- func (h *RateLimitHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
- func (h *RateLimitHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
- func (h *RateLimitHook) Name() string
- type RiskLevel
- type ToolApprovalRequest
- type ToolCallHookRequest
- type ToolHook
- type ToolResultHookResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalDecision ¶
ApprovalDecision represents the approval decision
type ApprovalHook ¶
type ApprovalHook interface {
Hook
ApproveTool(ctx context.Context, req *ToolApprovalRequest) (ApprovalDecision, error)
}
ApprovalHook is called to approve or reject tool execution
type EventHook ¶
EventHook observes events without modifying them EventHooks are automatically bridged to the EventBus for monitoring purposes
type HookAction ¶
type HookAction string
HookAction defines what action to take after a hook runs
const ( HookActionContinue HookAction = "continue" HookActionStop HookAction = "stop" HookActionReject HookAction = "reject" HookActionModify HookAction = "modify" )
type HookDecision ¶
type HookDecision struct {
Action HookAction
Reason string
}
HookDecision represents the decision made by a hook
type HookManager ¶
type HookManager struct {
// contains filtered or unexported fields
}
HookManager manages all hooks
func NewHookManagerWithBus ¶
func NewHookManagerWithBus(eventBus *bus.EventBus) *HookManager
SetEventBus sets the event bus for the hook manager This enables automatic bridging of EventHooks to the EventBus
func (*HookManager) AfterLLM ¶
func (m *HookManager) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
AfterLLM calls all LLM hooks after an LLM call
func (*HookManager) AfterTool ¶
func (m *HookManager) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
AfterTool calls all tool hooks after tool execution
func (*HookManager) ApproveTool ¶
func (m *HookManager) ApproveTool(ctx context.Context, req *ToolApprovalRequest) (ApprovalDecision, error)
ApproveTool calls all approval hooks for tool execution
func (*HookManager) BeforeLLM ¶
func (m *HookManager) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
BeforeLLM calls all LLM hooks before an LLM call
func (*HookManager) BeforeTool ¶
func (m *HookManager) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
BeforeTool calls all tool hooks before tool execution
func (*HookManager) Register ¶
func (m *HookManager) Register(reg HookRegistration) error
Register registers a hook
type HookRegistration ¶
type HookRegistration struct {
Name string
Source HookSource
Hook interface{} // LLMHook, ToolHook, ApprovalHook, or EventHook
}
HookRegistration holds hook configuration
type HookSource ¶
type HookSource string
HookSource indicates where the hook comes from
const ( HookSourceBuiltIn HookSource = "built_in" HookSourceConfig HookSource = "config" HookSourceProcess HookSource = "process" )
type LLMHook ¶
type LLMHook interface {
Hook
BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
}
LLMHook is called before and after LLM calls
type LLMHookRequest ¶
type LLMHookRequest struct {
Provider string
Model string
Messages []provider.Message
Tools []map[string]interface{}
}
LLMHookRequest contains data for LLM-related hooks
type LLMHookResponse ¶
LLMHookResponse contains the LLM response for hooks
type MessageFilterHook ¶
type MessageFilterHook struct {
// contains filtered or unexported fields
}
MessageFilterHook filters messages based on content
func NewMessageFilterHook ¶
func NewMessageFilterHook() *MessageFilterHook
NewMessageFilterHook creates a new message filter hook
func (*MessageFilterHook) AddBlockedPattern ¶
func (h *MessageFilterHook) AddBlockedPattern(pattern string) error
AddBlockedPattern adds a pattern that should be blocked
func (*MessageFilterHook) AddWarnPattern ¶
func (h *MessageFilterHook) AddWarnPattern(pattern string) error
AddWarnPattern adds a pattern that should trigger a warning
func (*MessageFilterHook) AfterLLM ¶
func (h *MessageFilterHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
AfterLLM passes through the response
func (*MessageFilterHook) AfterTool ¶
func (h *MessageFilterHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
AfterTool passes through results
func (*MessageFilterHook) BeforeLLM ¶
func (h *MessageFilterHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
BeforeLLM checks messages for blocked content
func (*MessageFilterHook) BeforeTool ¶
func (h *MessageFilterHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
BeforeTool passes through tool calls
func (*MessageFilterHook) Name ¶
func (h *MessageFilterHook) Name() string
type PrivacyHook ¶
type PrivacyHook struct {
// contains filtered or unexported fields
}
PrivacyHook provides PII detection and redaction
func (*PrivacyHook) AfterLLM ¶
func (h *PrivacyHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
AfterLLM passes through the response without modification
func (*PrivacyHook) AfterTool ¶
func (h *PrivacyHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
AfterTool passes through the result without modification
func (*PrivacyHook) BeforeLLM ¶
func (h *PrivacyHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
BeforeLLM redacts PII from messages before sending to LLM
func (*PrivacyHook) BeforeTool ¶
func (h *PrivacyHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
BeforeTool redacts PII from tool arguments before execution
func (*PrivacyHook) Name ¶
func (h *PrivacyHook) Name() string
type RateLimitHook ¶
type RateLimitHook struct {
// contains filtered or unexported fields
}
RateLimitHook limits the rate of LLM calls
func NewRateLimitHook ¶
func NewRateLimitHook(maxPerMinute int) *RateLimitHook
NewRateLimitHook creates a new rate limit hook
func (*RateLimitHook) AfterLLM ¶
func (h *RateLimitHook) AfterLLM(ctx context.Context, resp *LLMHookResponse) (*LLMHookResponse, HookDecision, error)
AfterLLM passes through the response
func (*RateLimitHook) AfterTool ¶
func (h *RateLimitHook) AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
AfterTool passes through
func (*RateLimitHook) BeforeLLM ¶
func (h *RateLimitHook) BeforeLLM(ctx context.Context, req *LLMHookRequest) (*LLMHookRequest, HookDecision, error)
BeforeLLM checks rate limits
func (*RateLimitHook) BeforeTool ¶
func (h *RateLimitHook) BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
BeforeTool passes through
func (*RateLimitHook) Name ¶
func (h *RateLimitHook) Name() string
type ToolApprovalRequest ¶
type ToolApprovalRequest struct {
ToolName string
ToolArgs map[string]interface{}
Command string
RiskLevel RiskLevel
SessionID string
}
ToolApprovalRequest contains data for tool approval hooks
type ToolCallHookRequest ¶
type ToolCallHookRequest struct {
ToolName string
ToolArgs map[string]interface{}
Result interface{}
Error error
}
ToolCallHookRequest contains data for tool call hooks
type ToolHook ¶
type ToolHook interface {
Hook
BeforeTool(ctx context.Context, call *ToolCallHookRequest) (*ToolCallHookRequest, HookDecision, error)
AfterTool(ctx context.Context, result *ToolResultHookResponse) (*ToolResultHookResponse, HookDecision, error)
}
ToolHook is called before and after tool execution