Documentation
¶
Index ¶
Constants ¶
const ( ModeAsk = "ask" // ask user for every tool call ModeAuto = "auto" // execute automatically ModeDeny = "deny" // refuse tool execution )
Mode constants for tool execution behaviour.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AskFunc ¶
AskFunc is invoked when policy.Mode==ModeAsk. It should return true to approve the call, false to reject. It can optionally mutate the policy (for example to switch to auto mode after user confirmation).
type Policy ¶
type Policy struct {
Mode string // ask, auto or deny
AllowList []string // optional set of allowed tools (empty => all)
BlockList []string // optional set of blocked tools
Ask AskFunc // optional callback when Mode==ask
}
Policy controls runtime behaviour of tool execution.
func FromContext ¶
FromContext retrieves policy from context; may be nil.
type Registry ¶
type Registry interface {
// Definitions returns the merged list of available tool definitions.
Definitions() []llm.ToolDefinition
//MatchDefinition matches tool definition based on pattern
MatchDefinition(pattern string) []*llm.ToolDefinition
// GetDefinition fetches the definition for the given tool name. The second
// result value indicates whether the definition exists.
GetDefinition(name string) (*llm.ToolDefinition, bool)
// MustHaveTools converts a set of patterns into the LLM toolkit slice used by
// generation prompts.
MustHaveTools(patterns []string) ([]llm.Tool, error)
// Execute invokes the given tool with the supplied arguments and returns
// its textual result.
Execute(ctx context.Context, name string, args map[string]interface{}) (string, error)
// SetDebugLogger attaches a writer that receives every executed tool call
// for debugging.
SetDebugLogger(w io.Writer)
}
Registry defines the minimal interface required by the rest of the code-base. Previous consumers used a concrete *Registry struct; moving to an interface allows alternative implementations (remote catalogues, mocks, etc.) while retaining backward-compatibility.
func WithConversation ¶ added in v0.2.0
WithConversation returns a Registry that guarantees ctx carries convID for every Execute call. All other methods delegate to the underlying registry.