tools

package
v0.3.28-beta Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package tools provides the core tool execution framework for Kodelet. It defines the available tools, manages tool registration, and handles tool execution with proper validation, tracing, and error handling.

Index

Constants

View Source
const (
	// MaxOutputBytes is the maximum number of bytes to output from a file read operation
	MaxOutputBytes = 100_000 // 100KB
	// MaxLineCharacterLimit is the maximum characters per line before truncation
	MaxLineCharacterLimit = 2000
	// MaxLineLimit is the maximum number of lines that can be read at once
	MaxLineLimit = 2000
)
View Source
const NoToolsMarker = "none"

NoToolsMarker is a special value indicating no tools should be enabled

Variables

View Source
var (

	// BannedCommands lists commands that are not allowed to run through the bash tool
	BannedCommands = []string{
		"vim",
		"view",
		"less",
		"more",
		"cd",
	}
)
View Source
var ErrMCPDisabled = errors.New("MCP is disabled via configuration")

ErrMCPDisabled is returned when MCP is disabled via configuration

Functions

func BuildSubagentArgs

func BuildSubagentArgs(ctx context.Context, subagentArgs string, input *SubAgentInput, workflow *fragments.Fragment) []string

BuildSubagentArgs builds the command-line arguments for spawning a subagent process. This is extracted as a separate function for testability. Returns the complete argument list including the base args, subagent_args from config, and the question. The workflow parameter is optional and provides workflow metadata (profile).

func FormatEditedBlock

func FormatEditedBlock(originalContent, oldText, newText string) string

FormatEditedBlock formats the edited text block with line numbers, using the original content and old text to find the starting line number.

func FormatSearchResults

func FormatSearchResults(pattern string, results []SearchResult) string

FormatSearchResults formats the search results for output

func GenerateSchema

func GenerateSchema[T any]() *jsonschema.Schema

GenerateSchema generates a JSON schema for the given type

func GetMainTools

func GetMainTools(ctx context.Context, allowedTools []string, enableTodos bool) []tooltypes.Tool

GetMainTools returns the main tools available for the agent

func GetMainToolsWithOptions

func GetMainToolsWithOptions(ctx context.Context, allowedTools []string, enableTodos bool, disableFSSearchTools bool) []tooltypes.Tool

GetMainToolsWithOptions returns the main tools available for the agent with feature toggles applied.

func GetSubAgentTools

func GetSubAgentTools(ctx context.Context, allowedTools []string) []tooltypes.Tool

GetSubAgentTools returns the tools available for sub-agents

func GetSubAgentToolsWithOptions

func GetSubAgentToolsWithOptions(ctx context.Context, allowedTools []string, disableFSSearchTools bool) []tooltypes.Tool

GetSubAgentToolsWithOptions returns the sub-agent tools with feature toggles applied.

func GetToolsFromNames

func GetToolsFromNames(toolNames []string) []tooltypes.Tool

GetToolsFromNames returns a list of tools from the given tool names

func RunTool

func RunTool(ctx context.Context, state tooltypes.State, toolName string, parameters string) tooltypes.ToolResult

RunTool executes a tool by name with the given parameters

func ToOpenAITools

func ToOpenAITools(tools []tooltypes.Tool) []openai.Tool

ToOpenAITools converts internal tool format to OpenAI's format

func ValidateSubAgentTools

func ValidateSubAgentTools(toolNames []string) error

ValidateSubAgentTools validates that all sub-agent tool names are available

func ValidateTools

func ValidateTools(toolNames []string) error

ValidateTools validates that all tool names are available

Types

type ApplyPatchInput

type ApplyPatchInput tooltypes.ApplyPatchInput

ApplyPatchInput reuses the shared apply_patch tool input schema while preserving pkg/tools schema IDs.

type ApplyPatchTool

type ApplyPatchTool struct{}

ApplyPatchTool applies codex-style file patch instructions.

func (*ApplyPatchTool) Description

func (t *ApplyPatchTool) Description() string

Description returns the tool description.

func (*ApplyPatchTool) Execute

