Documentation
¶
Overview ¶
Package tools implements the agent's file and shell tools, sandboxed to a root directory.
Index ¶
- func Bash(ctx context.Context, root, command string, timeout time.Duration) (string, error)
- func EditFile(root, path, oldStr, newStr string, replaceAll bool) (int, error)
- func Grep(root, pattern, path, include string) (string, error)
- func ListFiles(root, path, pattern string) (string, error)
- func ReadFile(root, path string, offset, limit int) (string, error)
- func Resolve(root, path string) (string, error)
- func Specs() []model.ToolSpec
- func WriteFile(root, path, content string) error
- type Executor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bash ¶
Bash runs command in a fresh `bash -c` process in root. On timeout the whole process group is killed so background children do not linger.
func EditFile ¶
EditFile replaces the single occurrence of oldStr with newStr, or every occurrence if replaceAll is set, and returns the number of replacements.
func Grep ¶
Grep returns lines matching pattern as "file:line: content". Binary and very large files are skipped. A non-empty include glob limits the search to matching files, using the same rules as ListFiles: a glob without "/" matches base names, a glob with "/" matches paths relative to the searched directory. When path is a single file, include is ignored.
func ListFiles ¶
ListFiles lists the entries of a directory, or, with a pattern, walks it recursively and returns matching files. A pattern without "/" matches base names; a pattern with "/" matches paths relative to the listed directory.
func ReadFile ¶
ReadFile returns a file's contents. A positive offset (1-based start line) or limit (max lines) returns just that range, ending in a "[lines A-B of N]" note when the range isn't the whole file.