Documentation
¶
Index ¶
- Constants
- func AddTruncationMeta(result map[string]any, info TruncationInfo) map[string]any
- func BuildMap(tools []Tool) (map[string]Tool, error)
- func Declarations(tools []Tool) []model.ToolDefinition
- func TruncateString(s string, policy TruncationPolicy) (string, int)
- func TruncateText(s string, policy TruncationPolicy) (string, int)
- type CoreToolsConfig
- type Handler
- type Tool
- type TruncationInfo
- type TruncationPolicy
Constants ¶
const (
// ReadToolName is the mandatory built-in read tool name.
ReadToolName = "READ"
)
Variables ¶
This section is empty.
Functions ¶
func AddTruncationMeta ¶
func AddTruncationMeta(result map[string]any, info TruncationInfo) map[string]any
AddTruncationMeta attaches truncation metadata to a tool result map.
func Declarations ¶
func Declarations(tools []Tool) []model.ToolDefinition
Declarations returns model-visible declarations for tools.
func TruncateString ¶
func TruncateString(s string, policy TruncationPolicy) (string, int)
TruncateString truncates a string in the middle to fit the policy budget.
func TruncateText ¶
func TruncateText(s string, policy TruncationPolicy) (string, int)
TruncateText truncates text and includes total line count when truncated.
Types ¶
type CoreToolsConfig ¶
type CoreToolsConfig struct {
Read filesystem.ReadConfig
Runtime toolexec.Runtime
}
CoreToolsConfig configures mandatory kernel tools.
type Tool ¶
type Tool interface {
Name() string
Description() string
Declaration() model.ToolDefinition
Run(context.Context, map[string]any) (map[string]any, error)
}
Tool is the executable tool contract.
func EnsureCoreTools ¶
func EnsureCoreTools(userTools []Tool, cfg CoreToolsConfig) ([]Tool, error)
EnsureCoreTools injects mandatory kernel tools and returns a new tool list.
type TruncationInfo ¶
type TruncationInfo struct {
Truncated bool
Policy string
MaxTokens int
MaxBytes int
EstimatedTokens int
EstimatedBytes int
RemovedTokens int
RemovedBytes int
OmittedItems int
}
TruncationInfo describes truncation that was applied.
func TruncateMap ¶
func TruncateMap(input map[string]any, policy TruncationPolicy) (map[string]any, TruncationInfo)
TruncateMap applies truncation to a tool result map and returns the updated map plus truncation info.
type TruncationPolicy ¶
TruncationPolicy defines limits for truncating tool output.
func DefaultTruncationPolicy ¶
func DefaultTruncationPolicy() TruncationPolicy
DefaultTruncationPolicy returns default tool output truncation policy.