func (t *ApplyPatchTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute applies the patch to disk.

func (*ApplyPatchTool) GenerateSchema

func (t *ApplyPatchTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool input.

func (*ApplyPatchTool) Name

func (t *ApplyPatchTool) Name() string

Name returns the name of the tool.

func (*ApplyPatchTool) TracingKVs

func (t *ApplyPatchTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing attributes.

func (*ApplyPatchTool) ValidateInput

func (t *ApplyPatchTool) ValidateInput(state tooltypes.State, parameters string) error

ValidateInput validates the patch format and referenced files.

type BashInput

type BashInput tooltypes.BashInput

BashInput reuses the shared bash tool input schema while preserving pkg/tools schema IDs.

type BashTool

type BashTool struct {
	// contains filtered or unexported fields
}

BashTool executes bash commands with configurable restrictions and timeout support

func NewBashTool

func NewBashTool(allowedCommands []string, disableFSSearchTools bool) *BashTool

NewBashTool creates a new BashTool with the specified allowed commands

func (*BashTool) Description

func (b *BashTool) Description() string

Description returns the description of the tool

func (*BashTool) Execute

func (b *BashTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute runs the bash command and returns the result

func (*BashTool) GenerateSchema

func (b *BashTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*BashTool) MatchesCommand

func (b *BashTool) MatchesCommand(command string) bool

MatchesCommand checks if a command matches any of the compiled glob patterns

func (*BashTool) Name

func (b *BashTool) Name() string

Name returns the name of the tool

func (*BashTool) TracingKVs

func (b *BashTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*BashTool) ValidateInput

func (b *BashTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type BashToolResult

type BashToolResult struct {
	// contains filtered or unexported fields
}

BashToolResult represents the result of a bash command execution

func (*BashToolResult) AssistantFacing

func (r *BashToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*BashToolResult) GetError

func (r *BashToolResult) GetError() string

GetError returns the error message

func (*BashToolResult) GetResult

func (r *BashToolResult) GetResult() string

GetResult returns the command output

func (*BashToolResult) IsError

func (r *BashToolResult) IsError() bool

IsError returns true if the result contains an error

func (*BashToolResult) StructuredData

func (r *BashToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the tool execution

type BasicState

type BasicState struct {
	// contains filtered or unexported fields
}

BasicState implements the State interface with basic functionality

func NewBasicState

func NewBasicState(ctx context.Context, opts ...BasicStateOption) *BasicState

NewBasicState creates a new BasicState with the given options

func (*BasicState) BasicTools

func (s *BasicState) BasicTools() []tooltypes.Tool

BasicTools returns the list of basic tools

func (*BasicState) ClearFileLastAccessed

func (s *BasicState) ClearFileLastAccessed(path string) error

ClearFileLastAccessed clears the last access time for a file

func (*BasicState) DiscoverContexts

func (s *BasicState) DiscoverContexts() map[string]string

DiscoverContexts discovers and returns context information for the current state

func (*BasicState) FileLastAccess

func (s *BasicState) FileLastAccess() map[string]time.Time

FileLastAccess returns a map of file paths to their last access times

func (*BasicState) GetFileLastAccessed

func (s *BasicState) GetFileLastAccessed(path string) (time.Time, error)

GetFileLastAccessed gets the last access time for a file

func (*BasicState) GetLLMConfig

func (s *BasicState) GetLLMConfig() any

GetLLMConfig returns the LLM configuration

func (*BasicState) LockFile

func (s *BasicState) LockFile(path string)

LockFile acquires an exclusive lock for the given file path. This ensures atomic read-modify-write operations when editing files.

func (*BasicState) MCPTools

func (s *BasicState) MCPTools() []tooltypes.Tool

MCPTools returns the list of MCP tools

func (*BasicState) SetFileLastAccess

func (s *BasicState) SetFileLastAccess(fileLastAccess map[string]time.Time)

SetFileLastAccess sets the file last access map

func (*BasicState) SetFileLastAccessed

func (s *BasicState) SetFileLastAccessed(path string, lastAccessed time.Time) error

SetFileLastAccessed sets the last access time for a file

func (*BasicState) SetTodoFilePath

func (s *BasicState) SetTodoFilePath(path string)

SetTodoFilePath sets the path to the todo file

func (*BasicState) TodoFilePath

func (s *BasicState) TodoFilePath() (string, error)

TodoFilePath returns the path to the todo file

func (*BasicState) Tools

func (s *BasicState) Tools() []tooltypes.Tool

Tools returns all available tools

func (*BasicState) UnlockFile

func (s *BasicState) UnlockFile(path string)

UnlockFile releases the lock for the given file path.

func (*BasicState) WorkingDirectory

func (s *BasicState) WorkingDirectory() string

WorkingDirectory returns the state working directory.

type BasicStateOption

type BasicStateOption func(ctx context.Context, s *BasicState) error

BasicStateOption is a function that configures a BasicState

func WithCustomTools

func WithCustomTools(customManager *CustomToolManager) BasicStateOption

WithCustomTools returns an option that configures custom tools

func WithExtraMCPTools

func WithExtraMCPTools(tools []tooltypes.Tool) BasicStateOption

WithExtraMCPTools returns an option that adds extra MCP tools

func WithLLMConfig

func WithLLMConfig(config llmtypes.Config) BasicStateOption

WithLLMConfig returns an option that sets the LLM configuration

func WithMCPTools

func WithMCPTools(mcpManager *MCPManager) BasicStateOption

WithMCPTools returns an option that configures MCP tools

func WithMainTools

func WithMainTools() BasicStateOption

WithMainTools returns an option that configures main tools

func WithSessionID

func WithSessionID(sessionID string) BasicStateOption

WithSessionID returns an option that binds the state to a specific conversation session.

func WithSkillTool

func WithSkillTool() BasicStateOption

WithSkillTool returns an option that configures the skill tool with discovered skills

func WithSubAgentTool

func WithSubAgentTool() BasicStateOption

WithSubAgentTool returns an option that configures the subagent tool with discovered workflows

func WithSubAgentToolsFromConfig

func WithSubAgentToolsFromConfig() BasicStateOption

WithSubAgentToolsFromConfig returns an option that configures sub-agent tools using the state's llmConfig This is used when running kodelet with --as-subagent flag

func WithWorkingDirectory

func WithWorkingDirectory(workingDir string) BasicStateOption

WithWorkingDirectory returns an option that sets the explicit working directory.

type CodeExecutionInput

type CodeExecutionInput struct {
	CodePath    string `` /* 137-byte string literal not displayed */
	Description string `json:"description,omitempty" jsonschema:"description=Brief description of what this code does"`
}

CodeExecutionInput represents the input parameters for code execution

type CodeExecutionResult

type CodeExecutionResult struct {
	// contains filtered or unexported fields
}

CodeExecutionResult holds the result of code execution

func (*CodeExecutionResult) AssistantFacing

func (r *CodeExecutionResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*CodeExecutionResult) GetError

func (r *CodeExecutionResult) GetError() string

GetError returns the error message

func (*CodeExecutionResult) GetResult

func (r *CodeExecutionResult) GetResult() string

GetResult returns the tool output

func (*CodeExecutionResult) IsError

func (r *CodeExecutionResult) IsError() bool

IsError returns true if the result contains an error

func (*CodeExecutionResult) StructuredData

StructuredData returns structured metadata about the execution

type CodeExecutionTool

type CodeExecutionTool struct {
	// contains filtered or unexported fields
}

CodeExecutionTool enables TypeScript code execution with MCP tool access

func NewCodeExecutionTool

func NewCodeExecutionTool(runtime *runtime.NodeRuntime) *CodeExecutionTool

NewCodeExecutionTool creates a new code execution tool

func NewCodeExecutionToolWithOptions

func NewCodeExecutionToolWithOptions(runtime *runtime.NodeRuntime, toolMode llmtypes.ToolMode, disableFSSearchTools bool) *CodeExecutionTool

NewCodeExecutionToolWithOptions creates a code execution tool with description rendering options.

func (*CodeExecutionTool) Description

func (t *CodeExecutionTool) Description() string

Description returns the description of the tool for the LLM

func (*CodeExecutionTool) Execute

func (t *CodeExecutionTool) Execute(ctx context.Context, _ tooltypes.State, parameters string) tooltypes.ToolResult

Execute runs the code execution tool

func (*CodeExecutionTool) GenerateSchema

func (t *CodeExecutionTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*CodeExecutionTool) Name

func (t *CodeExecutionTool) Name() string

Name returns the name of the tool

func (*CodeExecutionTool) TracingKVs

func (t *CodeExecutionTool) TracingKVs(_ string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs

func (*CodeExecutionTool) ValidateInput

func (t *CodeExecutionTool) ValidateInput(_ tooltypes.State, _ string) error

ValidateInput validates the input parameters

type CodeSearchInput

type CodeSearchInput tooltypes.CodeSearchInput

CodeSearchInput reuses the shared grep_tool input schema while preserving pkg/tools schema IDs.

type ContextDiscovery

type ContextDiscovery struct {
	// contains filtered or unexported fields
}

ContextDiscovery tracks context discovery results

type CustomTool

type CustomTool struct {
	// contains filtered or unexported fields
}

CustomTool represents a custom executable tool

func (*CustomTool) Description

func (t *CustomTool) Description() string

Description returns the description of the tool

func (*CustomTool) Execute

func (t *CustomTool) Execute(ctx context.Context, _ tooltypes.State, parameters string) tooltypes.ToolResult

Execute runs the custom tool and returns the result

func (*CustomTool) GenerateSchema

func (t *CustomTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*CustomTool) Name

func (t *CustomTool) Name() string

Name returns the name of the tool

func (*CustomTool) TracingKVs

func (t *CustomTool) TracingKVs(_ string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*CustomTool) ValidateInput

func (t *CustomTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type CustomToolConfig

type CustomToolConfig struct {
	Enabled       bool          `mapstructure:"enabled" json:"enabled" yaml:"enabled"`
	GlobalDir     string        `mapstructure:"global_dir" json:"global_dir" yaml:"global_dir"`
	LocalDir      string        `mapstructure:"local_dir" json:"local_dir" yaml:"local_dir"`
	Timeout       time.Duration `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
	MaxOutputSize int           `mapstructure:"max_output_size" json:"max_output_size" yaml:"max_output_size"`
	ToolWhiteList []string      `mapstructure:"tool_white_list" json:"tool_white_list" yaml:"tool_white_list"`
}

CustomToolConfig represents the configuration for custom tools

func LoadCustomToolConfig

func LoadCustomToolConfig() CustomToolConfig

LoadCustomToolConfig loads custom tool configuration from Viper This is exported so it can be used by other packages (e.g., for injecting into fragments)

type CustomToolDescription

type CustomToolDescription struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"input_schema"`
}

CustomToolDescription represents the JSON structure returned by tool's description command

type CustomToolManager

type CustomToolManager struct {
	// contains filtered or unexported fields
}

CustomToolManager manages discovery and registration of custom tools

func CreateCustomToolManagerFromViper

func CreateCustomToolManagerFromViper(ctx context.Context) (*CustomToolManager, error)

CreateCustomToolManagerFromViper creates a custom tool manager from Viper configuration

func NewCustomToolManager

func NewCustomToolManager() (*CustomToolManager, error)

NewCustomToolManager creates a new custom tool manager

func (*CustomToolManager) DiscoverTools

func (m *CustomToolManager) DiscoverTools(ctx context.Context) error

DiscoverTools scans directories and discovers available custom tools

func (*CustomToolManager) GetTool

func (m *CustomToolManager) GetTool(name string) (*CustomTool, bool)

GetTool returns a specific tool by name

func (*CustomToolManager) ListTools

func (m *CustomToolManager) ListTools() []tooltypes.Tool

ListTools returns all discovered custom tools

type CustomToolResult

type CustomToolResult struct {
	// contains filtered or unexported fields
}

CustomToolResult represents the result of a custom tool execution

func (*CustomToolResult) AssistantFacing

func (r *CustomToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*CustomToolResult) GetError

func (r *CustomToolResult) GetError() string

GetError returns the error message

func (*CustomToolResult) GetResult

func (r *CustomToolResult) GetResult() string

GetResult returns the tool output

func (*CustomToolResult) IsError

func (r *CustomToolResult) IsError() bool

IsError returns true if the result contains an error

func (*CustomToolResult) StructuredData

func (r *CustomToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the custom tool execution

type EditInfo

type EditInfo struct {
	StartLine  int
	EndLine    int
	OldContent string
	NewContent string
}

EditInfo contains information about a single edit operation

type FileEditInput

type FileEditInput tooltypes.FileEditInput

FileEditInput reuses the shared file_edit tool input schema while preserving pkg/tools schema IDs.

type FileEditTool

type FileEditTool struct{}

FileEditTool provides functionality to edit files by replacing text

func (*FileEditTool) Description

func (t *FileEditTool) Description() string

Description returns the description of the tool

func (*FileEditTool) Execute

func (t *FileEditTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute performs the file edit operation

func (*FileEditTool) GenerateSchema

func (t *FileEditTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*FileEditTool) Name

func (t *FileEditTool) Name() string

Name returns the name of the tool

func (*FileEditTool) TracingKVs

func (t *FileEditTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*FileEditTool) ValidateInput

func (t *FileEditTool) ValidateInput(state tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type FileEditToolResult

type FileEditToolResult struct {
	// contains filtered or unexported fields
}

FileEditToolResult represents the result of a file edit operation

func (*FileEditToolResult) AssistantFacing

func (r *FileEditToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*FileEditToolResult) GetError

func (r *FileEditToolResult) GetError() string

GetError returns the error message

func (*FileEditToolResult) GetResult

func (r *FileEditToolResult) GetResult() string

GetResult returns a success message

func (*FileEditToolResult) IsError

func (r *FileEditToolResult) IsError() bool

IsError returns true if the result contains an error

func (*FileEditToolResult) StructuredData

StructuredData returns structured metadata about the file edit operation

type FileReadInput

type FileReadInput tooltypes.FileReadInput

FileReadInput reuses the shared file_read tool input schema while preserving pkg/tools schema IDs.

type FileReadTool

type FileReadTool struct{}

FileReadTool provides functionality to read files with line numbers

func (*FileReadTool) Description

func (r *FileReadTool) Description() string

Description returns the description of the tool

func (*FileReadTool) Execute

func (r *FileReadTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute reads the file and returns the result

func (*FileReadTool) GenerateSchema

func (r *FileReadTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*FileReadTool) Name

func (r *FileReadTool) Name() string

Name returns the name of the tool

func (*FileReadTool) TracingKVs

func (r *FileReadTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*FileReadTool) ValidateInput

func (r *FileReadTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type FileReadToolResult

type FileReadToolResult struct {
	// contains filtered or unexported fields
}

FileReadToolResult represents the result of a file read operation

func (*FileReadToolResult) AssistantFacing

func (r *FileReadToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*FileReadToolResult) GetError

func (r *FileReadToolResult) GetError() string

GetError returns the error message

func (*FileReadToolResult) GetResult

func (r *FileReadToolResult) GetResult() string

GetResult returns the file content

func (*FileReadToolResult) IsError

func (r *FileReadToolResult) IsError() bool

IsError returns true if the result contains an error

func (*FileReadToolResult) StructuredData

StructuredData returns structured metadata about the file read operation

type FileWriteInput

type FileWriteInput tooltypes.FileWriteInput

FileWriteInput reuses the shared file_write tool input schema while preserving pkg/tools schema IDs.

type FileWriteTool

type FileWriteTool struct{}

FileWriteTool provides functionality to write files

func (*FileWriteTool) Description

func (t *FileWriteTool) Description() string

Description returns the description of the tool

func (*FileWriteTool) Execute

func (t *FileWriteTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute writes the file and returns the result

func (*FileWriteTool) GenerateSchema

func (t *FileWriteTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*FileWriteTool) Name

func (t *FileWriteTool) Name() string

Name returns the name of the tool

func (*FileWriteTool) TracingKVs

func (t *FileWriteTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*FileWriteTool) ValidateInput

func (t *FileWriteTool) ValidateInput(state tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type FileWriteToolResult

type FileWriteToolResult struct {
	// contains filtered or unexported fields
}

FileWriteToolResult represents the result of a file write operation

func (*FileWriteToolResult) AssistantFacing

func (r *FileWriteToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*FileWriteToolResult) GetError

func (r *FileWriteToolResult) GetError() string

GetError returns the error message

func (*FileWriteToolResult) GetResult

func (r *FileWriteToolResult) GetResult() string

GetResult returns a success message

func (*FileWriteToolResult) IsError

func (r *FileWriteToolResult) IsError() bool

IsError returns true if the result contains an error

func (*FileWriteToolResult) StructuredData

StructuredData returns structured metadata about the file write operation

type GlobInput

type GlobInput tooltypes.GlobInput

GlobInput reuses the shared glob_tool input schema while preserving pkg/tools schema IDs.

type GlobTool

type GlobTool struct{}

GlobTool provides functionality to search for files using glob patterns

func (*GlobTool) Description

func (t *GlobTool) Description() string

Description returns the description of the tool

func (*GlobTool) Execute

func (t *GlobTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute searches for files matching the glob pattern

func (*GlobTool) GenerateSchema

func (t *GlobTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*GlobTool) Name

func (t *GlobTool) Name() string

Name returns the name of the tool

func (*GlobTool) TracingKVs

func (t *GlobTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*GlobTool) ValidateInput

func (t *GlobTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type GlobToolResult

type GlobToolResult struct {
	// contains filtered or unexported fields
}

GlobToolResult represents the result of a glob pattern search

func (*GlobToolResult) AssistantFacing

func (r *GlobToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*GlobToolResult) GetError

func (r *GlobToolResult) GetError() string

GetError returns the error message

func (*GlobToolResult) GetResult

func (r *GlobToolResult) GetResult() string

GetResult returns the formatted search results

func (*GlobToolResult) IsError

func (r *GlobToolResult) IsError() bool

IsError returns true if the result contains an error

func (*GlobToolResult) StructuredData

func (r *GlobToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the glob search

type GrepTool

type GrepTool struct{}

GrepTool provides functionality to search for patterns in files

func (*GrepTool) Description

func (t *GrepTool) Description() string

Description returns the description of the tool

func (*GrepTool) Execute

func (t *GrepTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute searches for the pattern in files and returns the results

func (*GrepTool) GenerateSchema

func (t *GrepTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*GrepTool) Name

func (t *GrepTool) Name() string

Name returns the name of the tool

func (*GrepTool) TracingKVs

func (t *GrepTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*GrepTool) ValidateInput

func (t *GrepTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type GrepToolResult

type GrepToolResult struct {
	// contains filtered or unexported fields
}

GrepToolResult represents the result of a grep/search operation

func (*GrepToolResult) AssistantFacing

func (r *GrepToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*GrepToolResult) GetError

func (r *GrepToolResult) GetError() string

GetError returns the error message

func (*GrepToolResult) GetResult

func (r *GrepToolResult) GetResult() string

GetResult returns the formatted search results

func (*GrepToolResult) IsError

func (r *GrepToolResult) IsError() bool

IsError returns true if the result contains an error

func (*GrepToolResult) StructuredData

func (r *GrepToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the search operation

type GrepTruncationReason

type GrepTruncationReason string

GrepTruncationReason indicates why results were truncated

const (
	GrepNotTruncated          GrepTruncationReason = ""
	GrepTruncatedByFileLimit  GrepTruncationReason = "file_limit"
	GrepTruncatedByOutputSize GrepTruncationReason = "output_size"
)

Truncation reason constants

type ImageRecognitionInput

type ImageRecognitionInput struct {
	ImagePath string `` /* 183-byte string literal not displayed */
	Prompt    string `json:"prompt" jsonschema:"description=The information you want to extract from the image."`
}

ImageRecognitionInput defines the input parameters for the image_recognition tool.

type ImageRecognitionTool

type ImageRecognitionTool struct{}

ImageRecognitionTool implements the image_recognition tool for processing and understanding images.

func (*ImageRecognitionTool) Description

func (t *ImageRecognitionTool) Description() string

Description returns the description of the tool.

func (*ImageRecognitionTool) Execute

func (t *ImageRecognitionTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute executes the image_recognition tool using shell-out pattern. This spawns a subagent process via `kodelet run --as-subagent --image` for image analysis.

func (*ImageRecognitionTool) GenerateSchema

func (t *ImageRecognitionTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters.

func (*ImageRecognitionTool) Name

func (t *ImageRecognitionTool) Name() string

Name returns the name of the tool.

func (*ImageRecognitionTool) TracingKVs

func (t *ImageRecognitionTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability.

func (*ImageRecognitionTool) ValidateInput

func (t *ImageRecognitionTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool. ValidateInput validates the input parameters for the tool

type ImageRecognitionToolResult

type ImageRecognitionToolResult struct {
	// contains filtered or unexported fields
}

ImageRecognitionToolResult represents the result of an image recognition operation

func (*ImageRecognitionToolResult) AssistantFacing

func (r *ImageRecognitionToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*ImageRecognitionToolResult) GetError

func (r *ImageRecognitionToolResult) GetError() string

GetError returns the error message

func (*ImageRecognitionToolResult) GetResult

func (r *ImageRecognitionToolResult) GetResult() string

GetResult returns the recognized text

func (*ImageRecognitionToolResult) IsError

func (r *ImageRecognitionToolResult) IsError() bool

IsError returns true if the result contains an error

func (*ImageRecognitionToolResult) StructuredData

StructuredData returns structured metadata about the image recognition operation

type MCPConfig

type MCPConfig struct {
	Servers map[string]MCPServerConfig `json:"servers"`
}

MCPConfig holds the configuration for all MCP servers

func LoadMCPConfigFromViper

func LoadMCPConfigFromViper() (MCPConfig, error)

LoadMCPConfigFromViper loads MCP servers configuration from Viper

type MCPManager

type MCPManager struct {
	// contains filtered or unexported fields
}

MCPManager manages MCP clients and tools

func CreateMCPManagerFromViper

func CreateMCPManagerFromViper(ctx context.Context) (*MCPManager, error)

CreateMCPManagerFromViper creates a new MCPManager from Viper configuration Returns ErrMCPDisabled if MCP is disabled via configuration

func NewMCPManager

func NewMCPManager(config MCPConfig) (*MCPManager, error)

NewMCPManager creates a new MCP manager with the given configuration

func (*MCPManager) Clone

func (m *MCPManager) Clone() *MCPManager

Clone returns a shallow, non-owning copy of the manager so callers can compose per-session views without mutating or closing the shared configured MCP manager.

func (*MCPManager) Close

func (m *MCPManager) Close(ctx context.Context) error

Close closes all MCP clients

func (*MCPManager) GetMCPClient

func (m *MCPManager) GetMCPClient(clientName string) (*client.Client, error)

GetMCPClient gets the MCP client by name

func (*MCPManager) Initialize

func (m *MCPManager) Initialize(ctx context.Context) error

Initialize initializes all MCP clients

func (*MCPManager) ListMCPTools

func (m *MCPManager) ListMCPTools(ctx context.Context) ([]MCPTool, error)

ListMCPTools lists all available MCP tools from all clients

func (*MCPManager) ListMCPToolsIter

func (m *MCPManager) ListMCPToolsIter(
	ctx context.Context,
	iter func(serverName string, client *client.Client, tools []mcp.Tool),
	errHandler ...func(err error),
)

ListMCPToolsIter iterates over all MCP tools from all servers and calls the iter function for each server.

func (*MCPManager) Merge

func (m *MCPManager) Merge(other *MCPManager)

Merge adds all clients from another MCPManager into this one. If a client with the same name already exists, it is skipped.

type MCPServerConfig

type MCPServerConfig struct {
	ServerType    MCPServerType     `json:"server_type" yaml:"server_type"`         // stdio, sse (deprecated), or http (streamable HTTP)
	Command       string            `json:"command" yaml:"command"`                 // stdio: command to start the server
	Args          []string          `json:"args" yaml:"args"`                       // stdio: arguments to pass to the server
	Envs          map[string]string `json:"envs" yaml:"envs"`                       // stdio: environment variables to set
	BaseURL       string            `json:"base_url" yaml:"base_url"`               // http/sse: base URL of the server
	Headers       map[string]string `json:"headers" yaml:"headers"`                 // http/sse: headers to send to the server
	ToolWhiteList []string          `json:"tool_white_list" yaml:"tool_white_list"` // optional tool white list
}

MCPServerConfig holds the configuration for an MCP server

type MCPServerType

type MCPServerType string

MCPServerType represents the type of MCP server

const (
	// MCPServerTypeStdio represents a stdio-based MCP server
	MCPServerTypeStdio MCPServerType = "stdio"
	// MCPServerTypeSSE represents an SSE-based MCP server
	MCPServerTypeSSE MCPServerType = "sse"
	// MCPServerTypeHTTP represents a streamable HTTP-based MCP server
	MCPServerTypeHTTP MCPServerType = "http"
)

type MCPTool

type MCPTool struct {
	// contains filtered or unexported fields
}

MCPTool wraps an MCP tool with its client

func NewMCPTool

func NewMCPTool(client *client.Client, tool mcp.Tool, serverName string) *MCPTool

NewMCPTool creates a new MCP tool wrapper

func (*MCPTool) Description

func (t *MCPTool) Description() string

Description returns the description of the tool

func (*MCPTool) Execute

func (t *MCPTool) Execute(ctx context.Context, _ tooltypes.State, parameters string) tooltypes.ToolResult

Execute runs the MCP tool and returns the result

func (*MCPTool) GenerateSchema

func (t *MCPTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*MCPTool) MCPToolName

func (t *MCPTool) MCPToolName() string

MCPToolName returns the original MCP tool name (without the "mcp_" prefix)

func (*MCPTool) Name

func (t *MCPTool) Name() string

Name returns the name of the tool

func (*MCPTool) ServerName

func (t *MCPTool) ServerName() string

ServerName returns the name of the MCP server this tool belongs to

func (*MCPTool) TracingKVs

func (t *MCPTool) TracingKVs(_ string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*MCPTool) ValidateInput

func (t *MCPTool) ValidateInput(_ tooltypes.State, _ string) error

ValidateInput validates the input parameters for the tool

type MCPToolResult

type MCPToolResult struct {
	// contains filtered or unexported fields
}

MCPToolResult represents the result of an MCP tool execution

func (*MCPToolResult) AssistantFacing

func (r *MCPToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*MCPToolResult) GetError

func (r *MCPToolResult) GetError() string

GetError returns the error message

func (*MCPToolResult) GetResult

func (r *MCPToolResult) GetResult() string

GetResult returns the tool output

func (*MCPToolResult) IsError

func (r *MCPToolResult) IsError() bool

IsError returns true if the result contains an error

func (*MCPToolResult) StructuredData

func (r *MCPToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the MCP tool execution

type MatchPosition

type MatchPosition struct {
	Start int
	End   int
}

MatchPosition represents the start and end position of a match within a line

type Priority

type Priority string

Priority represents the priority of a todo item

const (
	// Low priority
	Low Priority = "low"
	// Medium priority
	Medium Priority = "medium"
	// High priority
	High Priority = "high"
)

type ReadConversationInput

type ReadConversationInput tooltypes.ReadConversationInput

ReadConversationInput reuses the shared read_conversation input schema while preserving pkg/tools schema IDs.

type ReadConversationTool

type ReadConversationTool struct {
	// contains filtered or unexported fields
}

ReadConversationTool reads a saved conversation and extracts the parts relevant to a goal.

func NewReadConversationTool

func NewReadConversationTool() *ReadConversationTool

NewReadConversationTool creates a read_conversation tool with production dependencies.

func (*ReadConversationTool) Description

func (t *ReadConversationTool) Description() string

Description returns the tool description.

func (*ReadConversationTool) Execute

func (t *ReadConversationTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute executes the read_conversation tool.

func (*ReadConversationTool) GenerateSchema

func (t *ReadConversationTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool input.

func (*ReadConversationTool) Name

func (t *ReadConversationTool) Name() string

Name returns the tool name.

func (*ReadConversationTool) TracingKVs

func (t *ReadConversationTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing attributes for observability.

func (*ReadConversationTool) ValidateInput

func (t *ReadConversationTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the tool input.

type ReadConversationToolResult

type ReadConversationToolResult struct {
	// contains filtered or unexported fields
}

ReadConversationToolResult represents the extracted conversation content.

func (*ReadConversationToolResult) AssistantFacing

func (r *ReadConversationToolResult) AssistantFacing() string

AssistantFacing returns the assistant-visible tool output.

func (*ReadConversationToolResult) GetError

func (r *ReadConversationToolResult) GetError() string

GetError returns the tool error.

func (*ReadConversationToolResult) GetResult

func (r *ReadConversationToolResult) GetResult() string

GetResult returns the extracted content.

func (*ReadConversationToolResult) IsError

func (r *ReadConversationToolResult) IsError() bool

IsError returns whether the result is an error.

func (*ReadConversationToolResult) StructuredData

StructuredData returns structured metadata about the read_conversation result.

type SearchResult

type SearchResult struct {
	Filename       string
	MatchedLines   map[int]string          // Line number -> content (matched lines)
	MatchPositions map[int][]MatchPosition // Line number -> match positions within the line
	ContextLines   map[int]string          // Line number -> content (context lines)
	LineNumbers    []int                   // All line numbers in order
}

SearchResult represents a search result from a file

type SkillInput

type SkillInput struct {
	SkillName string `json:"skill_name" jsonschema:"description=The name of the skill to invoke"`
}

SkillInput defines the input parameters for the skill tool

type SkillTool

type SkillTool struct {
	// contains filtered or unexported fields
}

SkillTool provides access to agentic skills

func NewSkillTool

func NewSkillTool(discoveredSkills map[string]*skills.Skill, enabled bool, disableFSSearchTools bool) *SkillTool

NewSkillTool creates a new skill tool with discovered skills

func NewSkillToolWithOptions

func NewSkillToolWithOptions(discoveredSkills map[string]*skills.Skill, enabled bool, toolMode llmtypes.ToolMode, disableFSSearchTools bool) *SkillTool

NewSkillToolWithOptions creates a new skill tool with rendering options.

func (*SkillTool) Description

func (t *SkillTool) Description() string

Description returns the tool description with available skills

func (*SkillTool) Execute

func (t *SkillTool) Execute(_ context.Context, _ tooltypes.State, parameters string) tooltypes.ToolResult

Execute invokes the skill and returns its content

func (*SkillTool) GenerateSchema

func (t *SkillTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input

func (*SkillTool) GetSkills

func (t *SkillTool) GetSkills() map[string]*skills.Skill

GetSkills returns the discovered skills

func (*SkillTool) IsActive

func (t *SkillTool) IsActive(skillName string) bool

IsActive checks if a skill is currently active

func (*SkillTool) IsEnabled

func (t *SkillTool) IsEnabled() bool

IsEnabled returns whether skills are enabled

func (*SkillTool) Name

func (t *SkillTool) Name() string

Name returns the tool name

func (*SkillTool) ResetActiveSkills

func (t *SkillTool) ResetActiveSkills()

ResetActiveSkills clears all active skills

func (*SkillTool) TracingKVs

func (t *SkillTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*SkillTool) ValidateInput

func (t *SkillTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters

type SkillToolResult

type SkillToolResult struct {
	// contains filtered or unexported fields
}

SkillToolResult represents the result of a skill invocation

func (*SkillToolResult) AssistantFacing

func (r *SkillToolResult) AssistantFacing() string

AssistantFacing returns the content to be fed to the LLM

func (*SkillToolResult) GetError

func (r *SkillToolResult) GetError() string

GetError returns the error string

func (*SkillToolResult) GetResult

func (r *SkillToolResult) GetResult() string

GetResult returns the result string

func (*SkillToolResult) IsError

func (r *SkillToolResult) IsError() bool

IsError returns true if there was an error

func (*SkillToolResult) StructuredData

func (r *SkillToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata for rendering

type Status

type Status string

Status represents the status of a todo item

const (
	// Pending indicates the todo is pending
	Pending Status = "pending"
	// InProgress indicates the todo is in progress
	InProgress Status = "in_progress"
	// Completed indicates the todo is completed
	Completed Status = "completed"
	// Canceled indicates the todo was canceled
	Canceled Status = "canceled"
)

type SubAgentInput

type SubAgentInput struct {
	Question string            `json:"question,omitempty" jsonschema:"description=The question to ask (required unless workflow is specified)"`
	Workflow string            `json:"workflow,omitempty" jsonschema:"description=Optional workflow name to use for specialized tasks"`
	Args     map[string]string `json:"args,omitempty" jsonschema:"description=Optional arguments for the workflow as key-value pairs"`
	Cwd      string            `json:"cwd,omitempty" jsonschema:"description=Working directory for subagent (absolute path)"`
}

SubAgentInput defines the input parameters for the sub-agent tool

type SubAgentTool

type SubAgentTool struct {
	// contains filtered or unexported fields
}

SubAgentTool provides functionality to spawn sub-agents for complex tasks

func NewSubAgentTool

func NewSubAgentTool(discoveredWorkflows map[string]*fragments.Fragment, workflowEnabled bool, disableFSSearchTools bool) *SubAgentTool

NewSubAgentTool creates a new sub-agent tool with discovered workflows

func NewSubAgentToolWithOptions

func NewSubAgentToolWithOptions(discoveredWorkflows map[string]*fragments.Fragment, workflowEnabled bool, toolMode llmtypes.ToolMode, disableFSSearchTools bool) *SubAgentTool

NewSubAgentToolWithOptions creates a new sub-agent tool with rendering options.

func (*SubAgentTool) Description

func (t *SubAgentTool) Description() string

Description returns the description of the tool

func (*SubAgentTool) Execute

func (t *SubAgentTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute runs the sub-agent via shell-out and returns the result

func (*SubAgentTool) GenerateSchema

func (t *SubAgentTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*SubAgentTool) GetWorkflows

func (t *SubAgentTool) GetWorkflows() map[string]*fragments.Fragment

GetWorkflows returns the discovered workflows

func (*SubAgentTool) IsWorkflowEnabled

func (t *SubAgentTool) IsWorkflowEnabled() bool

IsWorkflowEnabled returns whether workflows are enabled

func (*SubAgentTool) Name

func (t *SubAgentTool) Name() string

Name returns the name of the tool

func (*SubAgentTool) TracingKVs

func (t *SubAgentTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*SubAgentTool) ValidateInput

func (t *SubAgentTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type SubAgentToolResult

type SubAgentToolResult struct {
	// contains filtered or unexported fields
}

SubAgentToolResult represents the result of a sub-agent tool execution

func (*SubAgentToolResult) AssistantFacing

func (r *SubAgentToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*SubAgentToolResult) GetError

func (r *SubAgentToolResult) GetError() string

GetError returns the error message

func (*SubAgentToolResult) GetResult

func (r *SubAgentToolResult) GetResult() string

GetResult returns the sub-agent output

func (*SubAgentToolResult) IsError

func (r *SubAgentToolResult) IsError() bool

IsError returns true if the result contains an error

func (*SubAgentToolResult) StructuredData

StructuredData returns structured metadata about the sub-agent execution

type Todo

type Todo struct {
	Content  string   `json:"content" jsonschema:"description=The content of the todo in 1-2 sentences"`
	Status   Status   `json:"status" jsonschema:"description=The status of the todo"`
	Priority Priority `json:"priority" jsonschema:"description=The priority of the todo"`
}

Todo represents a single todo item

type TodoReadInput

type TodoReadInput struct{}

TodoReadInput defines the input parameters for the todo_read tool

type TodoReadTool

type TodoReadTool struct{}

TodoReadTool provides functionality to read the todo list

func (*TodoReadTool) Description

func (t *TodoReadTool) Description() string

Description returns the description of the tool

func (*TodoReadTool) Execute

Execute reads the todo file and returns the formatted list

func (*TodoReadTool) GenerateSchema

func (t *TodoReadTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*TodoReadTool) Name

func (t *TodoReadTool) Name() string

Name returns the name of the tool

func (*TodoReadTool) TracingKVs

func (t *TodoReadTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*TodoReadTool) ValidateInput

func (t *TodoReadTool) ValidateInput(_ tooltypes.State, _ string) error

ValidateInput validates the input parameters for the tool

type TodoToolResult

type TodoToolResult struct {
	// contains filtered or unexported fields
}

TodoToolResult represents the result of a todo read operation

func (*TodoToolResult) AssistantFacing

func (r *TodoToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*TodoToolResult) GetError

func (r *TodoToolResult) GetError() string

GetError returns the error message

func (*TodoToolResult) GetResult

func (r *TodoToolResult) GetResult() string

GetResult returns the formatted todo list

func (*TodoToolResult) IsError

func (r *TodoToolResult) IsError() bool

IsError returns true if the result contains an error

func (*TodoToolResult) StructuredData

func (r *TodoToolResult) StructuredData() tooltypes.StructuredToolResult

StructuredData returns structured metadata about the todo read operation

type TodoWriteInput

type TodoWriteInput struct {
	Todos []Todo `json:"todos" jsonschema:"description=The full list of todos including all the pending in_progress and completed ones"`
}

TodoWriteInput defines the input parameters for the todo_write tool

type TodoWriteTool

type TodoWriteTool struct{}

TodoWriteTool provides functionality to write and manage the todo list

func (*TodoWriteTool) Description

func (t *TodoWriteTool) Description() string

Description returns the description of the tool

func (*TodoWriteTool) Execute

func (t *TodoWriteTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute writes the todo list to the file

func (*TodoWriteTool) GenerateSchema

func (t *TodoWriteTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters

func (*TodoWriteTool) Name

func (t *TodoWriteTool) Name() string

Name returns the name of the tool

func (*TodoWriteTool) TracingKVs

func (t *TodoWriteTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability

func (*TodoWriteTool) ValidateInput

func (t *TodoWriteTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool

type WebFetchInput

type WebFetchInput struct {
	URL    string `json:"url" jsonschema:"description=The URL to fetch content from"`
	Prompt string `json:"prompt,omitempty" jsonschema:"description=Information to extract from HTML/Markdown content (optional)"`
}

WebFetchInput defines the input parameters for the web_fetch tool.

type WebFetchTool

type WebFetchTool struct {
	// contains filtered or unexported fields
}

WebFetchTool implements the web_fetch tool for retrieving and processing web content.

func NewWebFetchTool

func NewWebFetchTool(allowedDomainsFile string) *WebFetchTool

NewWebFetchTool creates a new WebFetchTool with optional domain filtering

func (*WebFetchTool) Description

func (t *WebFetchTool) Description() string

Description returns the description of the tool.

func (*WebFetchTool) Execute

func (t *WebFetchTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult

Execute executes the web_fetch tool.

func (*WebFetchTool) GenerateSchema

func (t *WebFetchTool) GenerateSchema() *jsonschema.Schema

GenerateSchema generates the JSON schema for the tool's input parameters.

func (*WebFetchTool) Name

func (t *WebFetchTool) Name() string

Name returns the name of the tool.

func (*WebFetchTool) TracingKVs

func (t *WebFetchTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)

TracingKVs returns tracing key-value pairs for observability.

func (*WebFetchTool) ValidateInput

func (t *WebFetchTool) ValidateInput(_ tooltypes.State, parameters string) error

ValidateInput validates the input parameters for the tool.

type WebFetchToolResult

type WebFetchToolResult struct {
	// contains filtered or unexported fields
}

WebFetchToolResult represents the result of fetching content from a web URL

func (*WebFetchToolResult) AssistantFacing

func (r *WebFetchToolResult) AssistantFacing() string

AssistantFacing returns the string representation for the AI assistant

func (*WebFetchToolResult) GetError

func (r *WebFetchToolResult) GetError() string

GetError returns the error message

func (*WebFetchToolResult) GetResult

func (r *WebFetchToolResult) GetResult() string

GetResult returns the fetched content

func (*WebFetchToolResult) IsError

func (r *WebFetchToolResult) IsError() bool

IsError returns true if the result contains an error

func (*WebFetchToolResult) StructuredData

StructuredData returns structured metadata about the web fetch operation

Directories

Path Synopsis
Package renderers provides CLI output rendering functionality for tool results.
Package renderers provides CLI output rendering functionality for tool results.

Jump to

Keyboard shortcuts

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