middleware

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalMiddleware

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

ApprovalMiddleware intercepts tool execution and injects approval logic

func NewApprovalMiddleware

func NewApprovalMiddleware(cfg ApprovalMiddlewareConfig) *ApprovalMiddleware

NewApprovalMiddleware creates a new approval middleware

func (*ApprovalMiddleware) Execute

Execute intercepts tool execution and applies approval logic If approval is required, it requests approval from the user via events If approval is granted (or not required), it enriches context and calls the next handler

func (*ApprovalMiddleware) ExecuteBatch

func (m *ApprovalMiddleware) ExecuteBatch(
	ctx context.Context,
	toolCalls []sdk.ChatCompletionMessageToolCall,
	isChatMode bool,
	executor ToolExecutor,
) ([]*domain.ToolExecutionResult, error)

ExecuteBatch executes multiple tool calls, handling approval for each Tools requiring approval are executed sequentially, while approved tools can be executed in parallel

func (*ApprovalMiddleware) WithRequestID

func (m *ApprovalMiddleware) WithRequestID(requestID string) *ApprovalMiddleware

WithRequestID creates a new middleware with a different request ID Useful for different execution contexts

type ApprovalMiddlewareConfig

type ApprovalMiddlewareConfig struct {
	Policy       domain.ApprovalPolicy
	StateManager domain.StateManager
	EventBus     chan<- domain.ChatEvent
	RequestID    string
}

ApprovalMiddlewareConfig contains configuration for the approval middleware

type ToolExecutor

type ToolExecutor func(ctx context.Context, toolCall *sdk.ChatCompletionMessageToolCall) (*domain.ToolExecutionResult, error)

ToolExecutor is a function that executes a tool and returns the result

Jump to

Keyboard shortcuts

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