tools

package
v0.1.8-rc.10 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloneableToolProvider added in v0.1.6

type CloneableToolProvider interface {
	ToolProviders
	Clone() ToolProviders
}

CloneableToolProvider represents a provider with epigenetic context that should be instantiated freshly for isolated environments (like sub-agents).

type FileToolProvider

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

FileToolProvider wraps a trpc-agent-go file.ToolSet and satisfies the ToolProviders interface. The tools are pre-computed at construction time because file.ToolSet.Tools requires a context.

func NewFileToolProvider

func NewFileToolProvider(ctx context.Context, workingDir string) *FileToolProvider

NewFileToolProvider creates a ToolProvider for file tools scoped to a working directory. Returns nil if the ToolSet fails to initialise.

func (*FileToolProvider) GetTools

func (p *FileToolProvider) GetTools(_ context.Context) []tool.Tool

GetTools returns the pre-computed file tools.

type PensieveToolProvider

type PensieveToolProvider struct{}

PensieveToolProvider wraps the Pensieve context management tools (delete_context, check_budget, note, read_notes) and satisfies the ToolProviders interface. Gated behind EnablePensieve in config.

func NewPensieveToolProvider

func NewPensieveToolProvider() *PensieveToolProvider

NewPensieveToolProvider creates a ToolProvider for the Pensieve tools.

func (*PensieveToolProvider) GetTools

func (p *PensieveToolProvider) GetTools(_ context.Context) []tool.Tool

GetTools returns the context management tools.

type Registry

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

Registry holds the bootstrapped, filtered set of tools. It evaluates its providers dynamically so that dynamically loaded skills become instantly available in downstream agents without needing a restart.

func NewRegistry

func NewRegistry(ctx context.Context, providers ...ToolProviders) *Registry

NewRegistry collects tools from every supplied ToolProviders conformer and evaluates them dynamically on each GetTools() call. The returned Registry provides the aggregated tool list via AllTools(). Use FilterDenied to subsequently exclude tools blocked by HITL config.

func (*Registry) AllTools

func (r *Registry) AllTools(ctx context.Context) Tools

AllTools is a convenience alias for GetTools. Prefer AllTools when calling from application code for readability; GetTools exists to satisfy the ToolProviders interface.

func (*Registry) CloneWithEphemeralProviders added in v0.1.6

func (r *Registry) CloneWithEphemeralProviders() *Registry

CloneWithEphemeralProviders creates a copy of the Registry and evaluates Clone() on providers that implement CloneableToolProvider, guaranteeing epigenetic isolation. This is used to ensure sub-agents get a fresh, empty state for dynamically loaded skills.

func (*Registry) Exclude

func (r *Registry) Exclude(names ...string) *Registry

Exclude returns a new Registry that omits tools with the given names. Used to strip orchestration-only tools (e.g. create_agent, send_message) before passing the registry to sub-agents.

func (*Registry) FilterDenied

func (r *Registry) FilterDenied(ctx context.Context, cfg hitl.Config) *Registry

FilterDenied returns a new Registry that excludes any tools denied by the HITL config. This is the single place where tool-level deny-listing is applied. Without this, denied tools would still be available to agents.

func (*Registry) GetTool

func (r *Registry) GetTool(ctx context.Context, name string) (tool.Tool, error)

func (*Registry) GetToolDescriptions

func (r *Registry) GetToolDescriptions(ctx context.Context) []string

func (*Registry) GetTools

func (r *Registry) GetTools(ctx context.Context) []tool.Tool

GetTools returns the full set of available (non-denied) tools. Satisfies the ToolProviders interface so a Registry can be passed as a provider to another Registry (e.g. codeOwner tools).

func (*Registry) Include

func (r *Registry) Include(names ...string) *Registry

Include returns a new Registry containing only tools whose names appear in the provided list. Unknown names are silently ignored. If names is empty, the original Registry is returned unchanged (all tools available). Used to scope sub-agents to exactly the tools the planner selected.

func (*Registry) ToolNames

func (r *Registry) ToolNames(ctx context.Context) []string

