tools

package
v0.0.0-...-a489972 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBuiltinTools

func RegisterBuiltinTools(registry *Registry)

RegisterBuiltinTools registers all builtin tools to a registry

Types

type CSVData

type CSVData struct {
	Records   [][]string
	Headers   []string
	Data      [][]string
	HasHeader bool
}

type CodeFormatterTool

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

CodeFormatterTool runs code formatters and linters

func (*CodeFormatterTool) Description

func (c *CodeFormatterTool) Description() string

func (*CodeFormatterTool) Execute

func (c *CodeFormatterTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*CodeFormatterTool) Name

func (c *CodeFormatterTool) Name() string

func (*CodeFormatterTool) Parameters

func (c *CodeFormatterTool) Parameters() map[string]interface{}

func (*CodeFormatterTool) RequiredParameters

func (c *CodeFormatterTool) RequiredParameters() []string

func (*CodeFormatterTool) SetConfirmator

func (c *CodeFormatterTool) SetConfirmator(confirmator Confirmator)

type Confirmator

type Confirmator interface {
	RequestConfirmation(operation, command string, dangerous bool) bool
}

Confirmator is an interface for requesting user confirmation

type ConfirmingTool

type ConfirmingTool interface {
	Tool
	SetConfirmator(confirmator Confirmator)
}

ConfirmingTool is a tool that can request user confirmation before execution

type CurrentTimeTool

type CurrentTimeTool struct{}

CurrentTimeTool returns the current time

func (*CurrentTimeTool) Description

func (c *CurrentTimeTool) Description() string

func (*CurrentTimeTool) Execute

func (c *CurrentTimeTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*CurrentTimeTool) Name

func (c *CurrentTimeTool) Name() string

func (*CurrentTimeTool) Parameters

func (c *CurrentTimeTool) Parameters() map[string]interface{}

func (*CurrentTimeTool) RequiredParameters

func (c *CurrentTimeTool) RequiredParameters() []string

type DataEditTool

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

DataEditTool handles JSON and YAML data manipulation

func (*DataEditTool) Description

func (d *DataEditTool) Description() string

func (*DataEditTool) Execute

func (d *DataEditTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*DataEditTool) Name

func (d *DataEditTool) Name() string

func (*DataEditTool) Parameters

func (d *DataEditTool) Parameters() map[string]interface{}

func (*DataEditTool) RequiredParameters

func (d *DataEditTool) RequiredParameters() []string

func (*DataEditTool) SetConfirmator

func (d *DataEditTool) SetConfirmator(confirmator Confirmator)

type DataProcessTool

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

DataProcessTool handles CSV data processing and analysis

func (*DataProcessTool) Description

func (d *DataProcessTool) Description() string

func (*DataProcessTool) Execute

func (d *DataProcessTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*DataProcessTool) Name

func (d *DataProcessTool) Name() string

func (*DataProcessTool) Parameters

func (d *DataProcessTool) Parameters() map[string]interface{}

func (*DataProcessTool) RequiredParameters

func (d *DataProcessTool) RequiredParameters() []string

func (*DataProcessTool) SetConfirmator

func (d *DataProcessTool) SetConfirmator(confirmator Confirmator)

type DiffHunk

type DiffHunk struct {
	OldStart int      // Starting line in original file (1-based)
	OldCount int      // Number of lines in original file
	NewStart int      // Starting line in new file (1-based)
	NewCount int      // Number of lines in new file
	Lines    []string // Diff lines with +/- prefixes
}

DiffHunk represents a single diff hunk

type DirectoryManageTool

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

DirectoryManageTool handles directory operations (create/delete/list)

func (*DirectoryManageTool) Description

func (d *DirectoryManageTool) Description() string

func (*DirectoryManageTool) Execute

func (d *DirectoryManageTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*DirectoryManageTool) Name

func (d *DirectoryManageTool) Name() string

func (*DirectoryManageTool) Parameters

func (d *DirectoryManageTool) Parameters() map[string]interface{}

