Documentation
¶
Index ¶
- Constants
- Variables
- func Definitions(registry map[string]Tool) []openai.ChatCompletionToolUnionParam
- func DiffStat(diff string) (added, removed int)
- func NewFunctionTool(name, description string, params openai.FunctionParameters) openai.ChatCompletionToolUnionParam
- func ReadOnlyCommand(cmdStr string) bool
- func Registry(opts Options) map[string]Tool
- func SanitizeToolName(name string) string
- func UnifiedDiff(path, before, after string) string
- type BackgroundProcess
- type EditFileTool
- type KillProcessTool
- type MCPTool
- type Options
- type PermissionRequest
- type ReadFileTool
- type ReadLogsTool
- type SearchResponse
- type SearchResult
- type ShellCmdTool
- type Tool
- type WebSearchTool
- type Whitelist
- type WriteFileTool
- type WriteGate
Constants ¶
const ( PermShell = "shell" PermWrite = "write" )
Variables ¶
var ( UseStdinForPrompt = false // used for testing // Returns "y", "a" or "n" plus an optional alternative instruction on denial PromptPermission func(req PermissionRequest) (choice, alt string) )
var ( BgProcesses = map[string]*BackgroundProcess{} BgProcessesMu sync.Mutex )
Functions ¶
func Definitions ¶
func Definitions(registry map[string]Tool) []openai.ChatCompletionToolUnionParam
Returns the OpenAI tool definitions sorted by name
func NewFunctionTool ¶
func NewFunctionTool(name, description string, params openai.FunctionParameters) openai.ChatCompletionToolUnionParam
func SanitizeToolName ¶
Maps a name onto ^[a-zA-Z0-9_-]{1,64}$
Types ¶
type BackgroundProcess ¶
type EditFileTool ¶
type EditFileTool struct {
Gate *WriteGate
}
EditFileTool implements Tool for search/replace edits.
func (EditFileTool) Definition ¶
func (e EditFileTool) Definition() openai.ChatCompletionToolUnionParam
func (EditFileTool) Name ¶
func (EditFileTool) Name() string
type KillProcessTool ¶
type KillProcessTool struct{}
func (KillProcessTool) Definition ¶
func (k KillProcessTool) Definition() openai.ChatCompletionToolUnionParam
func (KillProcessTool) Name ¶
func (KillProcessTool) Name() string
type MCPTool ¶
type MCPTool struct {
// contains filtered or unexported fields
}
MCPTool adapts an MCP tool behind the tools.Tool interface
func (MCPTool) Definition ¶
func (m MCPTool) Definition() openai.ChatCompletionToolUnionParam
type PermissionRequest ¶
type PermissionRequest struct {
Kind string
Command string // shell: full command
Background bool // shell: runs in background
Path string // write: target file
Diff string // write: unified diff of the change
}
What a tool asks the user to approve
type ReadFileTool ¶
type ReadFileTool struct{}
ReadFileTool implements Tool for reading files.
func (ReadFileTool) Definition ¶
func (r ReadFileTool) Definition() openai.ChatCompletionToolUnionParam
func (ReadFileTool) Name ¶
func (ReadFileTool) Name() string
type ReadLogsTool ¶
type ReadLogsTool struct{}
func (ReadLogsTool) Definition ¶
func (r ReadLogsTool) Definition() openai.ChatCompletionToolUnionParam
func (ReadLogsTool) Name ¶
func (ReadLogsTool) Name() string
type SearchResponse ¶
type SearchResponse struct {
Answer string `json:"answer,omitempty"`
Results []SearchResult `json:"results"`
}
type SearchResult ¶
type ShellCmdTool ¶
ShellCmdTool implements Tool for executing shell commands
func (ShellCmdTool) Definition ¶
func (s ShellCmdTool) Definition() openai.ChatCompletionToolUnionParam
func (ShellCmdTool) Name ¶
func (ShellCmdTool) Name() string
type WebSearchTool ¶
type WebSearchTool struct {
// contains filtered or unexported fields
}
WebSearchTool implements Tool for searching the web using Tavily.
func NewWebSearchTool ¶
func NewWebSearchTool(apiKey string) WebSearchTool
func (WebSearchTool) Definition ¶
func (w WebSearchTool) Definition() openai.ChatCompletionToolUnionParam
func (WebSearchTool) Name ¶
func (WebSearchTool) Name() string
type Whitelist ¶
type Whitelist struct {
// contains filtered or unexported fields
}
func NewWhitelist ¶
type WriteFileTool ¶
type WriteFileTool struct {
Gate *WriteGate
}
WriteFileTool implements Tool for writing/appending files.
func (WriteFileTool) Definition ¶
func (w WriteFileTool) Definition() openai.ChatCompletionToolUnionParam
func (WriteFileTool) Name ¶
func (WriteFileTool) Name() string
type WriteGate ¶
type WriteGate struct {
// contains filtered or unexported fields
}
Gates file writes (shared by write_file and edit_file)