ToolNames returns the names of all available tools (for logging).

func (*Registry) UnavailableNames

func (r *Registry) UnavailableNames(ctx context.Context, names []string) []string

UnavailableNames returns the subset of the given names that are NOT present in the registry — either because they are denied, excluded, or simply unknown. Used by create_agent to detect when the LLM requests tools that the config has blocked, so it can return an error instead of creating a zero-tool sub-agent.

type ShellToolProvider

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

ShellToolProvider wraps the shell tool and satisfies the ToolProviders interface. It encapsulates code executor configuration.

func NewShellToolProvider

func NewShellToolProvider(workingDir string, secrets security.SecretProvider, config unix.ShellToolConfig) *ShellToolProvider

NewShellToolProvider creates a ToolProvider for the run_shell tool. The config controls security features like env var filtering and binary allowlists. The SecretProvider is used to resolve allowed environment variables at runtime.

func (*ShellToolProvider) GetTools

func (p *ShellToolProvider) GetTools(_ context.Context) []tool.Tool

GetTools returns the shell tool backed by a local code executor.

type SkillLoadConfig added in v0.1.6

type SkillLoadConfig struct {
	MaxLoadedSkills int      `yaml:"max_loaded_skills,omitempty" toml:"max_loaded_skills,omitempty"`
	SkillsRoots     []string `yaml:"skills_roots,omitempty" toml:"skills_roots,omitempty"`

	// CreateSkillDir is the writable directory where user-created and learned skills
	// are stored. Defaults to ~/.genie/<agentName>/dynamic_skills.
	CreateSkillDir string `yaml:"create_skill_dir,omitempty" toml:"create_skill_dir,omitempty"`
}

func DefaultSkillLoadConfig added in v0.1.6

func DefaultSkillLoadConfig() SkillLoadConfig

type SkillToolProvider added in v0.1.6

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

SkillToolProvider wraps the skill loading tools (skill_list_docs, skill_load, skill_run).

func NewSkillToolProvider added in v0.1.6

func NewSkillToolProvider(workingDir string, agentName string, config SkillLoadConfig, additionalRepos ...skill.Repository) (*SkillToolProvider, error)

NewSkillToolProvider creates a ToolProvider containing skill discovery tools. A MutableRepository is always created at ~/.genie/<agentName>/dynamic_skills so learned skills can be persisted. The CreateSkillDir config overrides this default path when set. The agentName scopes the skill directory per-agent.

func (*SkillToolProvider) Clone added in v0.1.6

func (p *SkillToolProvider) Clone() ToolProviders

Clone returns a new SkillToolProvider with a fresh DynamicSkillLoader (empty loaded-skills state) but sharing the same skill repository and code executor. This implements CloneableToolProvider so that CloneWithEphemeralProviders() can isolate dynamic-skill state per sub-agent — without this, skill load/unload state would be shared across all sub-agents. The mutable repo is shared (writes go to the same directory).

func (*SkillToolProvider) Get added in v0.1.6

Get implements dynamicskills.SkillRegistry.

func (*SkillToolProvider) GetTools added in v0.1.6

func (p *SkillToolProvider) GetTools(_ context.Context) []tool.Tool

GetTools returns the tools needed for agents to dynamically discover and load skills.

func (*SkillToolProvider) MutableRepo

func (p *SkillToolProvider) MutableRepo() *skills.MutableRepository

MutableRepo returns the writable skill repository used by the learning package to persist distilled skills. Always non-nil after construction.

func (*SkillToolProvider) Search added in v0.1.6

func (p *SkillToolProvider) Search(query string) []dynamicskills.Skill

Search implements dynamicskills.SkillRegistry.

type SmartToolProvider

type SmartToolProvider interface {
	// SearchToolsWithContext performs a semantic search and then re-ranks results
	// using co-occurrence affinity with the provided context tools. The blended
	// score is: 0.7*semantic + 0.3*max(cooccurrence with each contextTool).
	SearchToolsWithContext(ctx context.Context, query string, contextTools []string, limit int) (ToolSearchResults, error)

	// RecordToolUsage records that the given tools were used together in a
	// single task run. This updates the co-occurrence graph by incrementing
	// all pairwise edges. The graph is symmetric.
	RecordToolUsage(ctx context.Context, toolNames []string)
}

