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 SetSkillScanDirs(dirs []string)
- 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 WithProcessEnvironment(ctx context.Context, env []string) context.Context
- func Write() tool.Tool
- type ApplyPatchInput
- type BashInput
- type CommandControl
- 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 SetSkillScanDirs ¶ added in v0.1.8
func SetSkillScanDirs(dirs []string)
SetSkillScanDirs points the shared skill registry at ADDITIONAL skill roots (in addition to the defaults). The toolserver calls this from its --skills-dir flag / SKILLS_DIRS env so the platform can ship skills outside the agent workspace. Empty input is a no-op.
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
func WithProcessEnvironment ¶ added in v0.1.16
WithProcessEnvironment supplies an explicit environment for launched programs. In-process child agents inherit this context along with the execution policy.
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 CommandControl ¶ added in v0.1.19
CommandControl is host-only bash transport configuration, not part of the model's BashInput schema. Signals are opaque IDs verified by the host before the command context is cancelled. No stdout content is interpreted as control.
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.
func (*ExitState) Result ¶
Result returns the last (status, message) the agent passed to exit. Zero values when Called() is false.
func (*ExitState) Set ¶ added in v0.1.7
Set records an exit outcome. ExitTool calls it internally; it is also exported so a caller that supplies its own exit-tool variant — e.g. one with an extended status vocabulary — can still drive the runner's "must call exit" termination through a standard ExitState.
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:"Text files only: the line number to start reading from (0-based); omit for images"`
Limit int `json:"limit,omitempty" description:"Text files only: the number of lines to read (defaults to 2000); omit for images"`
}
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 ADDITIONAL directories to scan for skills, on top of the built-in defaults (cwd/.claude, ~/.claude, …). Each entry is a skill root scanned for <dir>/skills/**/SKILL.md and <dir>/skill/**/SKILL.md. Passing nil clears the extras and falls back to defaults only.
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" enum:"general,explore"`
}
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