Documentation
¶
Index ¶
- Constants
- func AllowedReadDirsFromContext(ctx context.Context) []string
- func AllowedWriteDirsFromContext(ctx context.Context) []string
- func FindingResult(input json.RawMessage) (map[string]any, error)
- func IsPathInAllowedDirs(path string, additionalDirs []string) string
- type FileEditTool
- type FileReadConfig
- type FileReadTool
- type FileWriteTool
- type GlobTool
- type GrepTool
- type ListDirTool
- type Registry
- func (r *Registry) AllTools() []Tool
- func (r *Registry) Dispatch(ctx context.Context, workingDir string, name string, args json.RawMessage) (string, error)
- func (r *Registry) SetAllowedDirs(dirs []string)
- func (r *Registry) SetAllowedReadDirs(dirs []string)
- func (r *Registry) SetAllowedWriteDirs(dirs []string)
- type ReportFindingTool
- type ShellConfig
- type ShellTool
- type Tool
- func NewFileEditTool() Tool
- func NewFileReadTool() Tool
- func NewFileReadToolWithConfig(cfg *FileReadConfig) Tool
- func NewFileWriteTool() Tool
- func NewGlobTool() Tool
- func NewGrepTool() Tool
- func NewListDirTool() Tool
- func NewReportFindingTool() Tool
- func NewShellTool() Tool
- func NewShellToolWithConfig(cfg *ShellConfig) Tool
Constants ¶
const ( // AllowedReadDirsKey carries additional directories read-only tools may access beyond workingDir. AllowedReadDirsKey contextKey = "allowed_read_dirs" // AllowedWriteDirsKey carries additional directories write tools may access beyond workingDir. AllowedWriteDirsKey contextKey = "allowed_write_dirs" )
const ReportFindingToolName = "report_finding"
ReportFindingToolName is the canonical name for the report_finding tool.
Variables ¶
This section is empty.
Functions ¶
func AllowedReadDirsFromContext ¶
AllowedReadDirsFromContext extracts additional read-allowed directories from context.
func AllowedWriteDirsFromContext ¶
AllowedWriteDirsFromContext extracts additional write-allowed directories from context.
func FindingResult ¶
func FindingResult(input json.RawMessage) (map[string]any, error)
FindingResult returns a structured representation of the finding for event emission.
func IsPathInAllowedDirs ¶
IsPathInAllowedDirs checks if a resolved path is within any of the allowed directories. Returns the relative path if found, empty string otherwise.
Types ¶
type FileEditTool ¶
type FileEditTool struct{}
func (*FileEditTool) Description ¶
func (t *FileEditTool) Description() string
func (*FileEditTool) Execute ¶
func (t *FileEditTool) Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
func (*FileEditTool) Name ¶
func (t *FileEditTool) Name() string
func (*FileEditTool) Schema ¶
func (t *FileEditTool) Schema() json.RawMessage
type FileReadConfig ¶ added in v0.15.0
type FileReadConfig struct {
MaxOutputBytes int `json:"max_output_bytes,omitempty"`
}
FileReadConfig allows overriding file_read tool defaults per-profile.
type FileReadTool ¶
type FileReadTool struct {
// contains filtered or unexported fields
}
func (*FileReadTool) Description ¶
func (t *FileReadTool) Description() string
func (*FileReadTool) Execute ¶
func (t *FileReadTool) Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
func (*FileReadTool) Name ¶
func (t *FileReadTool) Name() string
func (*FileReadTool) Schema ¶
func (t *FileReadTool) Schema() json.RawMessage
type FileWriteTool ¶
type FileWriteTool struct{}
func (*FileWriteTool) Description ¶
func (t *FileWriteTool) Description() string
func (*FileWriteTool) Execute ¶
func (t *FileWriteTool) Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
func (*FileWriteTool) Name ¶
func (t *FileWriteTool) Name() string
func (*FileWriteTool) Schema ¶
func (t *FileWriteTool) Schema() json.RawMessage
type GlobTool ¶
type GlobTool struct{}
func (*GlobTool) Description ¶
func (*GlobTool) Schema ¶
func (t *GlobTool) Schema() json.RawMessage
type GrepTool ¶
type GrepTool struct{}
func (*GrepTool) Description ¶
func (*GrepTool) Schema ¶
func (t *GrepTool) Schema() json.RawMessage
type ListDirTool ¶
type ListDirTool struct{}
func (*ListDirTool) Description ¶
func (t *ListDirTool) Description() string
func (*ListDirTool) Execute ¶
func (t *ListDirTool) Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
func (*ListDirTool) Name ¶
func (t *ListDirTool) Name() string
func (*ListDirTool) Schema ¶
func (t *ListDirTool) Schema() json.RawMessage
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all available tools and dispatches calls by name.
func NewRegistry ¶
NewRegistry creates a registry from the given tools.
func (*Registry) Dispatch ¶
func (r *Registry) Dispatch(ctx context.Context, workingDir string, name string, args json.RawMessage) (string, error)
Dispatch looks up a tool by name and executes it with the given JSON args. Returns the tool's output string, or an error if the tool is not found or execution fails.
func (*Registry) SetAllowedDirs ¶
SetAllowedDirs sets additional directories that tools may access beyond the working directory for both read and write operations.
func (*Registry) SetAllowedReadDirs ¶
SetAllowedReadDirs sets additional directories read-only tools may access.
func (*Registry) SetAllowedWriteDirs ¶
SetAllowedWriteDirs sets additional directories write tools may access.
type ReportFindingTool ¶
type ReportFindingTool struct{}
func (*ReportFindingTool) Description ¶
func (t *ReportFindingTool) Description() string
func (*ReportFindingTool) Execute ¶
func (t *ReportFindingTool) Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
func (*ReportFindingTool) Name ¶
func (t *ReportFindingTool) Name() string
func (*ReportFindingTool) Schema ¶
func (t *ReportFindingTool) Schema() json.RawMessage
type ShellConfig ¶
type ShellConfig struct {
AllowedCommands []string `json:"allowed_commands,omitempty"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
MaxOutputBytes int `json:"max_output_bytes,omitempty"`
}
ShellConfig allows overriding shell tool defaults per-profile.
func DefaultShellConfig ¶
func DefaultShellConfig() ShellConfig
DefaultShellConfig returns a ShellConfig with built-in defaults.
type ShellTool ¶
type ShellTool struct {
// contains filtered or unexported fields
}
func (*ShellTool) Description ¶
func (*ShellTool) Schema ¶
func (t *ShellTool) Schema() json.RawMessage
type Tool ¶
type Tool interface {
// Name returns the tool name used in function_call / tool_use blocks.
Name() string
// Description returns a human-readable description of what the tool does.
// Sent to the model as part of the tool definition.
Description() string
// Schema returns the JSON Schema for the tool's arguments.
Schema() json.RawMessage
// Execute runs the tool with the given JSON arguments and returns
// a string result, or an error.
Execute(ctx context.Context, workingDir string, args json.RawMessage) (string, error)
}
Tool is the interface every pony tool implements.
func NewFileEditTool ¶
func NewFileEditTool() Tool
func NewFileReadTool ¶
func NewFileReadTool() Tool
func NewFileReadToolWithConfig ¶ added in v0.15.0
func NewFileReadToolWithConfig(cfg *FileReadConfig) Tool
NewFileReadToolWithConfig creates a FileReadTool with the given config overrides. Nil config uses the default 32 KB cap. Zero or negative MaxOutputBytes also falls back to the default.
func NewFileWriteTool ¶
func NewFileWriteTool() Tool
func NewGlobTool ¶
func NewGlobTool() Tool
func NewGrepTool ¶
func NewGrepTool() Tool
func NewListDirTool ¶
func NewListDirTool() Tool
func NewReportFindingTool ¶
func NewReportFindingTool() Tool
func NewShellTool ¶
func NewShellTool() Tool
func NewShellToolWithConfig ¶
func NewShellToolWithConfig(cfg *ShellConfig) Tool
NewShellToolWithConfig creates a ShellTool with the given config overrides. Nil fields fall back to DefaultShellConfig values. Partial configs are merged with defaults so that unset fields keep sensible values.