func (*DirectoryManageTool) RequiredParameters

func (d *DirectoryManageTool) RequiredParameters() []string

func (*DirectoryManageTool) SetConfirmator

func (d *DirectoryManageTool) SetConfirmator(confirmator Confirmator)

type FileCreationTool

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

FileCreationTool creates new files with specified content

func (*FileCreationTool) Description

func (f *FileCreationTool) Description() string

func (*FileCreationTool) Execute

func (f *FileCreationTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileCreationTool) Name

func (f *FileCreationTool) Name() string

func (*FileCreationTool) Parameters

func (f *FileCreationTool) Parameters() map[string]interface{}

func (*FileCreationTool) RequiredParameters

func (f *FileCreationTool) RequiredParameters() []string

func (*FileCreationTool) SetConfirmator

func (f *FileCreationTool) SetConfirmator(confirmator Confirmator)

type FileEditTool

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

FileEditTool edits files using git diff format

func (*FileEditTool) Description

func (f *FileEditTool) Description() string

func (*FileEditTool) Execute

func (f *FileEditTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileEditTool) Name

func (f *FileEditTool) Name() string

func (*FileEditTool) Parameters

func (f *FileEditTool) Parameters() map[string]interface{}

func (*FileEditTool) RequiredParameters

func (f *FileEditTool) RequiredParameters() []string

func (*FileEditTool) SetConfirmator

func (f *FileEditTool) SetConfirmator(confirmator Confirmator)

type FileInsertTool

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

FileInsertTool inserts content at specific positions

func (*FileInsertTool) Description

func (f *FileInsertTool) Description() string

func (*FileInsertTool) Execute

func (f *FileInsertTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileInsertTool) Name

func (f *FileInsertTool) Name() string

func (*FileInsertTool) Parameters

func (f *FileInsertTool) Parameters() map[string]interface{}

func (*FileInsertTool) RequiredParameters

func (f *FileInsertTool) RequiredParameters() []string

func (*FileInsertTool) SetConfirmator

func (f *FileInsertTool) SetConfirmator(confirmator Confirmator)

type FileManageTool

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

FileManageTool handles file operations (copy/move/rename)

func (*FileManageTool) Description

func (f *FileManageTool) Description() string

func (*FileManageTool) Execute

func (f *FileManageTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileManageTool) Name

func (f *FileManageTool) Name() string

func (*FileManageTool) Parameters

func (f *FileManageTool) Parameters() map[string]interface{}

func (*FileManageTool) RequiredParameters

func (f *FileManageTool) RequiredParameters() []string

func (*FileManageTool) SetConfirmator

func (f *FileManageTool) SetConfirmator(confirmator Confirmator)

type FileReadTool

type FileReadTool struct{}

FileReadTool reads file contents with advanced options

func (*FileReadTool) Description

func (f *FileReadTool) Description() string

func (*FileReadTool) Execute

func (f *FileReadTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileReadTool) Name

func (f *FileReadTool) Name() string

func (*FileReadTool) Parameters

func (f *FileReadTool) Parameters() map[string]interface{}

func (*FileReadTool) RequiredParameters

func (f *FileReadTool) RequiredParameters() []string

type FileReplaceLinesTool

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

FileReplaceLinesTool replaces specific line ranges in files

func (*FileReplaceLinesTool) Description

func (f *FileReplaceLinesTool) Description() string

func (*FileReplaceLinesTool) Execute

func (f *FileReplaceLinesTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileReplaceLinesTool) Name

func (f *FileReplaceLinesTool) Name() string

func (*FileReplaceLinesTool) Parameters

func (f *FileReplaceLinesTool) Parameters() map[string]interface{}

func (*FileReplaceLinesTool) RequiredParameters

func (f *FileReplaceLinesTool) RequiredParameters() []string

func (*FileReplaceLinesTool) SetConfirmator

func (f *FileReplaceLinesTool) SetConfirmator(confirmator Confirmator)

type FileSearchReplaceTool

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

FileSearchReplaceTool performs search and replace operations

