Documentation
¶
Overview ¶
Package tools provides tool implementations for the LLM agent system. It includes file operations (read, write, edit, delete), shell commands, search utilities, and integration with LSP servers.
Index ¶
- Constants
- func CleanupTempDir()
- func GetAgentID(ctx context.Context) config.AgentName
- func GetContextValues(ctx context.Context) (string, string)
- func IsTaskAgent(ctx context.Context) bool
- func NewEmptyResponse() toolResponse
- func NewImageResponse(content string) toolResponse
- func NewTextErrorResponse(content string) toolResponse
- func NewTextResponse(content string) toolResponse
- func ValidatePathInWorkingDirectory(filePath string) (string, error)
- func WithResponseMetadata(response toolResponse, metadata any) toolResponse
- type BaseTool
- func NewBashTool(permission permission.Service, reg agentregistry.Registry) BaseTool
- func NewDeleteTool(permissions permission.Service, files history.Service, ...) BaseTool
- func NewEditTool(lspService lsp.LspService, permissions permission.Service, ...) BaseTool
- func NewFetchTool(permissions permission.Service) BaseTool
- func NewGlobTool() BaseTool
- func NewGrepTool() BaseTool
- func NewLsTool(cfg config.Configurator) BaseTool
- func NewLspTool(lspService lsp.LspService) BaseTool
- func NewMultiEditTool(lspService lsp.LspService, permissions permission.Service, ...) BaseTool
- func NewPatchTool(lspService lsp.LspService, permissions permission.Service, ...) BaseTool
- func NewPlanTaskTool(taskService task.Service) BaseTool
- func NewSkillTool(permissions permission.Service, reg agentregistry.Registry) BaseTool
- func NewSourcegraphTool() BaseTool
- func NewStructOutputTool(schema map[string]any) BaseTool
- func NewUpdateStepTool(taskService task.Service) BaseTool
- func NewViewImageTool() BaseTool
- func NewViewTool(lspService lsp.LspService) BaseTool
- func NewWriteTool(lspService lsp.LspService, permissions permission.Service, ...) BaseTool
- type BashParams
- type BashPermissionsParams
- type BashResponseMetadata
- type DeleteParams
- type DeletePermissionsParams
- type DeleteResponseMetadata
- type EditParams
- type EditPermissionsParams
- type EditResponseMetadata
- type FetchParams
- type FetchPermissionsParams
- type GlobParams
- type GlobResponseMetadata
- type GrepParams
- type GrepResponseMetadata
- type LSPToolMetadata
- type LSParams
- type LSResponseMetadata
- type LineScanner
- type LspParams
- type MultiEditItem
- type MultiEditParams
- type MultiEditPermissionEdit
- type MultiEditPermissionsParams
- type MultiEditResponseMetadata
- type PatchParams
- type PatchResponseMetadata
- type PlanTaskParams
- type PlanTaskResponseMetadata
- type SkillParams
- type SourcegraphParams
- type ToolCall
- type ToolInfo
- type ToolResponse
- type TreeNode
- type UpdateStepParams
- type UpdateStepResponseMetadata
- type ViewImageParams
- type ViewImageResponseMetadata
- type ViewParams
- type ViewResponseMetadata
- type WriteParams
- type WritePermissionsParams
- type WriteResponseMetadata
Constants ¶
const ( BashToolName = "bash" DefaultTimeout = 2 * 60 * 1000 // 2 minutes in milliseconds MaxTimeout = 10 * 60 * 1000 // 10 minutes in milliseconds MaxOutputBytes = 50 * 1024 // 50KB MaxOutputLines = 2000 )
const ( LSToolName = "ls" MaxLSFiles = 1000 )
const ( MaxPersistBytes = 100 * 1024 * 1024 // 100MB TruncatedHeadLines = 500 TruncatedTailLines = 500 )
const ( ToolResponseTypeText toolResponseType = "text" ToolResponseTypeImage toolResponseType = "image" SessionIDContextKey sessionIDContextKey = "session_id" MessageIDContextKey messageIDContextKey = "message_id" IsTaskAgentContextKey isTaskAgentContextKey = "is_task_agent" AgentIDContextKey agentIDContextKey = "agent_id" // MaxToolResponseTokens is the maximum number of tokens allowed in a tool response // to prevent context overflow. ~1200KB of text content. MaxToolResponseTokens = 300_000 )
const ( ViewToolName = "view" MaxReadSize = 250 * 1024 DefaultReadLimit = 2000 MaxLineLength = 2000 )
const ( ViewImageToolName = "view_image" MaxImageSize = 5 * 1024 * 1024 // 5MB )
const (
DeleteToolName = "delete"
)
const (
EditToolName = "edit"
)
const (
FetchToolName = "fetch"
)
const (
GlobToolName = "glob"
)
const (
GrepToolName = "grep"
)
const (
LSPToolName = "lsp"
)
const (
MultiEditToolName = "multiedit"
)
const (
PatchToolName = "patch"
)
const (
PlanTaskToolName = "plan_task"
)
const (
SkillToolName = "skill"
)
const (
SourcegraphToolName = "sourcegraph"
)
const (
StructOutputToolName = "struct_output"
)
const (
UpdateStepToolName = "update_step"
)
const (
WriteToolName = "write"
)
Variables ¶
This section is empty.
Functions ¶
func CleanupTempDir ¶ added in v1.7.0
func CleanupTempDir()
CleanupTempDir removes the process-scoped temp directory and all its contents.
func GetAgentID ¶
GetAgentID returns the agent name from context, or empty string if not set
func IsTaskAgent ¶
IsTaskAgent returns true if the context indicates this is a task agent
func NewEmptyResponse ¶
func NewEmptyResponse() toolResponse
func NewImageResponse ¶
func NewImageResponse(content string) toolResponse
func NewTextErrorResponse ¶
func NewTextErrorResponse(content string) toolResponse
func NewTextResponse ¶
func NewTextResponse(content string) toolResponse
func ValidatePathInWorkingDirectory ¶ added in v1.5.0
ValidatePathInWorkingDirectory checks if a path is within the working directory to prevent path traversal attacks. It returns the absolute path if valid, or an error if not. This is a wrapper around fileutil.SecureResolvePath that uses config.WorkingDirectory().
func WithResponseMetadata ¶
func WithResponseMetadata(response toolResponse, metadata any) toolResponse
Types ¶
type BaseTool ¶
type BaseTool interface {
Info() ToolInfo
Run(ctx context.Context, params ToolCall) (ToolResponse, error)
}
func NewBashTool ¶
func NewBashTool(permission permission.Service, reg agentregistry.Registry) BaseTool
func NewDeleteTool ¶
func NewDeleteTool(permissions permission.Service, files history.Service, reg agentregistry.Registry) BaseTool
func NewEditTool ¶
func NewEditTool( lspService lsp.LspService, permissions permission.Service, files history.Service, reg agentregistry.Registry, ) BaseTool
func NewFetchTool ¶
func NewFetchTool(permissions permission.Service) BaseTool
func NewGlobTool ¶
func NewGlobTool() BaseTool
func NewGrepTool ¶
func NewGrepTool() BaseTool
func NewLsTool ¶
func NewLsTool(cfg config.Configurator) BaseTool
func NewLspTool ¶
func NewLspTool(lspService lsp.LspService) BaseTool
func NewMultiEditTool ¶
func NewMultiEditTool(lspService lsp.LspService, permissions permission.Service, files history.Service, reg agentregistry.Registry) BaseTool
func NewPatchTool ¶
func NewPatchTool(lspService lsp.LspService, permissions permission.Service, files history.Service, reg agentregistry.Registry) BaseTool
func NewPlanTaskTool ¶ added in v1.5.0
func NewSkillTool ¶
func NewSkillTool(permissions permission.Service, reg agentregistry.Registry) BaseTool
NewSkillTool creates a new skill tool instance.
func NewSourcegraphTool ¶
func NewSourcegraphTool() BaseTool
func NewStructOutputTool ¶ added in v1.3.0
func NewUpdateStepTool ¶ added in v1.5.0
func NewViewImageTool ¶
func NewViewImageTool() BaseTool
func NewViewTool ¶
func NewViewTool(lspService lsp.LspService) BaseTool
func NewWriteTool ¶
func NewWriteTool(lspService lsp.LspService, permissions permission.Service, files history.Service, reg agentregistry.Registry) BaseTool
type BashParams ¶
type BashPermissionsParams ¶
type BashResponseMetadata ¶
type DeleteParams ¶
type DeleteParams struct {
Path string `json:"path"`
}
type DeletePermissionsParams ¶
type DeleteResponseMetadata ¶
type EditParams ¶
type EditPermissionsParams ¶
type EditResponseMetadata ¶
type FetchParams ¶
type FetchPermissionsParams ¶
type FetchPermissionsParams = FetchParams
type GlobParams ¶
type GlobResponseMetadata ¶
type GrepParams ¶
type GrepResponseMetadata ¶
type LSPToolMetadata ¶
type LSPToolMetadata struct {
Title string `json:"title"`
}
type LSResponseMetadata ¶
type LineScanner ¶
type LineScanner struct {
// contains filtered or unexported fields
}
func NewLineScanner ¶
func NewLineScanner(r io.Reader) *LineScanner
func (*LineScanner) Err ¶
func (s *LineScanner) Err() error
func (*LineScanner) Scan ¶
func (s *LineScanner) Scan() bool
func (*LineScanner) Text ¶
func (s *LineScanner) Text() string
type MultiEditItem ¶
type MultiEditParams ¶
type MultiEditParams struct {
FilePath string `json:"file_path"`
Edits []MultiEditItem `json:"edits"`
}
type MultiEditPermissionEdit ¶ added in v1.7.0
type MultiEditPermissionsParams ¶ added in v1.7.0
type MultiEditPermissionsParams struct {
FilePath string `json:"file_path"`
Edits []MultiEditPermissionEdit `json:"edits"`
}
type PatchParams ¶
type PatchParams struct {
PatchText string `json:"patch_text"`
}
type PatchResponseMetadata ¶
type PlanTaskParams ¶ added in v1.5.0
type PlanTaskResponseMetadata ¶ added in v1.5.0
type PlanTaskResponseMetadata struct {
TaskID string `json:"task_id"`
}
type SkillParams ¶
type SkillParams struct {
Name string `json:"name"`
}
type SourcegraphParams ¶
type ToolResponse ¶
type ToolResponse = toolResponse
ToolResponse is the public interface for tool responses
type UpdateStepParams ¶ added in v1.5.0
type UpdateStepResponseMetadata ¶ added in v1.5.0
type ViewImageParams ¶
type ViewImageParams struct {
FilePath string `json:"file_path"`
}