Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBinary ¶
IsBinary reports whether data appears to be binary (non-text) content. It samples up to the first 8KB and checks for a high ratio of non-UTF-8 bytes or null bytes, which are reliable indicators of binary data.
func ResolvePath ¶ added in v0.10.0
ResolvePath resolves path relative to workDir when it is not already absolute.
func SplitLines ¶
SplitLines splits text into lines preserving newline suffixes. Trims the trailing empty element that strings.SplitAfter produces.
Types ¶
type Definition ¶
type Definition = ai.ToolDefinition
Definition is a callable tool definition exposed to a model.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds named tools and provides lookup + definitions.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates an empty tool registry. Tools are registered externally via Register().
func (*Registry) BuiltinNames ¶
BuiltinNames returns the names of all currently registered tools.
func (*Registry) Definitions ¶
func (r *Registry) Definitions() []Definition
Definitions returns all tool definitions for passing to the LLM.
type Tool ¶
type Tool interface {
Definition() Definition
Execute(ctx context.Context, args map[string]any) (string, error)
}
Tool is a tool that can be executed by the Go runner.
type TruncatedBy ¶ added in v0.10.0
type TruncatedBy string
const ( TruncatedByNone TruncatedBy = "" TruncatedByLines TruncatedBy = "lines" TruncatedByBytes TruncatedBy = "bytes" )
type TruncationResult ¶
type TruncationResult struct {
Content string
Truncated bool
TruncatedBy TruncatedBy
TotalLines int
TotalBytes int
OutputLines int
OutputBytes int
LastLinePartial bool
FirstLineExceedsLimit bool
MaxLines int
MaxBytes int
}
TruncationResult holds truncated output plus metadata about what happened. Content remains the user-facing string, including truncation headers/footers.
func TruncateHead ¶
func TruncateHead(output string) TruncationResult
TruncateHead keeps the first N lines / bytes (whichever limit is hit first). Suitable for file reads and search results where the beginning matters most. Never returns a partial line.
func TruncateTail ¶
func TruncateTail(output string) TruncationResult
TruncateTail keeps the last N lines / bytes (whichever limit is hit first). Suitable for command output and logs where the end matters most. When the last line alone exceeds the byte limit, it keeps a UTF-8-safe tail slice.