tools

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrorNotAbsolutePath  = "NOT_ABSOLUTE_PATH"
	ErrorNotFound         = "NOT_FOUND"
	ErrorFileEmpty        = "FILE_EMPTY"
	ErrorPDFParseError    = "PDF_PARSE_ERROR"
	ErrorUnreadableBinary = "UNREADABLE_BINARY"
)

Error constants for consistent error handling

View Source
const (
	DefaultOffset     = 1
	DefaultLimit      = 2000
	MaxLineLength     = 2000
	EmptyFileReminder = "The file exists but is empty."
)

Constants for defaults and limits

Variables

This section is empty.

Functions

This section is empty.

Types

type BashResult

type BashResult struct {
	Command  string `json:"command"`
	Output   string `json:"output"`
	Error    string `json:"error,omitempty"`
	ExitCode int    `json:"exit_code"`
	Duration string `json:"duration"`
}

BashResult represents the internal result of a bash command execution

type BashTool

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

BashTool handles bash command execution with security validation

func NewBashTool

func NewBashTool(cfg *config.Config) *BashTool

NewBashTool creates a new bash tool

func (*BashTool) Definition

func (t *BashTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*BashTool) Execute

func (t *BashTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the bash tool with given arguments

func (*BashTool) IsEnabled

func (t *BashTool) IsEnabled() bool

IsEnabled returns whether the bash tool is enabled

func (*BashTool) Validate

func (t *BashTool) Validate(args map[string]interface{}) error

Validate checks if the bash tool arguments are valid

type DeleteResult added in v0.18.0

type DeleteResult struct {
	Path              string   `json:"path"`
	DeletedFiles      []string `json:"deleted_files"`
	DeletedDirs       []string `json:"deleted_dirs"`
	TotalFilesDeleted int      `json:"total_files_deleted"`
	TotalDirsDeleted  int      `json:"total_dirs_deleted"`
	WildcardExpanded  bool     `json:"wildcard_expanded"`
	Errors            []string `json:"errors,omitempty"`
}

DeleteResult represents the result of a delete operation

type DeleteTool added in v0.18.0

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

DeleteTool handles file and directory deletion operations

func NewDeleteTool added in v0.18.0

func NewDeleteTool(cfg *config.Config) *DeleteTool

NewDeleteTool creates a new delete tool

func (*DeleteTool) Definition added in v0.18.0

func (t *DeleteTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*DeleteTool) Execute added in v0.18.0

func (t *DeleteTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the delete tool with given arguments

func (*DeleteTool) IsEnabled added in v0.18.0

func (t *DeleteTool) IsEnabled() bool

IsEnabled returns whether the delete tool is enabled

func (*DeleteTool) Validate added in v0.18.0

func (t *DeleteTool) Validate(args map[string]interface{}) error

Validate checks if the delete tool arguments are valid

type EditOperation added in v0.22.0

type EditOperation struct {
	OldString  string
	NewString  string
	ReplaceAll bool
}

EditOperation represents a single edit operation

type EditTool added in v0.21.0

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

EditTool handles exact string replacements in files with strict safety rules

func NewEditTool added in v0.21.0

func NewEditTool(cfg *config.Config) *EditTool

NewEditTool creates a new edit tool

func NewEditToolWithRegistry added in v0.21.0

func NewEditToolWithRegistry(cfg *config.Config, registry ReadToolTracker) *EditTool

NewEditToolWithRegistry creates a new edit tool with a registry for read tracking

func (*EditTool) Definition added in v0.21.0

func (t *EditTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*EditTool) Execute added in v0.21.0

func (t *EditTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the edit tool with given arguments

func (*EditTool) IsEnabled added in v0.21.0

func (t *EditTool) IsEnabled() bool

IsEnabled returns whether the edit tool is enabled

func (*EditTool) Validate added in v0.21.0

func (t *EditTool) Validate(args map[string]interface{}) error

Validate checks if the edit tool arguments are valid

type FileReadResult

type FileReadResult struct {
	FilePath  string `json:"file_path"`
	Content   string `json:"content"`
	Size      int64  `json:"size"`
	StartLine int    `json:"start_line,omitempty"`
	EndLine   int    `json:"end_line,omitempty"`
	Error     string `json:"error,omitempty"`
}

FileReadResult represents the internal result of a file read operation

type GoogleSearchItem

type GoogleSearchItem struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

GoogleSearchItem represents a single search result from Google API

type GoogleSearchResponse

type GoogleSearchResponse struct {
	Items []GoogleSearchItem `json:"items"`
}

GoogleSearchResponse represents the response from Google Custom Search API

type GrepCount added in v0.19.0

type GrepCount struct {
	File  string `json:"file"`
	Count int    `json:"count"`
}

GrepCount represents match count per file

type GrepMatch added in v0.19.0

type GrepMatch struct {
	File string `json:"file"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

GrepMatch represents a single match with line content

type GrepResult added in v0.19.0

type GrepResult struct {
	Pattern    string      `json:"pattern"`
	OutputMode string      `json:"output_mode"`
	Files      []string    `json:"files,omitempty"`
	Matches    []GrepMatch `json:"matches,omitempty"`
	Counts     []GrepCount `json:"counts,omitempty"`
	Total      int         `json:"total"`
	Truncated  bool        `json:"truncated"`
	Duration   string      `json:"duration"`
	Error      string      `json:"error,omitempty"`
}

GrepResult represents the result of a grep operation

type GrepTool added in v0.19.0

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

GrepTool handles search operations with ripgrep fallback to Go implementation

func NewGrepTool added in v0.19.0

func NewGrepTool(cfg *config.Config) *GrepTool

NewGrepTool creates a new grep tool

func (*GrepTool) Definition added in v0.19.0

func (t *GrepTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*GrepTool) Execute added in v0.19.0

func (t *GrepTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the grep tool with given arguments

func (*GrepTool) IsEnabled added in v0.19.0

func (t *GrepTool) IsEnabled() bool

IsEnabled returns whether the grep tool is enabled

func (*GrepTool) Validate added in v0.19.0

func (t *GrepTool) Validate(args map[string]interface{}) error

Validate checks if the grep tool arguments are valid

type MultiEditTool added in v0.22.0

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

MultiEditTool handles multiple exact string replacements in a single file atomically

func NewMultiEditTool added in v0.22.0

func NewMultiEditTool(cfg *config.Config) *MultiEditTool

NewMultiEditTool creates a new multi-edit tool

func NewMultiEditToolWithRegistry added in v0.22.0

func NewMultiEditToolWithRegistry(cfg *config.Config, registry ReadToolTracker) *MultiEditTool

NewMultiEditToolWithRegistry creates a new multi-edit tool with a registry for read tracking

func (*MultiEditTool) Definition added in v0.22.0

func (t *MultiEditTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*MultiEditTool) Execute added in v0.22.0

func (t *MultiEditTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the multi-edit tool with given arguments

func (*MultiEditTool) IsEnabled added in v0.22.0

func (t *MultiEditTool) IsEnabled() bool

IsEnabled returns whether the multi-edit tool is enabled

func (*MultiEditTool) Validate added in v0.22.0

func (t *MultiEditTool) Validate(args map[string]interface{}) error

Validate checks if the multi-edit tool arguments are valid

type ReadTool

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

ReadTool handles file reading operations with deterministic behavior

func NewReadTool

func NewReadTool(cfg *config.Config) *ReadTool

NewReadTool creates a new read tool

func (*ReadTool) Definition

func (t *ReadTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*ReadTool) Execute

func (t *ReadTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the read tool with given arguments

func (*ReadTool) IsEnabled

func (t *ReadTool) IsEnabled() bool

IsEnabled returns whether the read tool is enabled

func (*ReadTool) Validate

func (t *ReadTool) Validate(args map[string]interface{}) error

Validate checks if the read tool arguments are valid

type ReadToolTracker added in v0.21.0

type ReadToolTracker interface {
	IsReadToolUsed() bool
}

ReadToolTracker interface for tracking read tool usage

type Registry

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

Registry manages all available tools

func NewRegistry

func NewRegistry(cfg *config.Config) *Registry

NewRegistry creates a new tool registry with self-contained tools

func (*Registry) GetTool

func (r *Registry) GetTool(name string) (domain.Tool, error)

GetTool retrieves a tool by name

func (*Registry) GetToolDefinitions

func (r *Registry) GetToolDefinitions() []domain.ToolDefinition

GetToolDefinitions returns definitions for all enabled tools

func (*Registry) IsReadToolUsed added in v0.21.0

func (r *Registry) IsReadToolUsed() bool

IsReadToolUsed returns whether the Read tool has been used

func (*Registry) IsToolEnabled

func (r *Registry) IsToolEnabled(name string) bool

IsToolEnabled checks if a specific tool is enabled

func (*Registry) ListAvailableTools

func (r *Registry) ListAvailableTools() []string

ListAvailableTools returns names of all available and enabled tools

func (*Registry) SetReadToolUsed added in v0.21.0

func (r *Registry) SetReadToolUsed()

SetReadToolUsed marks that the Read tool has been used

type SearchOptions added in v0.19.0

type SearchOptions struct {
	CaseInsensitive bool
	ShowLineNumbers bool
	ContextBefore   int
	ContextAfter    int
	Multiline       bool
	GlobPattern     string
	FileType        string
	HeadLimit       int
}

SearchOptions holds configuration for the search operation

type TodoWriteTool added in v0.20.0

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

TodoWriteTool handles structured task list management for coding sessions

func NewTodoWriteTool added in v0.20.0

func NewTodoWriteTool(cfg *config.Config) *TodoWriteTool

NewTodoWriteTool creates a new TodoWrite tool

func (*TodoWriteTool) Definition added in v0.20.0

func (t *TodoWriteTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*TodoWriteTool) Execute added in v0.20.0

func (t *TodoWriteTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the TodoWrite tool with given arguments

func (*TodoWriteTool) IsEnabled added in v0.20.0

func (t *TodoWriteTool) IsEnabled() bool

IsEnabled returns whether the TodoWrite tool is enabled

func (*TodoWriteTool) Validate added in v0.20.0

func (t *TodoWriteTool) Validate(args map[string]interface{}) error

Validate checks if the TodoWrite tool arguments are valid

type TreeResult added in v0.16.0

type TreeResult struct {
	Path            string   `json:"path"`
	Output          string   `json:"output"`
	TotalFiles      int      `json:"total_files"`
	TotalDirs       int      `json:"total_dirs"`
	MaxDepth        int      `json:"max_depth"`
	MaxFiles        int      `json:"max_files"`
	ExcludePatterns []string `json:"exclude_patterns"`
	ShowHidden      bool     `json:"show_hidden"`
	Format          string   `json:"format"`
	UsingNativeTree bool     `json:"using_native_tree"`
	Truncated       bool     `json:"truncated"`
}

TreeResult represents the internal result of a tree operation

type TreeTool added in v0.16.0

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

TreeTool handles directory tree visualization operations

func NewTreeTool added in v0.16.0

func NewTreeTool(cfg *config.Config) *TreeTool

NewTreeTool creates a new tree tool

func (*TreeTool) Definition added in v0.16.0

func (t *TreeTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*TreeTool) Execute added in v0.16.0

func (t *TreeTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the tree tool with given arguments

func (*TreeTool) IsEnabled added in v0.16.0

func (t *TreeTool) IsEnabled() bool

IsEnabled returns whether the tree tool is enabled

func (*TreeTool) Validate added in v0.16.0

func (t *TreeTool) Validate(args map[string]interface{}) error

Validate checks if the tree tool arguments are valid

type WebFetchTool added in v0.24.1

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

WebFetchTool handles content fetching operations

func NewWebFetchTool added in v0.24.1

func NewWebFetchTool(cfg *config.Config) *WebFetchTool

NewWebFetchTool creates a new fetch tool

func (*WebFetchTool) Definition added in v0.24.1

func (t *WebFetchTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*WebFetchTool) Execute added in v0.24.1

func (t *WebFetchTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the fetch tool with given arguments

func (*WebFetchTool) IsEnabled added in v0.24.1

func (t *WebFetchTool) IsEnabled() bool

IsEnabled returns whether the fetch tool is enabled

func (*WebFetchTool) Validate added in v0.24.1

func (t *WebFetchTool) Validate(args map[string]interface{}) error

Validate checks if the fetch tool arguments are valid

type WebSearchTool

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

WebSearchTool handles web search operations

func NewWebSearchTool

func NewWebSearchTool(cfg *config.Config) *WebSearchTool

NewWebSearchTool creates a new web search tool

func (*WebSearchTool) Definition

func (t *WebSearchTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*WebSearchTool) Execute

func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the web search tool with given arguments

func (*WebSearchTool) IsEnabled

func (t *WebSearchTool) IsEnabled() bool

IsEnabled returns whether the web search tool is enabled

func (*WebSearchTool) Validate

func (t *WebSearchTool) Validate(args map[string]interface{}) error

Validate checks if the web search tool arguments are valid

type WriteTool added in v0.17.0

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

WriteTool handles file writing operations to the filesystem

func NewWriteTool added in v0.17.0

func NewWriteTool(cfg *config.Config) *WriteTool

NewWriteTool creates a new write tool

func (*WriteTool) Definition added in v0.17.0

func (t *WriteTool) Definition() domain.ToolDefinition

Definition returns the tool definition for the LLM

func (*WriteTool) Execute added in v0.17.0

func (t *WriteTool) Execute(ctx context.Context, args map[string]interface{}) (*domain.ToolExecutionResult, error)

Execute runs the write tool with given arguments

func (*WriteTool) IsEnabled added in v0.17.0

func (t *WriteTool) IsEnabled() bool

IsEnabled returns whether the write tool is enabled

func (*WriteTool) Validate added in v0.17.0

func (t *WriteTool) Validate(args map[string]interface{}) error

Validate checks if the write tool arguments are valid

Jump to

Keyboard shortcuts

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