Documentation
¶
Index ¶
- Constants
- func RegisterBuiltinTools(registry *Registry, policy permission.PermissionPolicy, workingDir string) error
- func StripHTML(s string) string
- func TodoDir(workspace string) string
- func TodoFilePath(workspace string) string
- func ToolDef(t Tool) provider.ToolDefinition
- type AllowedPathChecker
- type AskUserAnswer
- type AskUserChoice
- type AskUserHandler
- type AskUserQuestion
- type AskUserRequest
- type AskUserResponse
- type AskUserTool
- func (t *AskUserTool) Description() string
- func (t *AskUserTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
- func (t *AskUserTool) HasHandler() bool
- func (t *AskUserTool) Name() string
- func (t *AskUserTool) Parameters() json.RawMessage
- func (t *AskUserTool) SetHandler(handler AskUserHandler)
- type CommandJob
- type CommandJobManager
- func (m *CommandJobManager) List() []CommandJobSnapshot
- func (m *CommandJobManager) Read(id string, tailLines, sinceLine int) (CommandJobSnapshot, error)
- func (m *CommandJobManager) Start(ctx context.Context, command string, timeout time.Duration) (*CommandJobSnapshot, error)
- func (m *CommandJobManager) Stop(id string) (CommandJobSnapshot, error)
- func (m *CommandJobManager) Wait(ctx context.Context, id string, wait time.Duration, tailLines, sinceLine int) (CommandJobSnapshot, error)
- func (m *CommandJobManager) Write(id, input string, appendNewline bool) (CommandJobSnapshot, error)
- type CommandJobSnapshot
- type CommandJobStatus
- type EditFile
- type GetMCPPromptTool
- type GitDiff
- type GitLog
- type GitStatus
- type Glob
- type ListAgentsTool
- type ListCommandsTool
- type ListDir
- type ListMCPCapabilitiesTool
- type MCPPromptMessage
- type MCPPromptResult
- type MCPResourceContent
- type MCPResourceResult
- type MCPRuntime
- type MCPServerSnapshot
- type ReadCommandOutputTool
- type ReadFile
- type ReadMCPResourceTool
- type Registry
- type Result
- type RunCommand
- type SaveMemoryTool
- type SearchFiles
- type SkillLookup
- type SkillTool
- type SpawnAgentTool
- type StartCommandTool
- type StopCommandTool
- type Todo
- type TodoWrite
- type Tool
- type WaitAgentTool
- type WaitCommandTool
- type WebFetch
- type WebSearch
- type WriteCommandInputTool
- type WriteFile
Constants ¶
const ( AskUserKindSingle = "single" AskUserKindMulti = "multi" AskUserKindText = "text" AskUserStatusSubmitted = "submitted" AskUserStatusCancelled = "cancelled" AskUserCompletionUnanswered = "unanswered" AskUserCompletionPartial = "partial" AskUserCompletionAnswered = "answered" AskUserAnswerModeNone = "none" AskUserAnswerModeFreeformOnly = "freeform_only" AskUserAnswerModeSelectionOnly = "selection_only" AskUserAnswerModeSelectionAndFreeform = "selection_and_freeform" )
Variables ¶
This section is empty.
Functions ¶
func RegisterBuiltinTools ¶
func RegisterBuiltinTools(registry *Registry, policy permission.PermissionPolicy, workingDir string) error
RegisterBuiltinTools registers all built-in tools. If policy is nil, no sandbox path checking is enforced (permissive mode).
func TodoFilePath ¶ added in v1.1.7
func ToolDef ¶
func ToolDef(t Tool) provider.ToolDefinition
ToolDef creates a provider.ToolDefinition from a Tool.
Types ¶
type AllowedPathChecker ¶
AllowedPathChecker is a function that checks if a path is allowed by sandbox policy.
type AskUserAnswer ¶ added in v1.1.12
type AskUserAnswer struct {
ID string `json:"id"`
Title string `json:"title"`
Kind string `json:"kind"`
CompletionStatus string `json:"completion_status"`
AnswerMode string `json:"answer_mode"`
Answered bool `json:"answered"`
SelectedChoiceIDs []string `json:"selected_choice_ids,omitempty"`
SelectedChoices []string `json:"selected_choices,omitempty"`
FreeformText string `json:"freeform_text,omitempty"`
}
type AskUserChoice ¶ added in v1.1.12
type AskUserHandler ¶ added in v1.1.12
type AskUserHandler func(context.Context, AskUserRequest) (AskUserResponse, error)
type AskUserQuestion ¶ added in v1.1.12
type AskUserRequest ¶ added in v1.1.12
type AskUserRequest struct {
Title string `json:"title,omitempty"`
Questions []AskUserQuestion `json:"questions"`
}
type AskUserResponse ¶ added in v1.1.12
type AskUserResponse struct {
Status string `json:"status"`
Title string `json:"title,omitempty"`
QuestionCount int `json:"question_count"`
AnsweredCount int `json:"answered_count"`
Answers []AskUserAnswer `json:"answers"`
}
type AskUserTool ¶ added in v1.1.12
type AskUserTool struct {
// contains filtered or unexported fields
}
func NewAskUserTool ¶ added in v1.1.12
func NewAskUserTool() *AskUserTool
func (*AskUserTool) Description ¶ added in v1.1.12
func (t *AskUserTool) Description() string
func (*AskUserTool) Execute ¶ added in v1.1.12
func (t *AskUserTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (*AskUserTool) HasHandler ¶ added in v1.1.15
func (t *AskUserTool) HasHandler() bool
func (*AskUserTool) Name ¶ added in v1.1.12
func (t *AskUserTool) Name() string
func (*AskUserTool) Parameters ¶ added in v1.1.12
func (t *AskUserTool) Parameters() json.RawMessage
func (*AskUserTool) SetHandler ¶ added in v1.1.12
func (t *AskUserTool) SetHandler(handler AskUserHandler)
type CommandJob ¶
type CommandJobManager ¶
type CommandJobManager struct {
// contains filtered or unexported fields
}
func NewCommandJobManager ¶
func NewCommandJobManager(workingDir string) *CommandJobManager
func (*CommandJobManager) List ¶
func (m *CommandJobManager) List() []CommandJobSnapshot
func (*CommandJobManager) Read ¶
func (m *CommandJobManager) Read(id string, tailLines, sinceLine int) (CommandJobSnapshot, error)
func (*CommandJobManager) Start ¶
func (m *CommandJobManager) Start(ctx context.Context, command string, timeout time.Duration) (*CommandJobSnapshot, error)
func (*CommandJobManager) Stop ¶
func (m *CommandJobManager) Stop(id string) (CommandJobSnapshot, error)
func (*CommandJobManager) Wait ¶
func (m *CommandJobManager) Wait(ctx context.Context, id string, wait time.Duration, tailLines, sinceLine int) (CommandJobSnapshot, error)
func (*CommandJobManager) Write ¶ added in v1.0.23
func (m *CommandJobManager) Write(id, input string, appendNewline bool) (CommandJobSnapshot, error)
type CommandJobSnapshot ¶
type CommandJobStatus ¶
type CommandJobStatus string
const ( CommandJobRunning CommandJobStatus = "running" CommandJobCompleted CommandJobStatus = "completed" CommandJobFailed CommandJobStatus = "failed" CommandJobCancelled CommandJobStatus = "cancelled" CommandJobTimedOut CommandJobStatus = "timed_out" )
type EditFile ¶
type EditFile struct {
SandboxCheck AllowedPathChecker
}
EditFile implements the edit_file tool for find-and-replace editing.
func (EditFile) Description ¶
func (EditFile) Parameters ¶
func (t EditFile) Parameters() json.RawMessage
type GetMCPPromptTool ¶
type GetMCPPromptTool struct {
Runtime MCPRuntime
}
func (GetMCPPromptTool) Description ¶
func (t GetMCPPromptTool) Description() string
func (GetMCPPromptTool) Execute ¶
func (t GetMCPPromptTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (GetMCPPromptTool) Name ¶
func (t GetMCPPromptTool) Name() string
func (GetMCPPromptTool) Parameters ¶
func (t GetMCPPromptTool) Parameters() json.RawMessage
type GitDiff ¶
type GitDiff struct{}
GitDiff implements the git_diff tool.
func (GitDiff) Description ¶
func (GitDiff) Parameters ¶
func (t GitDiff) Parameters() json.RawMessage
type GitLog ¶
type GitLog struct{}
GitLog implements the git_log tool.
func (GitLog) Description ¶
func (GitLog) Parameters ¶
func (t GitLog) Parameters() json.RawMessage
type GitStatus ¶
type GitStatus struct{}
GitStatus implements the git_status tool.
func (GitStatus) Description ¶
func (GitStatus) Parameters ¶
func (t GitStatus) Parameters() json.RawMessage
type Glob ¶
type Glob struct {
SandboxCheck AllowedPathChecker
}
Glob implements the glob tool for file path matching.
func (Glob) Description ¶
func (Glob) Parameters ¶
func (t Glob) Parameters() json.RawMessage
type ListAgentsTool ¶
ListAgentsTool implements the list_agents tool.
func (ListAgentsTool) Description ¶
func (t ListAgentsTool) Description() string
func (ListAgentsTool) Execute ¶
func (t ListAgentsTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (ListAgentsTool) Name ¶
func (t ListAgentsTool) Name() string
func (ListAgentsTool) Parameters ¶
func (t ListAgentsTool) Parameters() json.RawMessage
type ListCommandsTool ¶
type ListCommandsTool struct {
Manager *CommandJobManager
}
func (ListCommandsTool) Description ¶
func (t ListCommandsTool) Description() string
func (ListCommandsTool) Execute ¶
func (t ListCommandsTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (ListCommandsTool) Name ¶
func (t ListCommandsTool) Name() string
func (ListCommandsTool) Parameters ¶
func (t ListCommandsTool) Parameters() json.RawMessage
type ListDir ¶
type ListDir struct {
SandboxCheck AllowedPathChecker
}
ListDir implements the list_directory tool.
func (ListDir) Description ¶
func (ListDir) Parameters ¶
func (t ListDir) Parameters() json.RawMessage
type ListMCPCapabilitiesTool ¶
type ListMCPCapabilitiesTool struct {
Runtime MCPRuntime
}
func (ListMCPCapabilitiesTool) Description ¶
func (t ListMCPCapabilitiesTool) Description() string
func (ListMCPCapabilitiesTool) Execute ¶
func (t ListMCPCapabilitiesTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (ListMCPCapabilitiesTool) Name ¶
func (t ListMCPCapabilitiesTool) Name() string
func (ListMCPCapabilitiesTool) Parameters ¶
func (t ListMCPCapabilitiesTool) Parameters() json.RawMessage
type MCPPromptMessage ¶
type MCPPromptResult ¶
type MCPPromptResult struct {
Description string
Messages []MCPPromptMessage
}
type MCPResourceContent ¶
type MCPResourceResult ¶
type MCPResourceResult struct {
Contents []MCPResourceContent
}
type MCPRuntime ¶
type MCPRuntime interface {
SnapshotMCP() []MCPServerSnapshot
GetPrompt(ctx context.Context, server, name string, args map[string]interface{}) (*MCPPromptResult, error)
ReadResource(ctx context.Context, server, uri string) (*MCPResourceResult, error)
}
type MCPServerSnapshot ¶
type ReadCommandOutputTool ¶
type ReadCommandOutputTool struct {
Manager *CommandJobManager
}
func (ReadCommandOutputTool) Description ¶
func (t ReadCommandOutputTool) Description() string
func (ReadCommandOutputTool) Execute ¶
func (t ReadCommandOutputTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (ReadCommandOutputTool) Name ¶
func (t ReadCommandOutputTool) Name() string
func (ReadCommandOutputTool) Parameters ¶
func (t ReadCommandOutputTool) Parameters() json.RawMessage
type ReadFile ¶
type ReadFile struct {
SandboxCheck AllowedPathChecker
}
ReadFile implements the read_file tool.
func (ReadFile) Description ¶
func (ReadFile) Parameters ¶
func (t ReadFile) Parameters() json.RawMessage
type ReadMCPResourceTool ¶
type ReadMCPResourceTool struct {
Runtime MCPRuntime
}
func (ReadMCPResourceTool) Description ¶
func (t ReadMCPResourceTool) Description() string
func (ReadMCPResourceTool) Execute ¶
func (t ReadMCPResourceTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (ReadMCPResourceTool) Name ¶
func (t ReadMCPResourceTool) Name() string
func (ReadMCPResourceTool) Parameters ¶
func (t ReadMCPResourceTool) Parameters() json.RawMessage
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the set of available tools.
func (*Registry) Register ¶
Register adds a tool to the registry. Returns error if name is already taken.
func (*Registry) ToDefinitions ¶
func (r *Registry) ToDefinitions() []provider.ToolDefinition
ToDefinitions converts all tools to provider.ToolDefinition for the LLM.
func (*Registry) Unregister ¶
Unregister removes a tool by name.
type Result ¶
Result is the output returned to the LLM. IsError: true means the tool execution had a user-visible error (shown to LLM). The Go error return is for system-level failures only (panic recovery, etc).
type RunCommand ¶
type RunCommand struct {
// WorkingDir is the fixed working directory set by the agent.
// LLM-provided working_dir is ignored to prevent sandbox escape.
WorkingDir string
}
RunCommand implements the run_command tool for executing shell commands.
func (RunCommand) Description ¶
func (t RunCommand) Description() string
func (RunCommand) Execute ¶
func (t RunCommand) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (RunCommand) Name ¶
func (t RunCommand) Name() string
func (RunCommand) Parameters ¶
func (t RunCommand) Parameters() json.RawMessage
type SaveMemoryTool ¶
type SaveMemoryTool struct {
// contains filtered or unexported fields
}
SaveMemoryTool lets the agent save experiences to auto memory.
func NewSaveMemoryTool ¶
func NewSaveMemoryTool(am *memory.AutoMemory) *SaveMemoryTool
NewSaveMemoryTool creates a save_memory tool.
func (*SaveMemoryTool) Description ¶
func (t *SaveMemoryTool) Description() string
func (*SaveMemoryTool) Execute ¶
func (t *SaveMemoryTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (*SaveMemoryTool) Name ¶
func (t *SaveMemoryTool) Name() string
func (*SaveMemoryTool) Parameters ¶
func (t *SaveMemoryTool) Parameters() json.RawMessage
type SearchFiles ¶
type SearchFiles struct {
SandboxCheck AllowedPathChecker
}
SearchFiles implements the search_files tool (grep-like content search).
func (SearchFiles) Description ¶
func (t SearchFiles) Description() string
func (SearchFiles) Execute ¶
func (t SearchFiles) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (SearchFiles) Name ¶
func (t SearchFiles) Name() string
func (SearchFiles) Parameters ¶
func (t SearchFiles) Parameters() json.RawMessage
type SkillTool ¶
type SkillTool struct {
Skills SkillLookup
Runtime MCPRuntime
Provider provider.Provider
Tools *Registry
AgentFactory subagent.AgentFactory
}
func (SkillTool) Description ¶
func (SkillTool) Parameters ¶
func (t SkillTool) Parameters() json.RawMessage
type SpawnAgentTool ¶
type SpawnAgentTool struct {
Manager *subagent.Manager
Provider provider.Provider
Tools *Registry
AgentFactory subagent.AgentFactory
}
SpawnAgentTool implements the spawn_agent tool.
func (SpawnAgentTool) Description ¶
func (t SpawnAgentTool) Description() string
func (SpawnAgentTool) Execute ¶
func (t SpawnAgentTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (SpawnAgentTool) Name ¶
func (t SpawnAgentTool) Name() string
func (SpawnAgentTool) Parameters ¶
func (t SpawnAgentTool) Parameters() json.RawMessage
type StartCommandTool ¶
type StartCommandTool struct {
Manager *CommandJobManager
}
func (StartCommandTool) Description ¶
func (t StartCommandTool) Description() string
func (StartCommandTool) Execute ¶
func (t StartCommandTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (StartCommandTool) Name ¶
func (t StartCommandTool) Name() string
func (StartCommandTool) Parameters ¶
func (t StartCommandTool) Parameters() json.RawMessage
type StopCommandTool ¶
type StopCommandTool struct {
Manager *CommandJobManager
}
func (StopCommandTool) Description ¶
func (t StopCommandTool) Description() string
func (StopCommandTool) Execute ¶
func (t StopCommandTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (StopCommandTool) Name ¶
func (t StopCommandTool) Name() string
func (StopCommandTool) Parameters ¶
func (t StopCommandTool) Parameters() json.RawMessage
type Todo ¶
type Todo struct {
ID string `json:"id"`
Content string `json:"content"`
Status string `json:"status"` // "pending", "in_progress", "done"
}
Todo represents a single todo item.
type TodoWrite ¶
type TodoWrite struct {
// contains filtered or unexported fields
}
TodoWrite implements the todo_write tool — manages a persistent todo list.
func NewTodoWrite ¶
NewTodoWrite creates a TodoWrite tool. dir defaults to ~/.ggcode.
func NewWorkspaceTodoWrite ¶ added in v1.1.7
func (*TodoWrite) Description ¶
func (*TodoWrite) Parameters ¶
func (t *TodoWrite) Parameters() json.RawMessage
type Tool ¶
type Tool interface {
// Name returns the unique tool identifier (e.g., "read_file").
Name() string
// Description returns a human-readable description shown to the LLM.
Description() string
// Parameters returns a JSON Schema object describing the tool's input.
// Must be a valid JSON object with "type": "object" at minimum.
Parameters() json.RawMessage
// Execute runs the tool with the given input and returns the result.
Execute(ctx context.Context, input json.RawMessage) (Result, error)
}
Tool is the interface every tool (built-in, MCP-adapted, or plugin) must implement.
func NewLSPTools ¶ added in v1.1.25
func NewLSPTools(workingDir string, readSandbox, writeSandbox AllowedPathChecker) []Tool
type WaitAgentTool ¶
WaitAgentTool implements the wait_agent tool.
func (WaitAgentTool) Description ¶
func (t WaitAgentTool) Description() string
func (WaitAgentTool) Execute ¶
func (t WaitAgentTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (WaitAgentTool) Name ¶
func (t WaitAgentTool) Name() string
func (WaitAgentTool) Parameters ¶
func (t WaitAgentTool) Parameters() json.RawMessage
type WaitCommandTool ¶
type WaitCommandTool struct {
Manager *CommandJobManager
}
func (WaitCommandTool) Description ¶
func (t WaitCommandTool) Description() string
func (WaitCommandTool) Execute ¶
func (t WaitCommandTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (WaitCommandTool) Name ¶
func (t WaitCommandTool) Name() string
func (WaitCommandTool) Parameters ¶
func (t WaitCommandTool) Parameters() json.RawMessage
type WebFetch ¶
type WebFetch struct {
// AllowPrivate disables SSRF protection. Only use for testing.
AllowPrivate bool
}
WebFetch implements the web_fetch tool — fetches a URL and returns text content.
func (WebFetch) Description ¶
func (WebFetch) Parameters ¶
func (t WebFetch) Parameters() json.RawMessage
type WebSearch ¶
type WebSearch struct{}
WebSearch implements the web_search tool — searches using DuckDuckGo HTML.
func (WebSearch) Description ¶
func (WebSearch) Parameters ¶
func (t WebSearch) Parameters() json.RawMessage
type WriteCommandInputTool ¶ added in v1.0.23
type WriteCommandInputTool struct {
Manager *CommandJobManager
}
func (WriteCommandInputTool) Description ¶ added in v1.0.23
func (t WriteCommandInputTool) Description() string
func (WriteCommandInputTool) Execute ¶ added in v1.0.23
func (t WriteCommandInputTool) Execute(ctx context.Context, input json.RawMessage) (Result, error)
func (WriteCommandInputTool) Name ¶ added in v1.0.23
func (t WriteCommandInputTool) Name() string
func (WriteCommandInputTool) Parameters ¶ added in v1.0.23
func (t WriteCommandInputTool) Parameters() json.RawMessage
type WriteFile ¶
type WriteFile struct {
SandboxCheck AllowedPathChecker
}
WriteFile implements the write_file tool.
func (WriteFile) Description ¶
func (WriteFile) Parameters ¶
func (t WriteFile) Parameters() json.RawMessage
Source Files
¶
- ask_user.go
- builtin.go
- command_job_tools.go
- command_jobs.go
- edit_file.go
- git_diff.go
- git_log.go
- git_status.go
- glob.go
- list_agents.go
- list_dir.go
- lsp.go
- mcp_runtime.go
- read_file.go
- run_command.go
- run_command_unix.go
- save_memory.go
- search_files.go
- skill.go
- spawn_agent.go
- todo_write.go
- tool.go
- wait_agent.go
- web_fetch.go
- web_search.go
- write_file.go