Documentation
¶
Overview ¶
Package tool provides the built-in agent tools: read, write, edit, and bash.
Index ¶
- func BuiltinToolsForPreset(workDir, preset string, bashFilter BashOutputFilterConfig) []agent.Tool
- func TruncateHead(s string, maxLines int, maxBytes int) string
- func TruncateTail(s string, maxLines int, maxBytes int) string
- type BashOutputFilterConfig
- type BashParams
- type BashTool
- type EditEntry
- type EditParams
- type EditTool
- type FindParams
- type FindTool
- type GrepParams
- type GrepTool
- type LsParams
- type LsTool
- type PatchParams
- type PatchTool
- type ReadParams
- type ReadTool
- type Task
- type TaskParams
- type TaskStatus
- type TaskStore
- type TaskTool
- type WriteParams
- type WriteTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltinToolsForPreset ¶
func BuiltinToolsForPreset(workDir, preset string, bashFilter BashOutputFilterConfig) []agent.Tool
BuiltinToolsForPreset returns the built-in tool set used by the native agent harness for a prompt preset.
func TruncateHead ¶
TruncateHead keeps the first maxLines lines or maxBytes bytes, whichever hits first. If the content was cut, a truncation marker is appended.
Types ¶
type BashOutputFilterConfig ¶
type BashParams ¶
type BashParams struct {
Command string `json:"command"`
TimeoutMs int `json:"timeout_ms,omitempty"`
}
BashParams are the parameters for the bash tool.
type BashTool ¶
type BashTool struct {
WorkDir string
OutputFilter BashOutputFilterConfig
}
BashTool executes shell commands.
func (*BashTool) Description ¶
func (*BashTool) Schema ¶
func (t *BashTool) Schema() json.RawMessage
type EditParams ¶
type EditParams struct {
Path string `json:"path"`
// Multi-edit form
Edits []EditEntry `json:"edits,omitempty"`
// Single-edit form (backward compat)
OldString string `json:"old_string,omitempty"`
NewString string `json:"new_string,omitempty"`
}
EditParams are the parameters for the edit tool. Supports two forms:
- Multi-edit (pi-style): path + edits[] array
- Single-edit (legacy): path + old_string + new_string
type EditTool ¶
type EditTool struct {
WorkDir string
}
EditTool performs find-replace edits on files.
func (*EditTool) Description ¶
func (*EditTool) Schema ¶
func (t *EditTool) Schema() json.RawMessage
type FindParams ¶
type FindParams struct {
Pattern string `json:"pattern"`
Dir string `json:"dir,omitempty"` // base dir; defaults to WorkDir
ExcludeDirs *[]string `json:"exclude_dirs,omitempty"` // override default skip dirs; nil uses defaults, empty slice means no skips
}
FindParams are the parameters for the find tool.
type FindTool ¶
type FindTool struct {
WorkDir string
ExcludeDirs []string // optional override for skipDirs; if empty, uses default skipDirs
}
FindTool finds files matching a path pattern.
func (*FindTool) Description ¶
func (*FindTool) Schema ¶
func (t *FindTool) Schema() json.RawMessage
type GrepParams ¶
type GrepParams struct {
Pattern string `json:"pattern"`
Dir string `json:"dir,omitempty"`
Glob string `json:"glob,omitempty"`
CaseInsensitive bool `json:"case_insensitive,omitempty"`
ExcludeDirs *[]string `json:"exclude_dirs,omitempty"` // override default skip dirs; nil uses defaults, empty slice means no skips
}
GrepParams are the parameters for the grep tool.
type GrepTool ¶
type GrepTool struct {
WorkDir string
ExcludeDirs []string // optional override for skipDirs; if empty, uses default skipDirs
}
GrepTool searches file contents for a regex pattern.
func (*GrepTool) Description ¶
func (*GrepTool) Schema ¶
func (t *GrepTool) Schema() json.RawMessage
type LsParams ¶
type LsParams struct {
Path string `json:"path,omitempty"` // defaults to WorkDir
}
LsParams are the parameters for the ls tool.
type LsTool ¶
type LsTool struct {
WorkDir string
}
LsTool lists directory contents.
func (*LsTool) Description ¶
func (*LsTool) Schema ¶
func (t *LsTool) Schema() json.RawMessage
type PatchParams ¶
type PatchParams struct {
Path string `json:"path"`
Search string `json:"search,omitempty"` // unique text to locate; must appear exactly once
Content string `json:"content"` // replacement text, or text to prepend/append
Operation string `json:"operation,omitempty"` // "replace" (default), "replace_all", "prepend", "append"
}
PatchParams are the parameters for the patch tool. The model provides search (context from the file) and content (the replacement). When search is omitted or empty, the operation is a full-file replace, prepend, or append depending on the operation field.
type PatchTool ¶
type PatchTool struct {
WorkDir string
}
PatchTool performs search-and-replace edits on files with robust line-ending handling and clear error messages. Inspired by ForgeCode's fs_patch design.
func (*PatchTool) Description ¶
func (*PatchTool) Schema ¶
func (t *PatchTool) Schema() json.RawMessage
type ReadParams ¶
type ReadParams struct {
Path string `json:"path"`
Offset int `json:"offset,omitempty"` // 0-based line offset
Limit int `json:"limit,omitempty"` // max lines to return
}
ReadParams are the parameters for the read tool.
type ReadTool ¶
type ReadTool struct {
WorkDir string
}
ReadTool reads file contents relative to a working directory.
func (*ReadTool) Description ¶
func (*ReadTool) Schema ¶
func (t *ReadTool) Schema() json.RawMessage
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Status TaskStatus `json:"status"`
Order int `json:"order"` // for ordering tasks in a plan
}
Task represents a tracked subtask within an agent run.
type TaskParams ¶
type TaskParams struct {
Operation string `json:"operation"` // create, update, list, get
ID string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
}
TaskParams are the parameters for task tool operations.
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the status of a tracked task.
const ( TaskStatusPending TaskStatus = "pending" TaskStatusInProgress TaskStatus = "in_progress" TaskStatusCompleted TaskStatus = "completed" )
type TaskStore ¶
type TaskStore struct {
// contains filtered or unexported fields
}
TaskStore persists task state within a single agent run.
type TaskTool ¶
type TaskTool struct {
Store *TaskStore
}
TaskTool provides task tracking capabilities for multi-step planning.
func (*TaskTool) Description ¶
func (*TaskTool) Schema ¶
func (t *TaskTool) Schema() json.RawMessage
type WriteParams ¶
WriteParams are the parameters for the write tool.