SmartToolProvider is a tool provider that can perform semantic search and co-occurrence analysis to find relevant tools.

type ToolProviders

type ToolProviders interface {
	GetTools(ctx context.Context) []tool.Tool
}

ToolProviders is the interface that all tool-producing types must satisfy in order to be passed to NewRegistry. Each provider is responsible for constructing its own tools from whatever dependencies it holds.

type ToolSearchResult

type ToolSearchResult struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Score       float64 `json:"score"`
}

ToolSearchResult represents a tool found via semantic search.

type ToolSearchResults

type ToolSearchResults []ToolSearchResult

func (ToolSearchResults) String

func (results ToolSearchResults) String() string

String formats search results as a concise string suitable for inclusion in LLM prompts. Each tool is listed as "- name: description".

type Tools

type Tools []tool.Tool

Slice is a convenience adapter that wraps a plain []tool.Tool into a ToolProviders conformer. Useful for ad-hoc tool collections that don't belong to a dedicated package (e.g. the codeowner's orchestration-only tool set).

func (Tools) GetTools

func (s Tools) GetTools(_ context.Context) []tool.Tool

GetTools returns the wrapped slice of tools.

type VectorToolProvider

type VectorToolProvider struct {

	// DisableCooccurrenceCache when true skips the in-memory map and reads
	// co-occurrence scores directly from the graph store. Useful when the
	// graph store is fast (e.g. in-memory graph) and you want to avoid
	// duplicate state. Has no effect when graphStore is nil.
	DisableCooccurrenceCache bool
	// contains filtered or unexported fields
}

VectorToolProvider indexes tool declarations into a vector store and provides semantic search over them. This enables the orchestrator to find relevant tools by goal description instead of listing all tools in prompts — reducing hallucination and prompt bloat.

It also maintains an in-memory co-occurrence graph that learns which tools are commonly used together (AutoTool-style). This graph is built incrementally from TreeResult.ToolCallCounts after each sub-agent run.

Important: this is a **lookup service only**. It does NOT implement the ToolProviders interface and never gives tools to agents directly. Sub-agents receive concrete tools via Registry.Include().

func NewVectorToolProvider

func NewVectorToolProvider(ctx context.Context, store vector.IStore, registry *Registry, graphStore graph.IStore) (*VectorToolProvider, error)

NewVectorToolProvider creates a VectorToolProvider and indexes every tool from the given registry into the vector store. Each tool is stored as a document with ID "tool:<name>", text "<name>: <description>", and metadata type=tool_index.

The indexing is idempotent (upsert) so repeated calls with the same registry are safe.

func (*VectorToolProvider) CooccurrenceScore

func (v *VectorToolProvider) CooccurrenceScore(toolA, toolB string) float64

CooccurrenceScore returns a normalized affinity score [0, 1] between two tools based on how frequently they appear together. Returns 0 if either tool is unknown or the graph is empty.

When DisableCooccurrenceCache is true and graphStore is available, the score is computed directly from the graph store entities.

func (*VectorToolProvider) RecordToolUsage

func (v *VectorToolProvider) RecordToolUsage(ctx context.Context, toolNames []string)

RecordToolUsage records that the given tools were used together in a single task run. This updates the co-occurrence graph by incrementing all pairwise edges. The graph is symmetric.

Called after every sub-agent completes with its TreeResult.ToolCallCounts.

func (*VectorToolProvider) SearchTools

func (v *VectorToolProvider) SearchTools(ctx context.Context, query string, limit int) (ToolSearchResults, error)

SearchTools performs a semantic search over indexed tool declarations, returning tools whose descriptions are most relevant to the query. Results are ordered by similarity score (highest first).

func (*VectorToolProvider) SearchToolsWithContext

func (v *VectorToolProvider) SearchToolsWithContext(ctx context.Context, query string, contextTools []string, limit int) (ToolSearchResults, error)

