Documentation
¶
Index ¶
- type Entry
- type PolicyConfig
- type PolicyMode
- type Registry
- func (r *Registry) All() []Entry
- func (r *Registry) AllTools() []tools.BaseTool
- func (r *Registry) DiscoveredTools() []tools.BaseTool
- func (r *Registry) GetEntry(name string) (Entry, bool)
- func (r *Registry) IsDiscovered(name string) bool
- func (r *Registry) MarkDiscovered(name string)
- func (r *Registry) Register(t tools.BaseTool, source ToolSource, nonDeferred bool) error
- func (r *Registry) Resolve(nameOrAlias string) tools.BaseTool
- func (r *Registry) Search(query string, limit int) []SearchResult
- type RegistrySearchAdapter
- type SearchResult
- type SelectionPolicy
- type ToolMetadata
- type ToolMetadataProvider
- type ToolSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Tool tools.BaseTool
Metadata ToolMetadata
}
Entry holds a registered tool together with its resolved metadata.
type PolicyConfig ¶
type PolicyConfig struct {
Mode PolicyMode
MaxDirectTools int
NonDeferredTools []string // tool names always kept visible
DeferredSources []string // source labels deferred by default
}
PolicyConfig parameterises the selection policy.
func DefaultPolicyConfig ¶
func DefaultPolicyConfig() PolicyConfig
DefaultPolicyConfig returns conservative defaults.
type PolicyMode ¶
type PolicyMode string
PolicyMode controls when deferred tool selection is active.
const ( // ModeAuto activates discovery when total tool count exceeds MaxDirectTools. ModeAuto PolicyMode = "auto" // ModeAlways forces discovery mode regardless of tool count. ModeAlways PolicyMode = "always" // ModeOff disables discovery — all tools are always visible. ModeOff PolicyMode = "off" )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry indexes all available tools, resolves aliases, and tracks per-session discovered/visible state.
func BuildRegistry ¶
BuildRegistry assembles a Registry from a flat tool slice, classifying each tool by source based on its name prefix and optionally implemented metadata.
func (*Registry) DiscoveredTools ¶
DiscoveredTools returns all tools marked as discovered.
func (*Registry) IsDiscovered ¶
IsDiscovered reports whether a tool has been surfaced via tool_search.
func (*Registry) MarkDiscovered ¶
MarkDiscovered marks a tool as discovered in the current session.
func (*Registry) Register ¶
Register adds a tool to the registry. source and nonDeferred are used when the tool does not implement ToolMetadataProvider.
type RegistrySearchAdapter ¶
type RegistrySearchAdapter struct {
// contains filtered or unexported fields
}
RegistrySearchAdapter wraps *Registry to satisfy tools.ToolSearchProvider. This breaks the import cycle: tools imports no tooldiscovery, tooldiscovery imports tools, and the adapter lives in tooldiscovery.
func NewRegistrySearchAdapter ¶
func NewRegistrySearchAdapter(reg *Registry) *RegistrySearchAdapter
NewRegistrySearchAdapter wraps reg as a tools.ToolSearchProvider.
func (*RegistrySearchAdapter) MarkDiscovered ¶
func (a *RegistrySearchAdapter) MarkDiscovered(name string)
MarkDiscovered implements tools.ToolSearchProvider.
func (*RegistrySearchAdapter) SearchTools ¶
func (a *RegistrySearchAdapter) SearchTools(query string, limit int) []tools.ToolSearchEntry
SearchTools implements tools.ToolSearchProvider.
type SearchResult ¶
type SearchResult struct {
CanonicalName string
Aliases []string
ServerName string
Source ToolSource
Description string
Score float64
}
SearchResult is a single match from a tool search query.
type SelectionPolicy ¶
type SelectionPolicy struct {
// contains filtered or unexported fields
}
SelectionPolicy decides which tools are immediately visible and which are deferred.
func NewSelectionPolicy ¶
func NewSelectionPolicy(cfg PolicyConfig) *SelectionPolicy
NewSelectionPolicy creates a SelectionPolicy from cfg.
func (*SelectionPolicy) Apply ¶
Apply returns the visible tool slice given the full set in the registry. If toolSearch is non-nil it is prepended to the visible set when discovery mode is active so the model can always find deferred tools.
func (*SelectionPolicy) IsDeferred ¶
func (p *SelectionPolicy) IsDeferred(e Entry) bool
IsDeferred reports whether a given entry should be hidden initially.
type ToolMetadata ¶
type ToolMetadata struct {
CanonicalName string
Aliases []string
ServerName string
ToolName string
Source ToolSource
Category string
// NonDeferred means this tool is always visible regardless of the threshold.
NonDeferred bool
// Priority controls ordering within a category (higher = more important).
Priority int
}
ToolMetadata carries optional discovery metadata for a BaseTool.
type ToolMetadataProvider ¶
type ToolMetadataProvider interface {
ToolMetadata() ToolMetadata
}
ToolMetadataProvider is an optional interface a BaseTool can implement to expose richer discovery metadata without changing the core BaseTool contract.
type ToolSource ¶
type ToolSource string
ToolSource identifies which subsystem provided a tool.
const ( SourceCore ToolSource = "core" SourceMCP ToolSource = "mcp" SourceInternal ToolSource = "internal" SourceLua ToolSource = "lua" SourceMesnada ToolSource = "mesnada" SourceRAG ToolSource = "rag" SourceGateway ToolSource = "gateway" )