Documentation
¶
Index ¶
- Constants
- Variables
- func IsParallelSafe(t Tool) bool
- func SafePath(root, rel string) (string, error)
- func ToAITool(t Tool) ai.Tool
- type ApplyPatchTool
- type EditFileTool
- type FetchURLTool
- type FindFilesTool
- type GrepSearchTool
- type ListDirTool
- type ParallelTool
- type ReadFileTool
- type Registry
- type RunCommandTool
- type SearchHit
- type Tool
- type WriteFileTool
Constants ¶
const ( MaxGrepResults = 200 MaxFindResults = 500 )
Search result caps so a broad pattern cannot flood the model context.
Variables ¶
var ErrPathEscape = errors.New("security error: path traversal escape detected")
ErrPathEscape is returned when a path traversal escape attempt is detected.
var ErrSSRFBlocked = errors.New("security error: SSRF protection blocked request to private/restricted host")
ErrSSRFBlocked is returned when a requested URL is rejected due to SSRF protection.
Functions ¶
func IsParallelSafe ¶
IsParallelSafe returns true if the tool implements ParallelTool and reports true.
Types ¶
type ApplyPatchTool ¶
type ApplyPatchTool struct {
Workspace string
}
ApplyPatchTool applies standard unified diffs to workspace files.
func (*ApplyPatchTool) Description ¶
func (t *ApplyPatchTool) Description() string
func (*ApplyPatchTool) Execute ¶
func (t *ApplyPatchTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*ApplyPatchTool) Name ¶
func (t *ApplyPatchTool) Name() string
func (*ApplyPatchTool) Parameters ¶
func (t *ApplyPatchTool) Parameters() map[string]any
type EditFileTool ¶
type EditFileTool struct {
Workspace string
}
func (*EditFileTool) Description ¶
func (t *EditFileTool) Description() string
func (*EditFileTool) Execute ¶
func (t *EditFileTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*EditFileTool) Name ¶
func (t *EditFileTool) Name() string
func (*EditFileTool) Parameters ¶
func (t *EditFileTool) Parameters() map[string]any
type FetchURLTool ¶
FetchURLTool performs an HTTP GET request to fetch remote content or API data.
func (*FetchURLTool) Description ¶
func (t *FetchURLTool) Description() string
func (*FetchURLTool) Execute ¶
func (t *FetchURLTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*FetchURLTool) Name ¶
func (t *FetchURLTool) Name() string
func (*FetchURLTool) ParallelSafe ¶
func (t *FetchURLTool) ParallelSafe() bool
ParallelSafe marks FetchURLTool as safe for concurrent web fetching execution.
func (*FetchURLTool) Parameters ¶
func (t *FetchURLTool) Parameters() map[string]any
type FindFilesTool ¶
type FindFilesTool struct {
Workspace string
}
FindFilesTool locates files and directories by glob pattern.
func (*FindFilesTool) Description ¶
func (t *FindFilesTool) Description() string
func (*FindFilesTool) Execute ¶
func (t *FindFilesTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*FindFilesTool) Name ¶
func (t *FindFilesTool) Name() string
func (*FindFilesTool) ParallelSafe ¶
func (t *FindFilesTool) ParallelSafe() bool
ParallelSafe marks FindFilesTool as safe for concurrent file finding execution.
func (*FindFilesTool) Parameters ¶
func (t *FindFilesTool) Parameters() map[string]any
type GrepSearchTool ¶
type GrepSearchTool struct {
Workspace string
}
GrepSearchTool searches file contents with regular expressions.
func (*GrepSearchTool) Description ¶
func (t *GrepSearchTool) Description() string
func (*GrepSearchTool) Execute ¶
func (t *GrepSearchTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*GrepSearchTool) Name ¶
func (t *GrepSearchTool) Name() string
func (*GrepSearchTool) ParallelSafe ¶
func (t *GrepSearchTool) ParallelSafe() bool
ParallelSafe marks GrepSearchTool as safe for concurrent search execution.
func (*GrepSearchTool) Parameters ¶
func (t *GrepSearchTool) Parameters() map[string]any
type ListDirTool ¶
type ListDirTool struct {
Workspace string
}
func (*ListDirTool) Description ¶
func (t *ListDirTool) Description() string
func (*ListDirTool) Execute ¶
func (t *ListDirTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*ListDirTool) Name ¶
func (t *ListDirTool) Name() string
func (*ListDirTool) ParallelSafe ¶
func (t *ListDirTool) ParallelSafe() bool
ParallelSafe marks ListDirTool as safe for concurrent directory listing operations.
func (*ListDirTool) Parameters ¶
func (t *ListDirTool) Parameters() map[string]any
type ParallelTool ¶
type ParallelTool interface {
ParallelSafe() bool
}
ParallelTool is an optional interface tools can implement to declare whether they are safe for concurrent execution.
type ReadFileTool ¶
type ReadFileTool struct {
Workspace string
}
func (*ReadFileTool) Description ¶
func (t *ReadFileTool) Description() string
func (*ReadFileTool) Execute ¶
func (t *ReadFileTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*ReadFileTool) Name ¶
func (t *ReadFileTool) Name() string
func (*ReadFileTool) ParallelSafe ¶
func (t *ReadFileTool) ParallelSafe() bool
ParallelSafe marks ReadFileTool as safe for concurrent read operations.
func (*ReadFileTool) Parameters ¶
func (t *ReadFileTool) Parameters() map[string]any
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a thread-safe collection of invokable tools.
func DefaultWorkspaceTools ¶
DefaultWorkspaceTools returns a ready-to-use registry equipped with file and execution tools.
type RunCommandTool ¶
RunCommandTool allows executing shell commands with strict timeouts.
func (*RunCommandTool) Description ¶
func (t *RunCommandTool) Description() string
func (*RunCommandTool) Execute ¶
func (t *RunCommandTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*RunCommandTool) Name ¶
func (t *RunCommandTool) Name() string
func (*RunCommandTool) Parameters ¶
func (t *RunCommandTool) Parameters() map[string]any
type SearchHit ¶
type SearchHit struct {
Path string `json:"path"`
Line int `json:"line"`
Text string `json:"text"`
}
SearchHit is one matched line reported by grep_search.
type Tool ¶
type Tool interface {
Name() string
Description() string
Parameters() map[string]any
Execute(ctx context.Context, args json.RawMessage) (any, error)
}
Tool defines an executable agent tool.
type WriteFileTool ¶
type WriteFileTool struct {
Workspace string
}
func (*WriteFileTool) Description ¶
func (t *WriteFileTool) Description() string
func (*WriteFileTool) Execute ¶
func (t *WriteFileTool) Execute(ctx context.Context, args json.RawMessage) (any, error)
func (*WriteFileTool) Name ¶
func (t *WriteFileTool) Name() string
func (*WriteFileTool) Parameters ¶
func (t *WriteFileTool) Parameters() map[string]any