tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package tools provides built-in tools for LLM agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTools

func AllTools() []llm.Tool

AllTools returns all built-in tools.

func BashTool

func BashTool() (llm.Tool, error)

BashTool returns the Bash tool.

func FileTools

func FileTools() []llm.Tool

FileTools returns file-related tools only. Includes: Read, Write, Glob, Grep

func GlobTool

func GlobTool() (llm.Tool, error)

GlobTool returns the Glob tool.

func GrepTool

func GrepTool() (llm.Tool, error)

GrepTool returns the Grep tool.

func KnowledgeTools

func KnowledgeTools() []llm.Tool

KnowledgeTools returns knowledge retrieval tools. Includes: WebSearch, Wikipedia

func MustBash

func MustBash() llm.Tool

MustBash returns the Bash tool, panicking on error.

func MustGlob

func MustGlob() llm.Tool

MustGlob returns the Glob tool, panicking on error.

func MustGrep

func MustGrep() llm.Tool

MustGrep returns the Grep tool, panicking on error.

func MustRead

func MustRead() llm.Tool

MustRead returns the Read tool, panicking on error.

func MustWebFetch

func MustWebFetch() llm.Tool

MustWebFetch returns the WebFetch tool, panicking on error.

func MustWebSearch

func MustWebSearch() llm.Tool

MustWebSearch returns the WebSearch tool, panicking on error.

func MustWikipedia

func MustWikipedia() llm.Tool

MustWikipedia returns the Wikipedia tool, panicking on error.

func MustWrite

func MustWrite() llm.Tool

MustWrite returns the Write tool, panicking on error.

func ReadOnlyTools

func ReadOnlyTools() []llm.Tool

ReadOnlyTools returns tools that don't modify the filesystem. Includes: Read, Glob, Grep, WebFetch, WebSearch, Wikipedia

func ReadTool

func ReadTool() (llm.Tool, error)

ReadTool returns the Read tool.

func SystemTools

func SystemTools() []llm.Tool

SystemTools returns tools that can modify the system. Includes: Write, Bash

func WebFetchTool

func WebFetchTool() (llm.Tool, error)

WebFetchTool returns the WebFetch tool.

func WebSearchTool

func WebSearchTool() (llm.Tool, error)

WebSearchTool returns the WebSearch tool.

func WebTools

func WebTools() []llm.Tool

WebTools returns web-related tools only. Includes: WebFetch, WebSearch, Wikipedia

func WikipediaTool

func WikipediaTool() (llm.Tool, error)

WikipediaTool returns the Wikipedia tool.

func WriteTool

func WriteTool() (llm.Tool, error)

WriteTool returns the Write tool.

Types

type BashInput

type BashInput struct {
	Command string `json:"command" jsonschema:"required,description=Shell command to execute"`
	Timeout int    `json:"timeout,omitempty" jsonschema:"description=Timeout in seconds (default: 30)"`
	WorkDir string `json:"workdir,omitempty" jsonschema:"description=Working directory for the command"`
}

BashInput defines the input for the Bash tool.

type BashOutput

type BashOutput struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

BashOutput defines the output of the Bash tool.

type GlobInput

type GlobInput struct {
	Pattern string `json:"pattern" jsonschema:"required,description=Glob pattern (e.g. **/*.go for all Go files)"`
	Path    string `json:"path,omitempty" jsonschema:"description=Base directory to search from (default: current directory)"`
}

GlobInput defines the input for the Glob tool.

type GlobOutput

type GlobOutput struct {
	Files []string `json:"files"`
	Count int      `json:"count"`
}

GlobOutput defines the output of the Glob tool.

type GrepInput

type GrepInput struct {
	Pattern    string `json:"pattern" jsonschema:"required,description=Regular expression pattern to search for"`
	Path       string `json:"path,omitempty" jsonschema:"description=File or directory to search in (default: current directory)"`
	Glob       string `json:"glob,omitempty" jsonschema:"description=File pattern filter (e.g. *.go)"`
	MaxMatches int    `json:"max_matches,omitempty" jsonschema:"description=Maximum number of matches to return (default: 100)"`
}

GrepInput defines the input for the Grep tool.

type GrepMatch

type GrepMatch struct {
	File    string `json:"file"`
	Line    int    `json:"line"`
	Content string `json:"content"`
}

GrepMatch represents a single match.

type GrepOutput

type GrepOutput struct {
	Matches []GrepMatch `json:"matches"`
	Count   int         `json:"count"`
}

GrepOutput defines the output of the Grep tool.

type ReadInput

type ReadInput struct {
	Path   string `json:"path" jsonschema:"required,description=File path to read"`
	Offset int    `json:"offset,omitempty" jsonschema:"description=Line offset to start from (0-based)"`
	Limit  int    `json:"limit,omitempty" jsonschema:"description=Max lines to read (default: 0 = all)"`
}

ReadInput defines the input for the Read tool.

type ReadOutput

type ReadOutput struct {
	Content   string `json:"content"`
	Lines     int    `json:"lines"`
	Truncated bool   `json:"truncated"`
}

ReadOutput defines the output of the Read 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 WebFetchInput

type WebFetchInput struct {
	URL     string `json:"url" jsonschema:"required,description=URL to fetch"`
	Extract string `json:"extract,omitempty" jsonschema:"description=Extract mode: html (raw), text (stripped), or markdown (default: text)"`
	Timeout int    `json:"timeout,omitempty" jsonschema:"description=Timeout in seconds (default: 30)"`
}

WebFetchInput defines the input for the WebFetch tool.

type WebFetchOutput

type WebFetchOutput struct {
	Content    string `json:"content"`
	StatusCode int    `json:"status_code"`
	Title      string `json:"title,omitempty"`
	URL        string `json:"url"`
}

WebFetchOutput defines the output of the WebFetch tool.

type WebSearchInput

type WebSearchInput struct {
	Query      string `json:"query" jsonschema:"required,description=Search query"`
	MaxResults int    `json:"max_results,omitempty" jsonschema:"description=Maximum number of results to return (default: 5)"`
}

WebSearchInput defines the input for the WebSearch tool.

type WebSearchOutput

type WebSearchOutput struct {
	Results     []SearchResult `json:"results"`
	Abstract    string         `json:"abstract,omitempty"`
	AbstractURL string         `json:"abstract_url,omitempty"`
}

WebSearchOutput defines the output of the WebSearch tool.

type WikipediaInput

type WikipediaInput struct {
	Query    string `json:"query" jsonschema:"required,description=Search query or article title"`
	Language string `json:"language,omitempty" jsonschema:"description=Language code (default: en)"`
	Summary  bool   `json:"summary,omitempty" jsonschema:"description=Return summary only (default: true)"`
}

WikipediaInput defines the input for the Wikipedia tool.

type WikipediaOutput

type WikipediaOutput struct {
	Title       string `json:"title"`
	Summary     string `json:"summary"`
	URL         string `json:"url"`
	Content     string `json:"content,omitempty"`
	Description string `json:"description,omitempty"`
}

WikipediaOutput defines the output of the Wikipedia tool.

type WriteInput

type WriteInput struct {
	Path    string `json:"path" jsonschema:"required,description=File path to write"`
	Content string `json:"content" jsonschema:"required,description=Content to write to the file"`
}

WriteInput defines the input for the Write tool.

type WriteOutput

type WriteOutput struct {
	Success bool   `json:"success"`
	Path    string `json:"path"`
	Bytes   int    `json:"bytes"`
}

WriteOutput defines the output of the Write tool.

Jump to

Keyboard shortcuts

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