Documentation
¶
Index ¶
- Constants
- type CreateDirectoryArgs
- type DirectoryTreeArgs
- type DirectoryTreeMeta
- type Edit
- type EditFileArgs
- type ListDirectoryArgs
- type ListDirectoryMeta
- type Opt
- type PostEditConfig
- type ReadFileArgs
- type ReadFileMeta
- type ReadMultipleFilesArgs
- type ReadMultipleFilesMeta
- type RemoveDirectoryArgs
- type SearchFilesContentArgs
- type SearchFilesContentMeta
- type Tool
- type WriteFileArgs
Constants ¶
const ( ToolNameReadFile = "read_file" ToolNameReadMultipleFiles = "read_multiple_files" ToolNameEditFile = "edit_file" ToolNameWriteFile = "write_file" ToolNameDirectoryTree = "directory_tree" ToolNameListDirectory = "list_directory" ToolNameSearchFilesContent = "search_files_content" ToolNameMkdir = "create_directory" ToolNameRmdir = "remove_directory" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateDirectoryArgs ¶
type CreateDirectoryArgs struct {
Paths []string `json:"paths" jsonschema:"Directories to create"`
}
type DirectoryTreeArgs ¶
type DirectoryTreeArgs struct {
Path string `json:"path" jsonschema:"Directory to traverse"`
}
type DirectoryTreeMeta ¶
type EditFileArgs ¶
type EditFileArgs struct {
Path string `json:"path" jsonschema:"File to edit"`
Edits []Edit `json:"edits" jsonschema:"Edits to apply"`
}
func ParseEditFileArgs ¶
func ParseEditFileArgs(data []byte) (EditFileArgs, error)
ParseEditFileArgs parses LLM-generated edit_file arguments, handling two common failure modes:
- The outer JSON itself is malformed — typically extra closing braces/brackets or stray escape sequences caused by the model losing track of nesting depth when the text payload contains structural characters (e.g. YAML, Dockerfiles).
- The "edits" field is double-serialized (a JSON string instead of an array).
type ListDirectoryArgs ¶
type ListDirectoryArgs struct {
Path string `json:"path" jsonschema:"Directory to list"`
}
type ListDirectoryMeta ¶
type Opt ¶
type Opt func(*Tool)
func WithAllowList ¶
WithAllowList restricts every filesystem operation to paths that resolve under one of the supplied roots. Each entry may be:
- "." — the agent's working directory
- "~" or "~/..." — the user's home directory
- "$VAR" / "${VAR}" — an environment variable
- any absolute or relative path (relative paths are anchored at the working directory)
Symlinks are resolved before the containment check, so a symlink inside an allowed root cannot be used to escape it. An empty or nil slice disables the allow-list and preserves the default behaviour (any path is allowed).
Invalid entries (e.g. an empty string) are logged and the allow-list is silently dropped, mirroring how WithIgnoreVCS handles construction errors.
func WithDenyList ¶
WithDenyList forbids every filesystem operation on paths that resolve under one of the supplied roots. Tokens follow the same expansion rules as WithAllowList. The deny-list takes precedence over the allow-list: a path that matches both is rejected. An empty or nil slice disables the deny-list.
func WithIgnoreVCS ¶
func WithPostEditCommands ¶
func WithPostEditCommands(postEditCommands []PostEditConfig) Opt
type PostEditConfig ¶
type PostEditConfig struct {
Path string // File path pattern (glob-style)
Cmd string // Command to execute (with $path placeholder)
}
PostEditConfig represents a post-edit command configuration
type ReadFileArgs ¶
type ReadFileArgs struct {
Path string `json:"path" jsonschema:"File to read"`
}
type ReadFileMeta ¶
type ReadMultipleFilesArgs ¶
type ReadMultipleFilesMeta ¶
type ReadMultipleFilesMeta struct {
Files []ReadFileMeta `json:"files"`
}
type RemoveDirectoryArgs ¶
type RemoveDirectoryArgs struct {
Paths []string `json:"paths" jsonschema:"Directories to remove"`
}
type SearchFilesContentArgs ¶
type SearchFilesContentArgs struct {
Path string `json:"path" jsonschema:"Starting directory"`
Query string `json:"query" jsonschema:"Text or regex to search"`
IsRegex bool `json:"is_regex,omitempty" jsonschema:"Treat query as regex"`
ExcludePatterns []string `json:"excludePatterns,omitempty" jsonschema:"Patterns to exclude"`
}
type SearchFilesContentMeta ¶
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
func NewFilesystemTool ¶
func (*Tool) Close ¶
Close releases any *os.Root file descriptors held by the allow/deny lists. It is safe to call Close multiple times.