Documentation
¶
Overview ¶
Package tools provides tool implementations for the agent runtime
Package tools provides tool implementations for the agent runtime
Index ¶
- func DeleteFile(path string) error
- func FileExists(path string) bool
- func LoadToolsFromConfig(toolRegistry *ToolRegistry) error
- func ReadFile(path string) (string, error)
- func SaveToolsToConfig(toolRegistry *ToolRegistry) error
- func WriteFile(path, content string) error
- type Argument
- type Bundle
- type Command
- type CppTool
- type EditAnthropicTool
- type EditLintingTool
- type EditReplaceTool
- type EditRewriteTool
- type FileTool
- type FilemapTool
- type ForfeitTool
- type HTTPTool
- type Handler
- func (h *Handler) ExecuteAction(ctx context.Context, action string, environment *env.SWEEnv) (observation string, err error)
- func (h *Handler) GetState(environment *env.SWEEnv) (map[string]interface{}, error)
- func (h *Handler) Install(environment *env.SWEEnv) error
- func (h *Handler) ParseActions(output string) (thought string, action string, err error)
- type PythonTool
- type Registry
- type ReviewOnSubmitMTool
- type ReviewOnSubmitTool
- type SearchTool
- type ShellTool
- type SubmitTool
- type Tool
- type ToolConfig
- type ToolDefinition
- type ToolFilterConfig
- type ToolRegistry
- func (r *ToolRegistry) ExecuteAction(action string, env interface{}) (string, error)
- func (r *ToolRegistry) GetCommand(name string) (*Command, error)
- func (r *ToolRegistry) GetState(env *env.SWEEnv) (map[string]interface{}, error)
- func (r *ToolRegistry) Install(env *env.SWEEnv) error
- func (r *ToolRegistry) ListCommands() []*Command
- func (r *ToolRegistry) LoadTools(toolsPath string) error
- func (r *ToolRegistry) Reset(env *env.SWEEnv) error
- func (r *ToolRegistry) SetMockState(state map[string]interface{})
- type ToolWithEnv
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteFile ¶
func FileExists ¶
func LoadToolsFromConfig ¶
func LoadToolsFromConfig(toolRegistry *ToolRegistry) error
func SaveToolsToConfig ¶
func SaveToolsToConfig(toolRegistry *ToolRegistry) error
Types ¶
type Command ¶
type Command struct {
Name string `json:"name"`
Description string `json:"description"`
Arguments []Argument `json:"arguments"`
Category string `json:"category"`
Timeout int `json:"timeout"`
EndName string `json:"end_name,omitempty"`
InvokeFormat string `json:"invoke_format,omitempty"`
ArgumentFormat string `json:"argument_format,omitempty"`
}
type CppTool ¶
type CppTool struct {
// contains filtered or unexported fields
}
func NewCppTool ¶
func (*CppTool) Description ¶
type EditAnthropicTool ¶
type EditAnthropicTool struct {
// contains filtered or unexported fields
}
EditAnthropicTool implements the Tool interface for Anthropic-specific editing
func (*EditAnthropicTool) Description ¶
func (t *EditAnthropicTool) Description() string
func (*EditAnthropicTool) Execute ¶
func (t *EditAnthropicTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs Anthropic-specific editing operations
func (*EditAnthropicTool) Name ¶
func (t *EditAnthropicTool) Name() string
type EditLintingTool ¶
type EditLintingTool struct {
// contains filtered or unexported fields
}
EditLintingTool implements the Tool interface for linting-based editing
func (*EditLintingTool) Description ¶
func (t *EditLintingTool) Description() string
func (*EditLintingTool) Execute ¶
func (t *EditLintingTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs linting-based editing operations
func (*EditLintingTool) Name ¶
func (t *EditLintingTool) Name() string
type EditReplaceTool ¶
type EditReplaceTool struct {
// contains filtered or unexported fields
}
EditReplaceTool implements the Tool interface for replacing text in files
func (*EditReplaceTool) Description ¶
func (t *EditReplaceTool) Description() string
func (*EditReplaceTool) Execute ¶
func (t *EditReplaceTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute replaces occurrences of a string in a file
func (*EditReplaceTool) Name ¶
func (t *EditReplaceTool) Name() string
type EditRewriteTool ¶
type EditRewriteTool struct {
// contains filtered or unexported fields
}
EditRewriteTool implements the Tool interface for rewriting code
func (*EditRewriteTool) Description ¶
func (t *EditRewriteTool) Description() string
func (*EditRewriteTool) Execute ¶
func (t *EditRewriteTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs code rewriting operations
func (*EditRewriteTool) Name ¶
func (t *EditRewriteTool) Name() string
type FileTool ¶
type FileTool struct {
// contains filtered or unexported fields
}
FileTool implements the Tool interface for file operations
func (*FileTool) Description ¶
Description returns the description of the file tool
type FilemapTool ¶
type FilemapTool struct {
// contains filtered or unexported fields
}
FilemapTool implements the Tool interface for file mapping operations
func (*FilemapTool) Description ¶
func (t *FilemapTool) Description() string
func (*FilemapTool) Execute ¶
func (t *FilemapTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs file mapping operations
func (*FilemapTool) Name ¶
func (t *FilemapTool) Name() string
type ForfeitTool ¶
type ForfeitTool struct {
// contains filtered or unexported fields
}
ForfeitTool implements the Tool interface for forfeiting tasks
func (*ForfeitTool) Description ¶
func (t *ForfeitTool) Description() string
func (*ForfeitTool) Execute ¶
func (t *ForfeitTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs task forfeiting operations
func (*ForfeitTool) Name ¶
func (t *ForfeitTool) Name() string
type HTTPTool ¶
type HTTPTool struct {
// contains filtered or unexported fields
}
HTTPTool implements the Tool interface for HTTP requests
func (*HTTPTool) Description ¶
Description returns the description of the HTTP tool
type Handler ¶
type Handler struct {
Config *ToolConfig // Use ToolConfig from tools package
Definitions map[string]ToolDefinition
Registry *Registry // Reference to the tool registry
}
Handler manages tool execution and parsing
func NewHandler ¶
func NewHandler(config *ToolConfig, definitions []ToolDefinition, registry *Registry) (*Handler, error)
NewHandler creates a new tool handler with the provided configuration and registry
func (*Handler) ExecuteAction ¶
func (h *Handler) ExecuteAction(ctx context.Context, action string, environment *env.SWEEnv) (observation string, err error)
ExecuteAction executes a tool action with the provided context and environment
type PythonTool ¶
type PythonTool struct {
// contains filtered or unexported fields
}
func NewPythonTool ¶
func NewPythonTool(name, description string) (*PythonTool, error)
func (*PythonTool) Close ¶
func (t *PythonTool) Close() error
func (*PythonTool) Description ¶
func (t *PythonTool) Description() string
func (*PythonTool) Execute ¶
func (t *PythonTool) Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
func (*PythonTool) Name ¶
func (t *PythonTool) Name() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the collection of available tools
func NewRegistry ¶
func NewRegistry(cfg *config.Config, toolCfg *ToolConfig) (*Registry, error)
NewRegistry creates a new tool registry with the provided configuration
func (*Registry) Get ¶
func (r *Registry) Get(name string) (ToolWithEnv, error)
Get retrieves a tool from the registry by name
func (*Registry) Register ¶
func (r *Registry) Register(tool ToolWithEnv) error
Register adds a tool to the registry
type ReviewOnSubmitMTool ¶
type ReviewOnSubmitMTool struct {
// contains filtered or unexported fields
}
ReviewOnSubmitMTool implements the Tool interface for multi-submission reviews
func (*ReviewOnSubmitMTool) Description ¶
func (t *ReviewOnSubmitMTool) Description() string
func (*ReviewOnSubmitMTool) Execute ¶
func (t *ReviewOnSubmitMTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs multi-submission review operations
func (*ReviewOnSubmitMTool) Name ¶
func (t *ReviewOnSubmitMTool) Name() string
type ReviewOnSubmitTool ¶
type ReviewOnSubmitTool struct {
// contains filtered or unexported fields
}
ReviewOnSubmitTool implements the Tool interface for reviewing submissions
func (*ReviewOnSubmitTool) Description ¶
func (t *ReviewOnSubmitTool) Description() string
func (*ReviewOnSubmitTool) Execute ¶
func (t *ReviewOnSubmitTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute performs submission review operations
func (*ReviewOnSubmitTool) Name ¶
func (t *ReviewOnSubmitTool) Name() string
type SearchTool ¶
type SearchTool struct {
// contains filtered or unexported fields
}
SearchTool implements the Tool interface for searching in files
func (*SearchTool) Description ¶
func (t *SearchTool) Description() string
func (*SearchTool) Execute ¶
func (t *SearchTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute searches for a pattern in files
func (*SearchTool) Name ¶
func (t *SearchTool) Name() string
type ShellTool ¶
type ShellTool struct {
// contains filtered or unexported fields
}
ShellTool implements the Tool interface for executing shell commands
func (*ShellTool) Description ¶
Description returns the description of the shell tool
type SubmitTool ¶
type SubmitTool struct {
// contains filtered or unexported fields
}
SubmitTool implements the Tool interface for submitting solutions
func (*SubmitTool) Description ¶
func (t *SubmitTool) Description() string
func (*SubmitTool) Execute ¶
func (t *SubmitTool) Execute(ctx context.Context, args map[string]interface{}, environment *env.SWEEnv) (string, error)
Execute submits the final solution or patch
func (*SubmitTool) Name ¶
func (t *SubmitTool) Name() string
type Tool ¶
type Tool interface {
Name() string
Description() string
Execute(ctx context.Context, args map[string]interface{}) (interface{}, error)
}
Tool is the interface that all tools must implement
type ToolConfig ¶
type ToolConfig struct {
ExecutionTimeout time.Duration `json:"execution_timeout"`
MaxOutputSize int `json:"max_output_size"`
ToolsDir string `json:"tools_dir"`
Filter ToolFilterConfig `json:"filter"`
Bundles []Bundle `json:"bundles"`
EnvVariables map[string]interface{} `json:"env_variables"`
RegistryVariables map[string]interface{} `json:"registry_variables"`
SubmitCommand string `json:"submit_command"`
EnableBashTool bool `json:"enable_bash_tool"`
FormatErrorTemplate string `json:"format_error_template"`
MultiLineCommandEndings map[string]string `json:"multi_line_command_endings"`
SubmitCommandEndName string `json:"submit_command_end_name"`
ResetCommands []string `json:"reset_commands"`
InstallTimeout int `json:"install_timeout"`
TotalExecutionTimeout int `json:"total_execution_timeout"`
MaxConsecutiveTimeouts int `json:"max_consecutive_timeouts"`
}
type ToolDefinition ¶
type ToolFilterConfig ¶
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
func NewToolRegistry ¶
func NewToolRegistry(config *ToolConfig, scriptRunner *python.ScriptRunner) (*ToolRegistry, error)
func (*ToolRegistry) ExecuteAction ¶
func (r *ToolRegistry) ExecuteAction(action string, env interface{}) (string, error)
func (*ToolRegistry) GetCommand ¶
func (r *ToolRegistry) GetCommand(name string) (*Command, error)
func (*ToolRegistry) GetState ¶
func (r *ToolRegistry) GetState(env *env.SWEEnv) (map[string]interface{}, error)
func (*ToolRegistry) ListCommands ¶
func (r *ToolRegistry) ListCommands() []*Command
func (*ToolRegistry) LoadTools ¶
func (r *ToolRegistry) LoadTools(toolsPath string) error
func (*ToolRegistry) SetMockState ¶
func (r *ToolRegistry) SetMockState(state map[string]interface{})