SearchToolsWithContext performs a semantic search and then re-ranks results using co-occurrence affinity with the provided context tools. The blended score is: 0.7*semantic + 0.3*max(cooccurrence with each contextTool).

This makes tool recommendations context-aware: tools that are commonly used alongside the context tools rank higher. If the co-occurrence graph is empty (cold start), results are ranked purely by semantic similarity.

Directories

Path Synopsis
Package codeskim provides a code outline/skimming tool for agents.
Package codeskim provides a code outline/skimming tool for agents.
Package datetime provides time and date tools for agents.
Package datetime provides time and date tools for agents.
Package doctool provides document parsing tools for agents.
Package doctool provides document parsing tools for agents.
Package encodetool provides encoding, decoding, and hashing tools for agents.
Package encodetool provides encoding, decoding, and hashing tools for agents.
Package executable provides a generic tool wrapper for arbitrary binaries.
Package executable provides a generic tool wrapper for arbitrary binaries.
google
calendar
Package calendar provides calendar management tools for agents.
Package calendar provides calendar management tools for agents.
contacts
Package contacts provides Google Contacts (People API) tools for agents.
Package contacts provides Google Contacts (People API) tools for agents.
gdrive
Package gdrive provides a DataSource connector that enumerates Google Drive files in configured folders for vectorization.
Package gdrive provides a DataSource connector that enumerates Google Drive files in configured folders for vectorization.
gdrive/gdrivefakes
Code generated by counterfeiter.
Code generated by counterfeiter.
gmail
Package gmail provides a DataSource connector that enumerates Gmail messages for given labels for vectorization.
Package gmail provides a DataSource connector that enumerates Gmail messages for given labels for vectorization.
oauth
Package oauth: browser_flow runs the OAuth2 authorization code flow by opening the system browser and running a local redirect server to capture the code, then exchanging it for a token and storing it in the device keyring.
Package oauth: browser_flow runs the OAuth2 authorization code flow by opening the system browser and running a local redirect server to capture the code, then exchanging it for a token and storing it in the device keyring.
tasks
Package tasks provides Google Tasks API tools for agents.
Package tasks provides Google Tasks API tools for agents.
Package jsontool provides JSON querying, validation, and transformation tools backed by gjson (reads) and sjson (writes).
Package jsontool provides JSON querying, validation, and transformation tools backed by gjson (reads) and sjson (writes).
Package math provides mathematical tools (a unified arithmetic tool and a calculator/expression evaluator) that can be registered with the tool registry.
Package math provides mathematical tools (a unified arithmetic tool and a calculator/expression evaluator) that can be registered with the tool registry.
Package networking provides agent-callable tools for making HTTP requests (GET, POST, etc.) to arbitrary URLs with configurable headers, body, and timeout.
Package networking provides agent-callable tools for making HTTP requests (GET, POST, etc.) to arbitrary URLs with configurable headers, body, and timeout.
Package ocrtool provides optical character recognition (OCR) tools for agents.
Package ocrtool provides optical character recognition (OCR) tools for agents.
pm
Package pm provides a DataSource connector for issue-tracking systems.
Package pm provides a DataSource connector for issue-tracking systems.
pmfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Package regextool provides regular expression tools for agents.
Package regextool provides regular expression tools for agents.
scm
Package scm provides a single DataSource connector backed by go-scm for all SCM providers (GitHub, GitLab, Bitbucket).
Package scm provides a single DataSource connector backed by go-scm for all SCM providers (GitHub, GitLab, Bitbucket).
scmfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
skills
Package sqltool provides SQL database query tools for agents.
Package sqltool provides SQL database query tools for agents.
Code generated by counterfeiter.
Code generated by counterfeiter.
Package webfetch provides a URL content fetcher for agents.
Package webfetch provides a URL content fetcher for agents.
Package youtubetranscript provides a tool to fetch transcript/captions from YouTube videos.
Package youtubetranscript provides a tool to fetch transcript/captions from YouTube videos.

Jump to

Keyboard shortcuts

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