Documentation
¶
Index ¶
- func ContextWithQuestionAsker(ctx context.Context, asker QuestionAsker) context.Context
- func ToolDefinition(t Tool) provider.ToolDefinition
- type A2ADispatchTool
- func (t *A2ADispatchTool) Description() string
- func (t *A2ADispatchTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *A2ADispatchTool) Name() string
- func (t *A2ADispatchTool) Parameters() json.RawMessage
- func (t *A2ADispatchTool) PromptGuidelines() []string
- func (t *A2ADispatchTool) PromptSnippet() string
- type A2ADispatcher
- type AgentEntry
- type BackgroundJob
- type BashTool
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *BashTool) ExecutionTimeout(params map[string]any) (time.Duration, bool)
- func (t *BashTool) GetJobManager() *JobManager
- func (t *BashTool) Name() string
- func (t *BashTool) Parameters() json.RawMessage
- func (t *BashTool) PromptGuidelines() []string
- func (t *BashTool) PromptSnippet() string
- type EditTool
- func (t *EditTool) Description() string
- func (t *EditTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *EditTool) Name() string
- func (t *EditTool) Parameters() json.RawMessage
- func (t *EditTool) PromptGuidelines() []string
- func (t *EditTool) PromptSnippet() string
- type ExecutionTimeoutProvider
- type FileDiff
- type FileLockManager
- type FindTool
- func (t *FindTool) Description() string
- func (t *FindTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *FindTool) Name() string
- func (t *FindTool) Parameters() json.RawMessage
- func (t *FindTool) PromptGuidelines() []string
- func (t *FindTool) PromptSnippet() string
- type GrepTool
- func (t *GrepTool) Description() string
- func (t *GrepTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *GrepTool) Name() string
- func (t *GrepTool) Parameters() json.RawMessage
- func (t *GrepTool) PromptGuidelines() []string
- func (t *GrepTool) PromptSnippet() string
- type JobManager
- type JobsTool
- func (t *JobsTool) Description() string
- func (t *JobsTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *JobsTool) Name() string
- func (t *JobsTool) Parameters() json.RawMessage
- func (t *JobsTool) PromptGuidelines() []string
- func (t *JobsTool) PromptSnippet() string
- type KillTool
- func (t *KillTool) Description() string
- func (t *KillTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *KillTool) Name() string
- func (t *KillTool) Parameters() json.RawMessage
- func (t *KillTool) PromptGuidelines() []string
- func (t *KillTool) PromptSnippet() string
- type LsTool
- type PlanStep
- type PlanTool
- func (t *PlanTool) Description() string
- func (t *PlanTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *PlanTool) Name() string
- func (t *PlanTool) Parameters() json.RawMessage
- func (t *PlanTool) PromptGuidelines() []string
- func (t *PlanTool) PromptSnippet() string
- type QuestionAsker
- type QuestionTool
- func (t *QuestionTool) Description() string
- func (t *QuestionTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *QuestionTool) Name() string
- func (t *QuestionTool) Parameters() json.RawMessage
- func (t *QuestionTool) PromptGuidelines() []string
- func (t *QuestionTool) PromptSnippet() string
- type ReadTool
- func (t *ReadTool) Description() string
- func (t *ReadTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *ReadTool) Name() string
- func (t *ReadTool) Parameters() json.RawMessage
- func (t *ReadTool) PromptGuidelines() []string
- func (t *ReadTool) PromptSnippet() string
- type Registry
- func (r *Registry) All() []Tool
- func (r *Registry) Definitions() []provider.ToolDefinition
- func (r *Registry) FileLocks() *FileLockManager
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) GetSandbox() sandbox.Sandbox
- func (r *Registry) GetWorkDir() string
- func (r *Registry) ImagePolicy(mode imageproc.Mode) imageproc.Policy
- func (r *Registry) JobManager() *JobManager
- func (r *Registry) ModeTools(mode string) []provider.ToolDefinition
- func (r *Registry) Register(t Tool)
- func (r *Registry) RegisterDefaults()
- func (r *Registry) RegisterDefaultsWithPlanTool(enablePlanTool bool)
- func (r *Registry) RegisterFiltered(toolNames []string)
- func (r *Registry) Remove(name string)
- func (r *Registry) ResolvePath(path string) (string, error)
- func (r *Registry) SetImageHint(h imageproc.Hint)
- func (r *Registry) SetSandbox(sb sandbox.Sandbox)
- func (r *Registry) ToolGuidelines(toolNames []string) []string
- func (r *Registry) ToolSnippets(toolNames []string) map[string]string
- type RegistryConfig
- type SetTool
- type SkillRefTool
- func (t *SkillRefTool) Description() string
- func (t *SkillRefTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *SkillRefTool) Name() string
- func (t *SkillRefTool) Parameters() json.RawMessage
- func (t *SkillRefTool) PromptGuidelines() []string
- func (t *SkillRefTool) PromptSnippet() string
- type TaskPlan
- type Tool
- type ToolResult
- func NewDiffToolResult(text string, diff *FileDiff) ToolResult
- func NewImageToolResult(text, mimeType, base64Data string) ToolResult
- func NewImageToolResultWithContent(text string, image provider.ImageContent) ToolResult
- func NewPlanToolResult(text string, plan *TaskPlan) ToolResult
- func NewTextToolResult(text string) ToolResult
- type WriteTool
- func (t *WriteTool) Description() string
- func (t *WriteTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
- func (t *WriteTool) Name() string
- func (t *WriteTool) Parameters() json.RawMessage
- func (t *WriteTool) PromptGuidelines() []string
- func (t *WriteTool) PromptSnippet() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithQuestionAsker ¶
func ContextWithQuestionAsker(ctx context.Context, asker QuestionAsker) context.Context
ContextWithQuestionAsker attaches a QuestionAsker to the context.
func ToolDefinition ¶
func ToolDefinition(t Tool) provider.ToolDefinition
ToolDefinition converts a Tool to a provider.ToolDefinition.
Types ¶
type A2ADispatchTool ¶
type A2ADispatchTool struct {
// contains filtered or unexported fields
}
A2ADispatchTool sends tasks to registered remote A2A agents.
func NewA2ADispatchTool ¶
func NewA2ADispatchTool(dispatcher A2ADispatcher) *A2ADispatchTool
NewA2ADispatchTool creates a new A2A dispatch tool.
func (*A2ADispatchTool) Description ¶
func (t *A2ADispatchTool) Description() string
func (*A2ADispatchTool) Execute ¶
func (t *A2ADispatchTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
func (*A2ADispatchTool) Name ¶
func (t *A2ADispatchTool) Name() string
func (*A2ADispatchTool) Parameters ¶
func (t *A2ADispatchTool) Parameters() json.RawMessage
func (*A2ADispatchTool) PromptGuidelines ¶
func (t *A2ADispatchTool) PromptGuidelines() []string
func (*A2ADispatchTool) PromptSnippet ¶
func (t *A2ADispatchTool) PromptSnippet() string
type A2ADispatcher ¶
type A2ADispatcher interface {
List() []AgentEntry
Dispatch(ctx context.Context, name, message string) (string, error)
}
A2ADispatcher is the interface needed by the a2a_dispatch tool. It is satisfied by a2a.A2AManager.
type AgentEntry ¶
AgentEntry is a minimal view of a remote A2A agent.
type BackgroundJob ¶
type BackgroundJob struct {
ID int
Command string
PID int
StartTime time.Time
// contains filtered or unexported fields
}
BackgroundJob represents a running background process.
func (*BackgroundJob) IsDone ¶
func (job *BackgroundJob) IsDone() bool
IsDone returns whether the job is finished.
func (*BackgroundJob) MarkDone ¶
func (job *BackgroundJob) MarkDone(stdout, stderr []byte, err error)
MarkDone marks a job as finished and stores output.
func (*BackgroundJob) Status ¶
func (job *BackgroundJob) Status() string
Status returns a string representation of the job status.
type BashTool ¶
type BashTool struct {
// contains filtered or unexported fields
}
BashTool executes shell commands.
func NewBashTool ¶
NewBashTool creates a new bash tool with a new JobManager.
func NewBashToolWithJM ¶
func NewBashToolWithJM(r *Registry, jm *JobManager) *BashTool
NewBashToolWithJM creates a new bash tool with an existing JobManager.
func (*BashTool) Description ¶
func (*BashTool) ExecutionTimeout ¶
ExecutionTimeout lets bash align the agent-level tool deadline with the runtime behavior exposed by Execute.
func (*BashTool) GetJobManager ¶
func (t *BashTool) GetJobManager() *JobManager
GetJobManager returns the job manager for background processes.
func (*BashTool) Parameters ¶
func (t *BashTool) Parameters() json.RawMessage
func (*BashTool) PromptGuidelines ¶
func (*BashTool) PromptSnippet ¶
type EditTool ¶
type EditTool struct {
// contains filtered or unexported fields
}
EditTool performs precise text replacements in files.
func (*EditTool) Description ¶
func (*EditTool) Parameters ¶
func (t *EditTool) Parameters() json.RawMessage
func (*EditTool) PromptGuidelines ¶
func (*EditTool) PromptSnippet ¶
type ExecutionTimeoutProvider ¶
type ExecutionTimeoutProvider interface {
ExecutionTimeout(params map[string]any) (time.Duration, bool)
}
ExecutionTimeoutProvider lets a tool override the agent's default execution timeout. The bool reports whether an override is provided. A non-positive duration disables the agent-level deadline while preserving parent cancellation.
type FileDiff ¶
type FileDiff struct {
Path string
Added int
Deleted int
AddedLines []int
DeletedLines []int
Unified string
Truncated bool
}
FileDiff describes a file change produced by a write-like tool.
func BuildFileDiff ¶
BuildFileDiff returns a compact, structured line diff for display and audit.
type FileLockManager ¶
type FileLockManager struct {
// contains filtered or unexported fields
}
FileLockManager coordinates in-process writes to individual files. It deliberately supports acquiring only one file at a time; write-like tools should not hold one file lock while waiting for another.
func DefaultFileLockManager ¶
func DefaultFileLockManager() *FileLockManager
DefaultFileLockManager returns the process-wide file lock manager used by default registries. It coordinates parent and sub-agent registries in the same process.
func NewFileLockManager ¶
func NewFileLockManager() *FileLockManager
NewFileLockManager creates an empty in-memory file lock manager.
type FindTool ¶
type FindTool struct {
// contains filtered or unexported fields
}
FindTool searches for files by name pattern using the go-fd SDK.
func (*FindTool) Description ¶
func (*FindTool) Parameters ¶
func (t *FindTool) Parameters() json.RawMessage
func (*FindTool) PromptGuidelines ¶
func (*FindTool) PromptSnippet ¶
type GrepTool ¶
type GrepTool struct {
// contains filtered or unexported fields
}
GrepTool searches file contents using the go-ripgrep SDK.
func (*GrepTool) Description ¶
func (*GrepTool) Parameters ¶
func (t *GrepTool) Parameters() json.RawMessage
func (*GrepTool) PromptGuidelines ¶
func (*GrepTool) PromptSnippet ¶
type JobManager ¶
type JobManager struct {
// contains filtered or unexported fields
}
JobManager manages background processes.
func (*JobManager) AddJob ¶
func (jm *JobManager) AddJob(cmd *exec.Cmd, command string, cancel context.CancelFunc) *BackgroundJob
AddJob adds a new background job.
func (*JobManager) GetJob ¶
func (jm *JobManager) GetJob(id int) *BackgroundJob
GetJob returns a job by ID.
func (*JobManager) KillJob ¶
func (jm *JobManager) KillJob(id int) error
KillJob kills a running job.
func (*JobManager) ListJobs ¶
func (jm *JobManager) ListJobs() []*BackgroundJob
ListJobs returns all jobs.
func (*JobManager) RemoveJob ¶
func (jm *JobManager) RemoveJob(id int)
RemoveJob removes a finished job.
type JobsTool ¶
type JobsTool struct {
// contains filtered or unexported fields
}
JobsTool lists and manages background jobs.
func NewJobsTool ¶
NewJobsTool creates a new jobs tool.
func (*JobsTool) Description ¶
func (*JobsTool) Parameters ¶
func (t *JobsTool) Parameters() json.RawMessage
func (*JobsTool) PromptGuidelines ¶
func (*JobsTool) PromptSnippet ¶
type KillTool ¶
type KillTool struct {
// contains filtered or unexported fields
}
KillTool stops a running background job.
func NewKillTool ¶
NewKillTool creates a new kill tool.
func (*KillTool) Description ¶
func (*KillTool) Parameters ¶
func (t *KillTool) Parameters() json.RawMessage
func (*KillTool) PromptGuidelines ¶
func (*KillTool) PromptSnippet ¶
type LsTool ¶
type LsTool struct {
// contains filtered or unexported fields
}
LsTool lists directory contents.
func (*LsTool) Description ¶
func (*LsTool) Parameters ¶
func (t *LsTool) Parameters() json.RawMessage
func (*LsTool) PromptGuidelines ¶
func (*LsTool) PromptSnippet ¶
type PlanTool ¶
type PlanTool struct {
// contains filtered or unexported fields
}
PlanTool publishes a structured task plan for UI and audit surfaces.
func (*PlanTool) Description ¶
func (*PlanTool) Parameters ¶
func (t *PlanTool) Parameters() json.RawMessage
func (*PlanTool) PromptGuidelines ¶
func (*PlanTool) PromptSnippet ¶
type QuestionAsker ¶
type QuestionAsker interface {
AskQuestion(ctx context.Context, question string, options []string, context string) string
}
QuestionAsker is the interface the tool uses to interact with the user. The agent implements this via RequestQuestion.
type QuestionTool ¶
type QuestionTool struct {
// contains filtered or unexported fields
}
QuestionTool asks the user a multiple-choice question during plan mode.
func NewQuestionTool ¶
func NewQuestionTool(r *Registry) *QuestionTool
NewQuestionTool creates a new question tool.
func (*QuestionTool) Description ¶
func (t *QuestionTool) Description() string
func (*QuestionTool) Execute ¶
func (t *QuestionTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
func (*QuestionTool) Name ¶
func (t *QuestionTool) Name() string
func (*QuestionTool) Parameters ¶
func (t *QuestionTool) Parameters() json.RawMessage
func (*QuestionTool) PromptGuidelines ¶
func (t *QuestionTool) PromptGuidelines() []string
func (*QuestionTool) PromptSnippet ¶
func (t *QuestionTool) PromptSnippet() string
type ReadTool ¶
type ReadTool struct {
// contains filtered or unexported fields
}
ReadTool reads file contents.
func (*ReadTool) Description ¶
func (*ReadTool) Parameters ¶
func (t *ReadTool) Parameters() json.RawMessage
func (*ReadTool) PromptGuidelines ¶
func (*ReadTool) PromptSnippet ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages available tools.
func NewRegistry ¶
NewRegistry creates a new tool registry.
func NewRegistryWithConfig ¶
func NewRegistryWithConfig(cfg RegistryConfig) *Registry
NewRegistryWithConfig creates a Registry with the given config.
func (*Registry) Definitions ¶
func (r *Registry) Definitions() []provider.ToolDefinition
Definitions returns tool definitions for all registered tools.
func (*Registry) FileLocks ¶
func (r *Registry) FileLocks() *FileLockManager
FileLocks returns the registry's in-memory file lock manager.
func (*Registry) GetSandbox ¶
GetSandbox returns the registry's sandbox.
func (*Registry) GetWorkDir ¶
GetWorkDir returns the registry's working directory.
func (*Registry) ImagePolicy ¶
ImagePolicy returns the image preprocessing policy for the current registry context.
func (*Registry) JobManager ¶
func (r *Registry) JobManager() *JobManager
JobManager returns the registry's per-instance job manager.
func (*Registry) ModeTools ¶
func (r *Registry) ModeTools(mode string) []provider.ToolDefinition
ModeTools returns tool definitions appropriate for the given mode.
func (*Registry) RegisterDefaults ¶
func (r *Registry) RegisterDefaults()
RegisterDefaults registers all default tools.
func (*Registry) RegisterDefaultsWithPlanTool ¶
RegisterDefaultsWithPlanTool registers all default tools, optionally including the plan tool.
func (*Registry) RegisterFiltered ¶
RegisterFiltered registers only the specified tools by name.
func (*Registry) ResolvePath ¶
ResolvePath resolves a user-provided path to an absolute path constrained to the work directory.
func (*Registry) SetImageHint ¶
SetImageHint updates provider/model context used by image-capable tools.
func (*Registry) SetSandbox ¶
SetSandbox updates the sandbox used by tools.
func (*Registry) ToolGuidelines ¶
ToolGuidelines returns prompt guidelines for the given tool names.
type RegistryConfig ¶
type RegistryConfig struct {
WorkDir string
Sandbox sandbox.Sandbox
ToolFilter []string // optional: only register these tools (empty = all)
SkillsMgr *skills.Manager // optional: skills manager for skill_ref tool
EnablePlanTool *bool // optional: defaults to true when nil
FileLocks *FileLockManager // optional: defaults to process-wide manager
ImageHint imageproc.Hint // optional: provider/model hint for image preprocessing
}
RegistryConfig configures a Registry instance.
type SkillRefTool ¶
type SkillRefTool struct {
// contains filtered or unexported fields
}
SkillRefTool loads on-demand reference files from skills.
func NewSkillRefTool ¶
func NewSkillRefTool(skillsMgr *skills.Manager) *SkillRefTool
NewSkillRefTool creates a new skill reference loading tool.
func (*SkillRefTool) Description ¶
func (t *SkillRefTool) Description() string
func (*SkillRefTool) Execute ¶
func (t *SkillRefTool) Execute(ctx context.Context, params map[string]any) (ToolResult, error)
func (*SkillRefTool) Name ¶
func (t *SkillRefTool) Name() string
func (*SkillRefTool) Parameters ¶
func (t *SkillRefTool) Parameters() json.RawMessage
func (*SkillRefTool) PromptGuidelines ¶
func (t *SkillRefTool) PromptGuidelines() []string
func (*SkillRefTool) PromptSnippet ¶
func (t *SkillRefTool) PromptSnippet() string
type Tool ¶
type Tool interface {
// Name returns the tool's name.
Name() string
// Description returns a description of what the tool does.
Description() string
// PromptSnippet returns a short one-line description for the system prompt's Available tools section.
PromptSnippet() string
// PromptGuidelines returns guideline bullets for the system prompt's Guidelines section.
PromptGuidelines() []string
// Parameters returns the JSON Schema for the tool's parameters.
Parameters() json.RawMessage
// Execute runs the tool with the given parameters.
Execute(ctx context.Context, params map[string]any) (ToolResult, error)
}
Tool is the interface that all tools must implement.
type ToolResult ¶
type ToolResult struct {
Text string // Plain text result (always populated for display/logging)
Contents []provider.ContentBlock // Rich content blocks (text + images) for the LLM
Diff *FileDiff // Optional structured file diff for UI/reporting
Plan *TaskPlan // Optional structured task plan for UI/reporting
}
ToolResult represents the result of a tool execution. It can contain plain text and optional rich content blocks (e.g. images).
func NewDiffToolResult ¶
func NewDiffToolResult(text string, diff *FileDiff) ToolResult
NewDiffToolResult creates a text tool result with structured diff metadata.
func NewImageToolResult ¶
func NewImageToolResult(text, mimeType, base64Data string) ToolResult
NewImageToolResult creates a tool result that includes an image. text is the human-readable description, mimeType and base64Data are the image payload.
func NewImageToolResultWithContent ¶
func NewImageToolResultWithContent(text string, image provider.ImageContent) ToolResult
NewImageToolResultWithContent creates a tool result with a fully populated image payload.
func NewPlanToolResult ¶
func NewPlanToolResult(text string, plan *TaskPlan) ToolResult
NewPlanToolResult creates a text tool result with structured plan metadata.
func NewTextToolResult ¶
func NewTextToolResult(text string) ToolResult
NewTextToolResult creates a plain text tool result.
type WriteTool ¶
type WriteTool struct {
// contains filtered or unexported fields
}
WriteTool writes content to files.
func NewWriteTool ¶
NewWriteTool creates a new write tool.
func (*WriteTool) Description ¶
func (*WriteTool) Parameters ¶
func (t *WriteTool) Parameters() json.RawMessage