Documentation
¶
Overview ¶
Package builtins provides built-in tools available to all agents.
Index ¶
- Constants
- func All(opts ...Options) []tools.Tool
- func CodeAgentReadTools(workDir string) []tools.Tool
- func CodeAgentSearchTools(workDir string) []tools.Tool
- func CodeAgentTools(workDir string) []tools.Tool
- func CodeAgentWriteTools(workDir string) []tools.Tool
- func GetByName(name string) tools.Tool
- func MimeFromExtension(ext string) string
- func NewMemoryGetTool(mgr *memory.Manager) tools.Tool
- func NewMemorySearchTool(mgr *memory.Manager) tools.Tool
- func NewScheduleDeleteTool(store scheduler.ScheduleStore, reloader ScheduleReloader) tools.Tool
- func NewScheduleHistoryTool(store scheduler.ScheduleStore) tools.Tool
- func NewScheduleListTool(store scheduler.ScheduleStore) tools.Tool
- func NewScheduleSetTool(store scheduler.ScheduleStore, reloader ScheduleReloader) tools.Tool
- func RegisterAll(reg *tools.Registry, opts ...Options) error
- func RegisterCodeAgentReadTools(reg *tools.Registry, workDir string) error
- func RegisterCodeAgentSearchTools(reg *tools.Registry, workDir string) error
- func RegisterCodeAgentTools(reg *tools.Registry, workDir string) error
- func RegisterCodeAgentWriteTools(reg *tools.Registry, workDir string) error
- func SafeSkillJoin(skillDir, rel string) (string, error)
- func SkillDir(workDir, name string) (string, bool)
- func TruncateOutput(s string) string
- func TruncateOutputCtx(ctx context.Context, s string) string
- type Options
- type PathValidator
- type ReadSkillTool
- type ScheduleReloader
Constants ¶
const ( // MaxOutputLines is the maximum number of lines returned by tool output. MaxOutputLines = 2000 // MaxOutputBytes is the maximum size of tool output in bytes. MaxOutputBytes = 50 * 1024 // Relaxed limits apply when the context carries tools.WithRelaxedLimits // (compression enabled): a destructive tool-side cut would otherwise // destroy data before the compression hook can shrink it losslessly. // 16x mirrors the agent loop's pre-hook safety ceiling multiplier; the // loop still bounds everything downstream. RelaxedMaxOutputLines = MaxOutputLines * 16 RelaxedMaxOutputBytes = MaxOutputBytes * 16 )
Variables ¶
This section is empty.
Functions ¶
func All ¶
All returns all built-in tools. Accepts zero or one Options value; extra Options are ignored (variadic for backward-compat only — callers should pass at most one).
func CodeAgentReadTools ¶
CodeAgentReadTools returns read-only coding tools (file_read + search).
func CodeAgentSearchTools ¶
CodeAgentSearchTools returns search/exploration tools (grep, glob, tree). These are safe read-only tools for exploring codebases.
func CodeAgentTools ¶
CodeAgentTools returns all coding agent tools (read + write).
func CodeAgentWriteTools ¶
CodeAgentWriteTools returns write/execute tools.
func MimeFromExtension ¶
MimeFromExtension returns the MIME type for a given file extension. Returns empty string if the extension is not in the allowlist.
func NewMemoryGetTool ¶
NewMemoryGetTool creates a memory_get tool backed by a Manager. This tool is registered conditionally (not via All()) since it needs a Manager instance.
func NewMemorySearchTool ¶
NewMemorySearchTool creates a memory_search tool backed by a Manager. This tool is registered conditionally (not via All()) since it needs a Manager instance.
func NewScheduleDeleteTool ¶
func NewScheduleDeleteTool(store scheduler.ScheduleStore, reloader ScheduleReloader) tools.Tool
NewScheduleDeleteTool creates a schedule_delete tool for removing schedules.
func NewScheduleHistoryTool ¶
func NewScheduleHistoryTool(store scheduler.ScheduleStore) tools.Tool
NewScheduleHistoryTool creates a schedule_history tool for viewing execution history.
func NewScheduleListTool ¶
func NewScheduleListTool(store scheduler.ScheduleStore) tools.Tool
NewScheduleListTool creates a schedule_list tool for listing schedules.
func NewScheduleSetTool ¶
func NewScheduleSetTool(store scheduler.ScheduleStore, reloader ScheduleReloader) tools.Tool
NewScheduleSetTool creates a schedule_set tool for creating/updating schedules.
func RegisterAll ¶
RegisterAll registers all built-in tools with the given registry. Same variadic-Options convention as All(); pass at most one.
func RegisterCodeAgentReadTools ¶
RegisterCodeAgentReadTools registers only the read-only coding tools.
func RegisterCodeAgentSearchTools ¶
RegisterCodeAgentSearchTools registers search/exploration tools.
func RegisterCodeAgentTools ¶
RegisterCodeAgentTools registers all coding agent tools with the given registry.
func RegisterCodeAgentWriteTools ¶
RegisterCodeAgentWriteTools registers the write/execute coding tools.
func SafeSkillJoin ¶ added in v0.17.0
SafeSkillJoin joins a skill-relative path onto the skill directory and confines the result to that directory — rejecting absolute paths, `..` traversal, AND symlinks that resolve outside the skill. The symlink check matters because a skill package ships whatever the author writes (COPY . .): a bundled symlink like `skills/owl/leak -> /etc/shadow` passes a purely-textual guard (no `..`, not absolute) but `os.ReadFile` / the script interpreter would follow it out of the skill dir. Same confinement posture as read_skill's traversal guard and cli_execute's workdir confinement.
func SkillDir ¶ added in v0.17.0
SkillDir resolves a skill's loadable name to its on-disk directory (`<workDir>/skills/<dir>`), matching read_skill's resolution: the directory name (and its underscore->hyphen variant) first, then the frontmatter `name` of any subdirectory skill (normalized for case and separator drift). Returns ("", false) for an unknown name or a flat single-file skill (which has no companion directory). Shared with the run_skill_script tool so skill-relative reads and executions resolve the same skill dir.
func TruncateOutput ¶
TruncateOutput truncates a string to MaxOutputLines and MaxOutputBytes, appending a truncation notice if the output was trimmed.
Types ¶
type Options ¶ added in v0.17.0
type Options struct {
// HTTPCredentialInjector, when non-nil, is wired into the
// http_request tool so per-call JIT credentials become request
// headers. Zero value → no JIT injection.
HTTPCredentialInjector *credentials.Injector
}
Options configures which optional per-tool integrations are wired when constructing the builtin tools. Governance R9 uses this to attach the JIT credential injector to http_request; future options (per-tool tracing, per-tool rate limits) belong here too so the public All() / RegisterAll() surface stays a small set of variadic entry points.
type PathValidator ¶
type PathValidator struct {
// contains filtered or unexported fields
}
PathValidator provides path confinement to a working directory. All resolved paths are guaranteed to be within workDir.
func NewPathValidator ¶
func NewPathValidator(workDir string) *PathValidator
NewPathValidator creates a PathValidator for the given working directory.
func (*PathValidator) Resolve ¶
func (v *PathValidator) Resolve(path string) (string, error)
Resolve converts a relative or absolute path to an absolute path within workDir. It returns an error if the resolved path escapes the working directory.
func (*PathValidator) WorkDir ¶
func (v *PathValidator) WorkDir() string
WorkDir returns the absolute working directory.
type ReadSkillTool ¶
type ReadSkillTool struct {
// contains filtered or unexported fields
}
ReadSkillTool reads a skill's SKILL.md file on demand. This enables lazy-loading: the LLM only loads full skill instructions when it decides a skill is relevant.
func NewReadSkillTool ¶
func NewReadSkillTool(workDir string) *ReadSkillTool
NewReadSkillTool creates a read_skill tool rooted at the given working directory.
func (*ReadSkillTool) Category ¶
func (t *ReadSkillTool) Category() tools.Category
func (*ReadSkillTool) Description ¶
func (t *ReadSkillTool) Description() string
func (*ReadSkillTool) Execute ¶
func (t *ReadSkillTool) Execute(_ context.Context, args json.RawMessage) (string, error)
func (*ReadSkillTool) InputSchema ¶
func (t *ReadSkillTool) InputSchema() json.RawMessage
func (*ReadSkillTool) Name ¶
func (t *ReadSkillTool) Name() string
type ScheduleReloader ¶
ScheduleReloader is the interface for reloading the scheduler after changes.
Source Files
¶
- csv_parse.go
- datetime_now.go
- directory_tree.go
- file_create.go
- file_edit.go
- file_patch.go
- file_read.go
- file_write.go
- glob_search.go
- grep_search.go
- http_request.go
- json_parse.go
- math_calculate.go
- memory_get.go
- memory_search.go
- pathutil.go
- read_skill.go
- register.go
- schedule_delete.go
- schedule_history.go
- schedule_list.go
- schedule_set.go
- truncate.go
- uuid_generate.go
- web_search.go
- web_search_perplexity.go
- web_search_provider.go
- web_search_tavily.go