Documentation
¶
Overview ¶
Package tools provides the tool implementations for Sol.
Package tools provides the tool implementations for Sol.
Index ¶
- Constants
- func ApplyPatch() tool.Tool
- func AskPermission(ctx context.Context, req PermissionRequest) error
- func Bash(workDir string) tool.Tool
- func BlockAnchorReplacer(content, find string) []string
- func CreateAllTools(workDir string) tool.Set
- func CreateToolSetForModel(modelID string) tool.Set
- func Edit() tool.Tool
- func ExitTool(state *ExitState) tool.Tool
- func Glob() tool.Tool
- func Grep() tool.Tool
- func IndentationFlexibleReplacer(content, find string) []string
- func LineTrimmedReplacer(content, find string) []string
- func MergeToolSets(sets ...tool.Set) tool.Set
- func MultiOccurrenceReplacer(content, find string) []string
- func Question() tool.Tool
- func Read() tool.Tool
- func SimpleReplacer(content, find string) []string
- func Skill() tool.Tool
- func Task() tool.Tool
- func TodoRead() tool.Tool
- func TodoWrite() tool.Tool
- func TrimmedBoundaryReplacer(content, find string) []string
- func WebSearch(llmProvider, llmAPIKey string) (tool.Tool, bool)
- func Webfetch() tool.Tool
- func WhitespaceNormalizedReplacer(content, find string) []string
- func Write() tool.Tool
- type ApplyPatchInput
- type BashInput
- type EditInput
- type ExitState
- type GlobInput
- type GrepInput
- type Hunk
- type PermissionDeniedError
- type PermissionRequest
- type QuestionInput
- type QuestionItem
- type QuestionOption
- type ReadInput
- type Replacer
- type SkillInfo
- type SkillInput
- type SkillRegistry
- type SubagentResult
- type SubagentSpawner
- type TaskInput
- type TodoItem
- type TodoReadInput
- type TodoStorage
- type TodoWriteInput
- type UpdateChunk
- type WriteInput
Constants ¶
const ( RunnerKey = tool.RunnerKey SessionIDKey = tool.SessionIDKey WorkDirKey = tool.WorkDirKey )
Re-export context keys from goai/tool for backward compatibility. Tools should use these keys for context.Value() lookups.
Variables ¶
This section is empty.
Functions ¶
func ApplyPatch ¶
ApplyPatch returns the apply_patch tool definition. This tool is used by gpt-5 models (codex-style patching).
func AskPermission ¶
func AskPermission(ctx context.Context, req PermissionRequest) error
AskPermission requests permission through the context-scoped permission manager. The runner must have injected a PermissionManager into the context.
func Bash ¶
Bash creates the bash tool. workDir is the default working directory shown in the tool description (e.g. "/home/agent/space" or os.Getwd()).
func BlockAnchorReplacer ¶
BlockAnchorReplacer matches blocks by first and last line anchors with fuzzy middle
func CreateAllTools ¶
CreateAllTools returns a tool.Set containing every tool implementation. workDir is used in the bash tool description to tell the LLM the default working directory. Pass "" to use os.Getwd().
func CreateToolSetForModel ¶
CreateToolSetForModel creates tools matching OpenCode's model-based tool selection. For gpt-5+ models (except gpt-4*), uses apply_patch instead of edit/write. CreateToolSetForModel creates tools matching OpenCode's model-based tool selection. For gpt-5+ models (except gpt-4*), uses apply_patch instead of edit/write.
func ExitTool ¶
ExitTool returns the tool the agent must call to end the run. The tool stores the agent-provided status/message into state and returns a benign success result so the model isn't surprised mid-stream; the runner loop observes ExitState after the step completes and terminates with RunStatus = RunExited.
Description doubles as the spec the model reads — it explicitly says "you must call this tool exactly once as your final action."
func IndentationFlexibleReplacer ¶
IndentationFlexibleReplacer matches with flexible indentation
func LineTrimmedReplacer ¶
LineTrimmedReplacer matches lines with trimmed whitespace
func MergeToolSets ¶
MergeToolSets merges multiple tool sets into one. Later sets override earlier ones if there are name conflicts.
func MultiOccurrenceReplacer ¶
MultiOccurrenceReplacer yields all exact matches
func SimpleReplacer ¶
SimpleReplacer returns exact matches
func TrimmedBoundaryReplacer ¶
TrimmedBoundaryReplacer matches with trimmed boundaries
func WebSearch ¶
WebSearch returns a web search tool if a provider can be resolved. It first checks if the given LLM provider has a native search backend declared in the provider overlay (reusing the same API key), then falls back to dedicated search env vars for brave/perplexity (CLI use). Returns (tool, false) if no search provider is available.
Airlock's runtime resolves search differently — it queries the providers table for any enabled search-capable row. This helper exists for the standalone Sol CLI and the build-time sol runner where there's no DB.
func WhitespaceNormalizedReplacer ¶
WhitespaceNormalizedReplacer matches with normalized whitespace
Types ¶
type ApplyPatchInput ¶
type ApplyPatchInput struct {
PatchText string `json:"patchText" description:"The full patch text that describes all changes to be made"`
}
ApplyPatchInput is the input schema for the apply_patch tool
type BashInput ¶
type BashInput struct {
Command string `json:"command" description:"The command to execute"`
Timeout int `json:"timeout,omitempty" description:"Optional timeout in milliseconds"`
Workdir string `json:"workdir,omitempty"`
Description string `` /* 333-byte string literal not displayed */
}
BashInput is the input schema for the bash tool
type EditInput ¶
type EditInput struct {
FilePath string `json:"filePath" description:"The absolute path to the file to modify"`
OldString string `json:"oldString" description:"The text to replace"`
NewString string `json:"newString" description:"The text to replace it with (must be different from oldString)"`
ReplaceAll bool `json:"replaceAll,omitempty" description:"Replace all occurrences of oldString (default false)"`
}
EditInput is the input schema for the edit tool
type ExitState ¶
type ExitState struct {
// contains filtered or unexported fields
}
ExitState captures the outcome reported by the agent via the exit tool. Pass a pointer into RunnerOptions.ExitState to opt the runner into "must call exit" termination semantics; the runner breaks the step loop as soon as the tool stores a result.
Designed for autonomous, non-interactive runs (CI, builds, sol-CLI piping) where a structured outcome is more useful than parsing the model's text.
type GlobInput ¶
type GlobInput struct {
Pattern string `json:"pattern" description:"The glob pattern to match files against"`
Path string `` /* 308-byte string literal not displayed */
}
GlobInput is the input schema for the glob tool
type GrepInput ¶
type GrepInput struct {
Pattern string `json:"pattern" description:"The regex pattern to search for in file contents"`
Path string `json:"path,omitempty" description:"The directory to search in. Defaults to the current working directory."`
Include string `json:"include,omitempty" description:"File pattern to include in the search (e.g. \"*.js\", \"*.{ts,tsx}\")"`
}
GrepInput is the input schema for the grep tool
type Hunk ¶
type Hunk struct {
Type string // "add", "delete", "update"
Path string
MovePath string // for renames
Contents string // for add
Chunks []UpdateChunk // for update
}
Hunk represents a single file operation in a patch
type PermissionDeniedError ¶
type PermissionDeniedError = bus.PermissionDeniedError
Re-export error types from bus
type PermissionRequest ¶
type PermissionRequest struct {
ID string
SessionID string
Permission string
Patterns []string
Always []string
Metadata map[string]any
ToolCallID string
}
PermissionRequest is a local type that maps to bus.PermissionRequest.
type QuestionInput ¶
type QuestionInput struct {
Questions []QuestionItem `json:"questions" description:"Questions to ask"`
}
QuestionInput is the input schema for the question tool
type QuestionItem ¶
type QuestionItem struct {
Question string `json:"question" description:"Complete question"`
Header string `json:"header" description:"Very short label (max 30 chars)"`
Options []QuestionOption `json:"options" description:"Available choices" itemRef:"QuestionOption"`
Multiple bool `json:"multiple,omitempty" description:"Allow selecting multiple choices"`
}
QuestionItem represents a single question with options
type QuestionOption ¶
type QuestionOption struct {
Label string `json:"label" description:"Display text (1-5 words, concise)"`
Description string `json:"description" description:"Explanation of choice"`
}
QuestionOption represents a single choice option
type ReadInput ¶
type ReadInput struct {
FilePath string `json:"filePath" description:"The path to the file to read"`
Offset int `json:"offset,omitempty" description:"The line number to start reading from (0-based)"`
Limit int `json:"limit,omitempty" description:"The number of lines to read (defaults to 2000)"`
}
ReadInput is the input schema for the read tool
type SkillInfo ¶
type SkillInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Location string `json:"location"`
}
SkillInfo represents a discovered skill
type SkillInput ¶
type SkillInput struct {
Name string `json:"name"`
}
SkillInput is the input schema for the skill tool
type SkillRegistry ¶
type SkillRegistry struct {
// contains filtered or unexported fields
}
SkillRegistry manages skill discovery
func (*SkillRegistry) All ¶
func (r *SkillRegistry) All() []SkillInfo
All returns all discovered skills
func (*SkillRegistry) Get ¶
func (r *SkillRegistry) Get(name string) (SkillInfo, bool)
Get returns a skill by name
func (*SkillRegistry) LoadContent ¶
func (r *SkillRegistry) LoadContent(skill SkillInfo) (string, error)
LoadContent loads the full content of a skill file
func (*SkillRegistry) Scan ¶
func (r *SkillRegistry) Scan() error
Scan discovers all available skills
func (*SkillRegistry) SetScanDirs ¶
func (r *SkillRegistry) SetScanDirs(dirs []string)
SetScanDirs sets the directories to scan for skills
type SubagentResult ¶
type SubagentResult interface {
GetTotalText() string
}
SubagentResult is the interface for subagent execution results.
type SubagentSpawner ¶
type SubagentSpawner interface {
SpawnSubagent(ctx context.Context, agentType, prompt string) (SubagentResult, error)
AgentName() string
}
SubagentSpawner is the interface for spawning subagents. This is implemented by the Runner in the main package.
type TaskInput ¶
type TaskInput struct {
Description string `json:"description" description:"A short (3-5 words) description of the task"`
Prompt string `json:"prompt" description:"The task for the agent to perform"`
SubagentType string `json:"subagent_type" description:"The type of specialized agent to use for this task"`
SessionID string `json:"session_id,omitempty" description:"Existing Task session to continue"`
Command string `json:"command,omitempty" description:"The command that triggered this task"`
}
TaskInput is the input schema for the task tool
type TodoItem ¶
type TodoItem struct {
Content string `json:"content" description:"Brief description of the task"`
Status string `json:"status" description:"Current status of the task: pending, in_progress, completed, cancelled"`
Priority string `json:"priority" description:"Priority level of the task: high, medium, low"`
ID string `json:"id" description:"Unique identifier for the todo item"`
}
TodoItem represents a single todo item
type TodoReadInput ¶
type TodoReadInput struct{}
TodoReadInput is the input schema for the todoread tool
type TodoStorage ¶
type TodoStorage struct {
// contains filtered or unexported fields
}
TodoStorage manages todo persistence
type TodoWriteInput ¶
type TodoWriteInput struct {
Todos []TodoItem `json:"todos" description:"The updated todo list"`
}
TodoWriteInput is the input schema for the todowrite tool
type UpdateChunk ¶
UpdateChunk represents a change within an update operation
type WriteInput ¶
type WriteInput struct {
Content string `json:"content" description:"The content to write to the file"`
FilePath string `json:"filePath" description:"The absolute path to the file to write (must be absolute, not relative)"`
}
WriteInput is the input schema for the write tool