Documentation
¶
Overview ¶
Package tools provides the tool registry and built-in tools.
Package tools provides the tool registry and built-in tools.
Index ¶
- func SetHTTPTimeout(timeout time.Duration)
- type Args
- func (a Args) Bool(key string) (bool, error)
- func (a Args) BoolOr(key string, defaultVal bool) bool
- func (a Args) Float(key string) (float64, error)
- func (a Args) FloatOr(key string, defaultVal float64) float64
- func (a Args) Has(key string) bool
- func (a Args) Int(key string) (int, error)
- func (a Args) IntOr(key string, defaultVal int) int
- func (a Args) Raw(key string) interface{}
- func (a Args) String(key string) (string, error)
- func (a Args) StringOr(key, defaultVal string) string
- func (a Args) StringSlice(key string) ([]string, error)
- func (a Args) StringSliceOr(key string, defaultVal []string) []string
- type CredentialProvider
- type DirEntry
- type ExecResult
- type FILResult
- type FileMemoryStore
- type GrepMatch
- type InMemoryStore
- type MemorySearchResult
- type MemoryStore
- type ObservationItem
- type Registry
- func (r *Registry) Definitions() []ToolDefinition
- func (r *Registry) Execute(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)
- func (r *Registry) Get(name string) Tool
- func (r *Registry) Has(name string) bool
- func (r *Registry) Register(t Tool)
- func (r *Registry) SetBashChecker(checker *policy.BashChecker)
- func (r *Registry) SetBashLLMChecker(llmChecker policy.LLMPolicyChecker)
- func (r *Registry) SetBashSecurityCallback(...)
- func (r *Registry) SetCredentials(creds CredentialProvider)
- func (r *Registry) SetMemoryStore(store MemoryStore)
- func (r *Registry) SetScratchpad(store MemoryStore, persisted bool)
- func (r *Registry) SetSemanticMemory(mem SemanticMemory)
- func (r *Registry) SetSpawner(spawner SpawnFunc)
- func (r *Registry) SetSummarizer(s Summarizer)
- type SearchResult
- type SemanticMemory
- type SemanticMemoryResult
- type SpawnFunc
- type Summarizer
- type Tool
- type ToolDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetHTTPTimeout ¶
SetHTTPTimeout configures the shared HTTP client timeout. This should be set to the maximum of configured tool timeouts. Context deadlines take precedence for individual requests.
Types ¶
type Args ¶
type Args map[string]interface{}
Args wraps tool arguments with typed accessor methods. Eliminates repetitive type assertions and improves error messages.
func (Args) Int ¶
Int gets a required integer argument. Handles both int and float64 (JSON numbers decode as float64).
func (Args) StringSlice ¶
StringSlice gets a required string slice argument. Handles []interface{} (JSON arrays decode as []interface{}).
type CredentialProvider ¶
CredentialProvider provides API keys for tools
type DirEntry ¶
type DirEntry struct {
Name string `json:"name"`
IsDir bool `json:"is_dir"`
Size int64 `json:"size"`
}
DirEntry represents a directory entry for ls.
type ExecResult ¶
type ExecResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exit_code"`
}
ExecResult represents the result of bash execution.
type FILResult ¶
type FILResult struct {
Findings []string `json:"findings"`
Insights []string `json:"insights"`
Lessons []string `json:"lessons"`
}
FILResult holds categorized observation results.
type FileMemoryStore ¶
type FileMemoryStore struct {
// contains filtered or unexported fields
}
FileMemoryStore stores memory in a JSON file.
func NewFileMemoryStore ¶
func NewFileMemoryStore(path string) *FileMemoryStore
NewFileMemoryStore creates a new file-based memory store.
func (*FileMemoryStore) Search ¶
func (s *FileMemoryStore) Search(query string) ([]MemorySearchResult, error)
func (*FileMemoryStore) Set ¶
func (s *FileMemoryStore) Set(key, value string) error
type GrepMatch ¶
type GrepMatch struct {
File string `json:"file"`
Line int `json:"line"`
Content string `json:"content"`
}
GrepMatch represents a grep match result.
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore stores memory in-memory only (lost after run).
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore creates a new in-memory store (scratchpad mode).
func (*InMemoryStore) Search ¶
func (s *InMemoryStore) Search(query string) ([]MemorySearchResult, error)
func (*InMemoryStore) Set ¶
func (s *InMemoryStore) Set(key, value string) error
type MemorySearchResult ¶
MemorySearchResult represents a search hit in scratchpad.
type MemoryStore ¶
type MemoryStore interface {
Get(key string) (string, error)
Set(key, value string) error
List(prefix string) ([]string, error)
Search(query string) ([]MemorySearchResult, error)
}
MemoryStore is the interface for key-value storage (scratchpad).
type ObservationItem ¶
type ObservationItem struct {
ID string `json:"id"`
Content string `json:"content"`
Category string `json:"category"`
}
ObservationItem represents a stored observation with its ID.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered tools.
func NewRegistry ¶
NewRegistry creates a new registry with built-in tools.
func (*Registry) Definitions ¶
func (r *Registry) Definitions() []ToolDefinition
Definitions returns LLM-facing definitions for enabled tools.
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)
Execute executes a tool by name with tracing instrumentation. Returns the result and any error from execution.
func (*Registry) SetBashChecker ¶
func (r *Registry) SetBashChecker(checker *policy.BashChecker)
SetBashChecker sets the bash security checker for the bash tool. The checker performs two-step verification: deterministic denylist + LLM policy check.
func (*Registry) SetBashLLMChecker ¶
func (r *Registry) SetBashLLMChecker(llmChecker policy.LLMPolicyChecker)
SetBashLLMChecker sets the LLM-based policy checker for directory access. This enables Step 2 of bash security checking.
func (*Registry) SetBashSecurityCallback ¶
func (r *Registry) SetBashSecurityCallback(fn func(command, step string, allowed bool, reason string, durationMs int64, inputTokens, outputTokens int))
SetBashSecurityCallback sets a callback for bash security decisions (for logging/auditing).
func (*Registry) SetCredentials ¶
func (r *Registry) SetCredentials(creds CredentialProvider)
SetCredentials sets the credential provider for tools that need API keys
func (*Registry) SetMemoryStore ¶
func (r *Registry) SetMemoryStore(store MemoryStore)
SetMemoryStore is deprecated, use SetScratchpad instead.
func (*Registry) SetScratchpad ¶
func (r *Registry) SetScratchpad(store MemoryStore, persisted bool)
SetScratchpad sets the scratchpad store and registers scratchpad tools. persisted indicates whether data survives across agent runs (affects tool descriptions).
func (*Registry) SetSemanticMemory ¶
func (r *Registry) SetSemanticMemory(mem SemanticMemory)
SetSemanticMemory sets the semantic memory and registers semantic memory tools
func (*Registry) SetSpawner ¶
SetSpawner sets the spawner function for the spawn_agent and spawn_agents tools
func (*Registry) SetSummarizer ¶
func (r *Registry) SetSummarizer(s Summarizer)
SetSummarizer sets the summarizer for web_fetch tool
type SearchResult ¶
type SearchResult struct {
Title string `json:"title"`
URL string `json:"url"`
Snippet string `json:"snippet"`
}
SearchResult represents a single search result
type SemanticMemory ¶
type SemanticMemory interface {
// RememberFIL stores multiple observations at once and returns their IDs
RememberFIL(ctx context.Context, findings, insights, lessons []string, source string) ([]string, error)
// RetrieveByID gets a single observation by ID
RetrieveByID(ctx context.Context, id string) (*ObservationItem, error)
// RecallFIL searches and returns categorized results
RecallFIL(ctx context.Context, query string, limitPerCategory int) (*FILResult, error)
// Recall searches and returns flat results with scores
Recall(ctx context.Context, query string, limit int) ([]SemanticMemoryResult, error)
}
SemanticMemory provides semantic memory operations.
type SemanticMemoryResult ¶
type SemanticMemoryResult struct {
ID string `json:"id"`
Content string `json:"content"`
Category string `json:"category"` // "finding" | "insight" | "lesson"
Score float32 `json:"score"`
}
SemanticMemoryResult is a memory with relevance score.
type SpawnFunc ¶
SpawnFunc is the function signature for spawning sub-agents. It takes role, task and returns the sub-agent's output. SpawnFunc is the function signature for spawning dynamic sub-agents. outputs is optional - when provided, the sub-agent returns structured JSON.
type Summarizer ¶
type Summarizer interface {
Summarize(ctx context.Context, content, question string) (string, error)
}
Summarizer provides content summarization for web_fetch
type Tool ¶
type Tool interface {
// Name returns the tool name.
Name() string
// Description returns a description for the LLM.
Description() string
// Parameters returns the JSON schema for parameters.
Parameters() map[string]interface{}
// Execute runs the tool with the given arguments.
Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)
}
Tool represents an executable tool.
func NewSpawnAgentTool ¶
NewSpawnAgentTool creates a spawn_agent tool with the given spawner function.
type ToolDefinition ¶
ToolDefinition is the LLM-facing tool definition.