func (*FileSearchReplaceTool) Description

func (f *FileSearchReplaceTool) Description() string

func (*FileSearchReplaceTool) Execute

func (f *FileSearchReplaceTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*FileSearchReplaceTool) Name

func (f *FileSearchReplaceTool) Name() string

func (*FileSearchReplaceTool) Parameters

func (f *FileSearchReplaceTool) Parameters() map[string]interface{}

func (*FileSearchReplaceTool) RequiredParameters

func (f *FileSearchReplaceTool) RequiredParameters() []string

func (*FileSearchReplaceTool) SetConfirmator

func (f *FileSearchReplaceTool) SetConfirmator(confirmator Confirmator)

type HttpRequestTool

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

HttpRequestTool makes HTTP requests

func (*HttpRequestTool) Description

func (h *HttpRequestTool) Description() string

func (*HttpRequestTool) Execute

func (h *HttpRequestTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*HttpRequestTool) Name

func (h *HttpRequestTool) Name() string

func (*HttpRequestTool) Parameters

func (h *HttpRequestTool) Parameters() map[string]interface{}

func (*HttpRequestTool) RequiredParameters

func (h *HttpRequestTool) RequiredParameters() []string

func (*HttpRequestTool) SetConfirmator

func (h *HttpRequestTool) SetConfirmator(confirmator Confirmator)

type Registry

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

Registry manages available tools

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new tool registry

func (*Registry) ExecuteAsync

func (r *Registry) ExecuteAsync(ctx context.Context, call ToolCall, resultChan chan<- ToolResult)

ExecuteAsync executes a tool call asynchronously

func (*Registry) GetOpenAIToolsSpec

func (r *Registry) GetOpenAIToolsSpec() []map[string]interface{}

GetOpenAIToolsSpec returns OpenAI-compatible tool specifications

func (*Registry) GetTool

func (r *Registry) GetTool(name string) (Tool, bool)

GetTool retrieves a tool by name

func (*Registry) ListTools

func (r *Registry) ListTools() []Tool

ListTools returns all registered tools

func (*Registry) Register

func (r *Registry) Register(tool Tool)

Register adds a tool to the registry

func (*Registry) SetConfirmator

func (r *Registry) SetConfirmator(confirmator Confirmator)

SetConfirmator sets the confirmator for all confirming tools

type ShellTool

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

ShellTool executes shell commands (use with caution)

func (*ShellTool) Description

func (s *ShellTool) Description() string

func (*ShellTool) Execute

func (s *ShellTool) Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)

func (*ShellTool) Name

func (s *ShellTool) Name() string

func (*ShellTool) Parameters

func (s *ShellTool) Parameters() map[string]interface{}

func (*ShellTool) RequiredParameters

func (s *ShellTool) RequiredParameters() []string

func (*ShellTool) SetConfirmator

func (s *ShellTool) SetConfirmator(confirmator Confirmator)

type Tool

type Tool interface {
	Name() string
	Description() string
	Parameters() map[string]interface{} // JSON schema for parameters
	RequiredParameters() []string       // List of required parameter names
	Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)
}

Tool represents a function that can be called by the AI

type ToolCall

type ToolCall struct {
	ID       string                 `json:"id"`
	Name     string                 `json:"name"`
	Function string                 `json:"function,omitempty"` // For OpenAI compatibility
	Args     map[string]interface{} `json:"arguments"`
}

ToolCall represents a tool call request

func ParseToolCallFromJSON

func ParseToolCallFromJSON(data string) (*ToolCall, error)

ParseToolCallFromJSON parses a tool call from JSON string

type ToolResult

type ToolResult struct {
	CallID string      `json:"call_id"`
	Name   string      `json:"name"`
	Result interface{} `json:"result"`
	Error  string      `json:"error,omitempty"`
}

ToolResult represents the result of a tool execution

func (*ToolResult) ToJSONString

func (tr *ToolResult) ToJSONString() string

ToJSONString converts a tool result to JSON string

Jump to

Keyboard shortcuts

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