Documentation
¶
Index ¶
Constants ¶
View Source
const BASH_DESCRIPTION = `Executes a given bash command and returns its output. Supports multi-line scripts.`
View Source
const GLOB_DESCRIPTION = `` /* 145-byte string literal not displayed */
View Source
const GREP_DESCRIPTION = `` /* 280-byte string literal not displayed */
View Source
const MODIFY_FILE_DESCRIPTION = `` /* 242-byte string literal not displayed */
View Source
const PYTHON_DESCRIPTION = `Executes the given Python script and returns its output.`
View Source
const READ_FILE_DESCRIPTION = `` /* 176-byte string literal not displayed */
View Source
const WRITE_FILE_DESCRIPTION = `` /* 170-byte string literal not displayed */
Variables ¶
View Source
var BashTool = api.ToolSpec{ Name: "Bash", Permission: api.ToolPermExec, Description: BASH_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "command", Type: "string", Description: "The command to execute", Required: true, }, { Name: "description", Type: "string", Description: "Clear, concise description of what this command does", }, { Name: "timeout", Type: "integer", Description: "Optional timeout in milliseconds (max 600000)", }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { command, ok := args["command"].(string) if !ok || command == "" { return "", fmt.Errorf("command parameter is required") } timeoutMs := 120000 if tmp, ok := args["timeout"]; ok { if v, ok := tmp.(float64); ok && v > 0 { timeoutMs = int(v) if timeoutMs > 600000 { timeoutMs = 600000 } } } return runBash(command, timeoutMs) }, }
View Source
var GlobTool = api.ToolSpec{ Name: "Glob", Permission: api.ToolPermRead, Description: GLOB_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "pattern", Type: "string", Description: "The glob pattern to match files against", Required: true, }, { Name: "path", Type: "string", Description: "The directory to search in. Defaults to current working directory.", }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { pattern, ok := args["pattern"].(string) if !ok || pattern == "" { return "", fmt.Errorf("pattern parameter is required") } var path string if tmp, ok := args["path"]; ok { path, _ = tmp.(string) } return globSearch(pattern, path) }, }
View Source
var GrepTool = api.ToolSpec{ Name: "Grep", Permission: api.ToolPermRead, Description: GREP_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "pattern", Type: "string", Description: "The regular expression pattern to search for in file contents", Required: true, }, { Name: "path", Type: "string", Description: "File or directory to search in. Defaults to current working directory.", }, { Name: "glob", Type: "string", Description: `Glob pattern to filter files (e.g. "*.js", "**/*.tsx") - maps to rg --glob`, }, { Name: "type", Type: "string", Description: "File type to search (e.g. js, py, rust, go, java)", }, { Name: "output_mode", Type: "string", Description: `Output mode. Defaults to "files_with_matches".`, Enum: []string{"content", "files_with_matches", "count"}, }, { Name: "-i", Type: "boolean", Description: "Case insensitive search", }, { Name: "-n", Type: "boolean", Description: `Show line numbers in output (requires output_mode: "content")`, }, { Name: "context", Type: "integer", Description: `Number of lines to show before and after each match (requires output_mode: "content")`, }, { Name: "-A", Type: "integer", Description: `Number of lines to show after each match (requires output_mode: "content")`, }, { Name: "-B", Type: "integer", Description: `Number of lines to show before each match (requires output_mode: "content")`, }, { Name: "multiline", Type: "boolean", Description: "Enable multiline mode where . matches newlines. Default: false.", }, { Name: "head_limit", Type: "integer", Description: `Limit output to first N lines/entries. Defaults to 250.`, }, { Name: "offset", Type: "integer", Description: "Skip first N lines/entries. Defaults to 0.", }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { pattern, ok := args["pattern"].(string) if !ok || pattern == "" { return "", fmt.Errorf("pattern parameter is required") } var path string if tmp, ok := args["path"]; ok { path, _ = tmp.(string) } var glob string if tmp, ok := args["glob"]; ok { glob, _ = tmp.(string) } var fileType string if tmp, ok := args["type"]; ok { fileType, _ = tmp.(string) } outputMode := "files_with_matches" if tmp, ok := args["output_mode"]; ok { if v, ok := tmp.(string); ok && v != "" { outputMode = v } } caseInsensitive := false if tmp, ok := args["-i"]; ok { caseInsensitive, _ = tmp.(bool) } showLineNums := true if tmp, ok := args["-n"]; ok { showLineNums, _ = tmp.(bool) } multiline := false if tmp, ok := args["multiline"]; ok { multiline, _ = tmp.(bool) } var contextLines int if tmp, ok := args["context"]; ok { if v, ok := tmp.(float64); ok { contextLines = int(v) } } var contextAfter int if tmp, ok := args["-A"]; ok { if v, ok := tmp.(float64); ok { contextAfter = int(v) } } var contextBefore int if tmp, ok := args["-B"]; ok { if v, ok := tmp.(float64); ok { contextBefore = int(v) } } headLimit := -1 if tmp, ok := args["head_limit"]; ok { if v, ok := tmp.(float64); ok { headLimit = int(v) } } if headLimit < 0 { headLimit = 250 } var offset int if tmp, ok := args["offset"]; ok { if v, ok := tmp.(float64); ok { offset = int(v) } } return grepSearch(pattern, path, glob, fileType, caseInsensitive, showLineNums, multiline, contextLines, contextAfter, contextBefore, outputMode, headLimit, offset) }, }
View Source
var ModifyFile = api.ToolSpec{ Name: "Edit", Permission: api.ToolPermWrite, Description: MODIFY_FILE_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "file_path", Type: "string", Description: "The path to the file to modify", Required: true, }, { Name: "old_string", Type: "string", Description: "The text to replace", Required: true, }, { Name: "new_string", Type: "string", Description: "The text to replace it with (must be different from old_string)", Required: true, }, { Name: "replace_all", Type: "boolean", Description: "Replace all occurrences of old_string (default false)", }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { path, ok := args["file_path"].(string) if !ok || path == "" { return "", fmt.Errorf("file_path parameter is required") } oldString, ok := args["old_string"].(string) if !ok { return "", fmt.Errorf("old_string parameter is required") } var newString string if tmp, ok := args["new_string"]; ok { newString, _ = tmp.(string) } replaceAll := false if tmp, ok := args["replace_all"]; ok { replaceAll, _ = tmp.(bool) } return editFile(path, oldString, newString, replaceAll) }, }
View Source
var PythonTool = api.ToolSpec{ Name: "Python", Permission: api.ToolPermExec, Description: PYTHON_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "command", Type: "string", Description: "The Python code to execute", Required: true, }, { Name: "description", Type: "string", Description: "Brief description of what this script does", }, { Name: "with", Type: "array", Description: "Run with the given packages installed (passed to uv run --with)", Items: &api.Items{Type: "string"}, }, { Name: "timeout", Type: "integer", Description: "Timeout in milliseconds (max 600000)", }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { command, ok := args["command"].(string) if !ok || command == "" { return "", fmt.Errorf("command parameter is required") } var deps []string if tmp, ok := args["with"]; ok { if arr, ok := tmp.([]any); ok { for _, v := range arr { if s, ok := v.(string); ok && s != "" { deps = append(deps, s) } } } } timeoutMs := 120000 if tmp, ok := args["timeout"]; ok { if v, ok := tmp.(float64); ok && v > 0 { timeoutMs = min(int(v), 600_000) } } return runPython(command, deps, timeoutMs) }, }
View Source
var ReadFileTool = api.ToolSpec{ Name: "Read", Description: READ_FILE_DESCRIPTION, Permission: api.ToolPermRead, Parameters: []api.ToolParameter{ { Name: "file_path", Type: "string", Description: "The path to the file to read", Required: true, }, { Name: "offset", Type: "integer", Description: "The line number to start reading from. Only provide if the file is too large to read at once.", }, { Name: "limit", Type: "integer", Description: "The number of lines to read. Only provide if the file is too large to read at once.", }, { Name: "pages", Type: "string", Description: `Page range for PDF files (e.g. "1-5", "3"). Only applicable to PDF files.`, }, }, Impl: func(tool *api.ToolSpec, args map[string]any) (string, error) { tmp, ok := args["file_path"] if !ok { return "", fmt.Errorf("file_path parameter to Read was not included.") } path, ok := tmp.(string) if !ok { return "", fmt.Errorf("Invalid file_path in function arguments: %v", tmp) } var offset, limit int if tmp, ok := args["offset"]; ok { if v, ok := tmp.(float64); ok { offset = int(v) } } if tmp, ok := args["limit"]; ok { if v, ok := tmp.(float64); ok { limit = int(v) } } return readFile(path, offset, limit) }, }
View Source
var WriteFileTool = api.ToolSpec{ Name: "Write", Permission: api.ToolPermWrite, Description: WRITE_FILE_DESCRIPTION, Parameters: []api.ToolParameter{ { Name: "file_path", Type: "string", Description: "The path to the file to write", Required: true, }, { Name: "content", Type: "string", Description: "The content to write to the file", Required: true, }, }, Impl: func(t *api.ToolSpec, args map[string]any) (string, error) { tmp, ok := args["file_path"] if !ok { return "", fmt.Errorf("file_path parameter to Write was not included.") } path, ok := tmp.(string) if !ok { return "", fmt.Errorf("Invalid file_path in function arguments: %v", tmp) } tmp, ok = args["content"] if !ok { return "", fmt.Errorf("Content parameter to Write was not included.") } content, ok := tmp.(string) if !ok { return "", fmt.Errorf("Invalid content in function arguments: %v", tmp) } return writeFile(path, content) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.