tools

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package tools provides the tool implementations for Sol.

Package tools provides the tool implementations for Sol.

Index

Constants

View Source
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

func ApplyPatch() tool.Tool

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

func Bash(workDir string) tool.Tool

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

func BlockAnchorReplacer(content, find string) []string

BlockAnchorReplacer matches blocks by first and last line anchors with fuzzy middle

func CreateAllTools

func CreateAllTools(workDir string) tool.Set

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

func CreateToolSetForModel(modelID string) tool.Set

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 Edit

func Edit() tool.Tool

Edit creates the edit tool

func ExitTool

func ExitTool(state *ExitState) tool.Tool

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 Glob

func Glob() tool.Tool

Glob creates the glob tool

func Grep

func Grep() tool.Tool

Grep creates the grep tool

func IndentationFlexibleReplacer

func IndentationFlexibleReplacer(content, find string) []string

IndentationFlexibleReplacer matches with flexible indentation

func LineTrimmedReplacer

func LineTrimmedReplacer(content, find string) []string

LineTrimmedReplacer matches lines with trimmed whitespace

func MergeToolSets

func MergeToolSets(sets ...tool.Set) tool.Set

MergeToolSets merges multiple tool sets into one. Later sets override earlier ones if there are name conflicts.

func MultiOccurrenceReplacer

func MultiOccurrenceReplacer(content, find string) []string

MultiOccurrenceReplacer yields all exact matches

func Question

func Question() tool.Tool

Question creates the question tool

func Read

func Read() tool.Tool

Read creates the read tool

func SimpleReplacer

func SimpleReplacer(content, find string) []string

SimpleReplacer returns exact matches

func Skill

func Skill() tool.Tool

Skill creates the skill tool

func Task

func Task() tool.Tool

Task creates the task tool

func TodoRead

func TodoRead() tool.Tool

TodoRead creates the todoread tool

func TodoWrite

func TodoWrite() tool.Tool

TodoWrite creates the todowrite tool

func TrimmedBoundaryReplacer

func TrimmedBoundaryReplacer(content, find string) []string

TrimmedBoundaryReplacer matches with trimmed boundaries

func WebSearch

func WebSearch(llmProvider, llmAPIKey string) (tool.Tool, bool)

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 Webfetch

func Webfetch() tool.Tool

Webfetch creates the webfetch tool using a direct HTTP client.

func WhitespaceNormalizedReplacer

func WhitespaceNormalizedReplacer(content, find string) []string

WhitespaceNormalizedReplacer matches with normalized whitespace

func Write

func Write() tool.Tool

Write creates the write tool

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.

func (*ExitState) Called

func (s *ExitState) Called() bool

Called reports whether the exit tool has been invoked at least once.

func (*ExitState) Result

func (s *ExitState) Result() (status, message string)

Result returns the last (status, message) the agent passed to exit. Zero values when Called() is false.

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 Replacer

type Replacer func(content, find string) []string

Replacer is a function that yields possible matches for the find string in content

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

func (*TodoStorage) Get

func (s *TodoStorage) Get(sessionID string) ([]TodoItem, error)

Get retrieves todos for a session

func (*TodoStorage) Update

func (s *TodoStorage) Update(sessionID string, todos []TodoItem) error

Update stores todos for a session

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

type UpdateChunk struct {
	Context  string
	OldLines []string
	NewLines []string
	IsEOF    bool
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL