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
- Variables
- func ContextWithCodeExecution(ctx context.Context, execution CodeExecutionContext) context.Context
- func ContextWithConversationID(ctx context.Context, conversationID string) context.Context
- func ContextWithToolContext(ctx context.Context, toolContext ToolContext) context.Context
- func FormatEditedBlock(originalContent, oldText, newText string) string
- func FormatSearchResults(pattern string, results []SearchResult) string
- func GenerateSchema[T any]() *jsonschema.Schema
- func GetMainTools(ctx context.Context, allowedTools []string) []tooltypes.Tool
- func GetMainToolsWithOptions(ctx context.Context, allowedTools []string, enableFSSearchTools bool) []tooltypes.Tool
- func GetToolsFromNames(toolNames []string) []tooltypes.Tool
- func PruneCodeExecutionAttachments(result, original tooltypes.StructuredToolResult) tooltypes.StructuredToolResult
- func RunTool(ctx context.Context, state tooltypes.State, toolName string, parameters string) tooltypes.ToolResult
- func RunToolImplementationWithUpdates(ctx context.Context, state tooltypes.State, tool tooltypes.Tool, ...) tooltypes.ToolResult
- func RunToolWithUpdates(ctx context.Context, state tooltypes.State, toolName string, parameters string, ...) tooltypes.ToolResult
- func ToOpenAITools(tools []tooltypes.Tool) []openai.Tool
- func ValidateTools(toolNames []string) error
- func VirtualToolNames() []string
- type ApplyPatchInput
- type ApplyPatchTool
- func (t *ApplyPatchTool) Description() string
- func (t *ApplyPatchTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *ApplyPatchTool) GenerateSchema() *jsonschema.Schema
- func (t *ApplyPatchTool) Name() string
- func (t *ApplyPatchTool) Short() string
- func (t *ApplyPatchTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *ApplyPatchTool) ValidateInput(state tooltypes.State, parameters string) error
- type BashInput
- type BashTool
- func (*BashTool) CodeModeDescription() string
- func (b *BashTool) Description() string
- func (b *BashTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (b *BashTool) ExecuteStreaming(ctx context.Context, state tooltypes.State, parameters string, ...) tooltypes.ToolResult
- func (b *BashTool) GenerateSchema() *jsonschema.Schema
- func (b *BashTool) MatchesCommand(command string) bool
- func (b *BashTool) Name() string
- func (b *BashTool) RawOutputSchema() map[string]any
- func (b *BashTool) Short() string
- func (b *BashTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (b *BashTool) ValidateInput(_ tooltypes.State, parameters string) error
- type BashToolResult
- type BasicState
- func (s *BasicState) BasicTools() []tooltypes.Tool
- func (s *BasicState) DiscoverContexts() map[string]string
- func (s *BasicState) ExtensionTools() []tooltypes.Tool
- func (s *BasicState) GetLLMConfig() any
- func (s *BasicState) LockFile(path string)
- func (s *BasicState) Tools() []tooltypes.Tool
- func (s *BasicState) UnlockFile(path string)
- func (s *BasicState) WorkingDirectory() string
- type BasicStateOption
- type BrowserController
- type BrowserInput
- type BrowserTool
- func (*BrowserTool) CodeModeDescription() string
- func (*BrowserTool) Description() string
- func (t *BrowserTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (*BrowserTool) GenerateSchema() *jsonschema.Schema
- func (*BrowserTool) Name() string
- func (*BrowserTool) Short() string
- func (*BrowserTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (*BrowserTool) ValidateInput(_ tooltypes.State, parameters string) error
- type CodeExecuteResult
- func (r CodeExecuteResult) AssistantFacing() string
- func (r CodeExecuteResult) ContentParts() []tooltypes.ToolResultContentPart
- func (r CodeExecuteResult) GetError() string
- func (r CodeExecuteResult) GetResult() string
- func (r CodeExecuteResult) IsError() bool
- func (r CodeExecuteResult) StructuredData() tooltypes.StructuredToolResult
- type CodeExecuteTool
- func (*CodeExecuteTool) Description() string
- func (t *CodeExecuteTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *CodeExecuteTool) ExecuteStreaming(ctx context.Context, state tooltypes.State, parameters string, ...) tooltypes.ToolResult
- func (*CodeExecuteTool) GenerateSchema() *jsonschema.Schema
- func (*CodeExecuteTool) Name() string
- func (*CodeExecuteTool) TracingKVs(string) ([]attribute.KeyValue, error)
- func (*CodeExecuteTool) ValidateInput(_ tooltypes.State, parameters string) error
- type CodeExecutionContext
- type CodeSearchInput
- type CodeToolError
- type CodeToolReply
- type ContextDiscovery
- type EditInfo
- type FileEditInput
- type FileEditTool
- func (t *FileEditTool) Description() string
- func (t *FileEditTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *FileEditTool) GenerateSchema() *jsonschema.Schema
- func (t *FileEditTool) Name() string
- func (t *FileEditTool) Short() string
- func (t *FileEditTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *FileEditTool) ValidateInput(_ tooltypes.State, parameters string) error
- type FileEditToolResult
- type FileReadInput
- type FileReadTool
- func (*FileReadTool) CodeModeDescription() string
- func (r *FileReadTool) Description() string
- func (r *FileReadTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (r *FileReadTool) GenerateSchema() *jsonschema.Schema
- func (r *FileReadTool) Name() string
- func (r *FileReadTool) RawOutputSchema() map[string]any
- func (r *FileReadTool) Short() string
- func (r *FileReadTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (r *FileReadTool) ValidateInput(_ tooltypes.State, parameters string) error
- type FileReadToolResult
- type FileWriteInput
- type FileWriteTool
- func (t *FileWriteTool) Description() string
- func (t *FileWriteTool) Execute(_ context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *FileWriteTool) GenerateSchema() *jsonschema.Schema
- func (t *FileWriteTool) Name() string
- func (t *FileWriteTool) Short() string
- func (t *FileWriteTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *FileWriteTool) ValidateInput(_ tooltypes.State, parameters string) error
- type FileWriteToolResult
- type GlobInput
- type GlobTool
- func (t *GlobTool) Description() string
- func (t *GlobTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *GlobTool) GenerateSchema() *jsonschema.Schema
- func (t *GlobTool) Name() string
- func (t *GlobTool) Short() string
- func (t *GlobTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *GlobTool) ValidateInput(_ tooltypes.State, parameters string) error
- type GlobToolResult
- type GrepTool
- func (t *GrepTool) Description() string
- func (t *GrepTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *GrepTool) GenerateSchema() *jsonschema.Schema
- func (t *GrepTool) Name() string
- func (t *GrepTool) Short() string
- func (t *GrepTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *GrepTool) ValidateInput(_ tooltypes.State, parameters string) error
- type GrepToolResult
- type GrepTruncationReason
- type MatchPosition
- type MetadataStore
- type SearchResult
- type SkillInput
- type SkillTool
- func (t *SkillTool) Description() string
- func (t *SkillTool) Execute(_ context.Context, _ tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *SkillTool) GenerateSchema() *jsonschema.Schema
- func (t *SkillTool) GetSkills() map[string]*skills.Skill
- func (t *SkillTool) IsActive(skillName string) bool
- func (t *SkillTool) IsEnabled() bool
- func (t *SkillTool) ModelOnly() bool
- func (t *SkillTool) Name() string
- func (t *SkillTool) ResetActiveSkills()
- func (t *SkillTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *SkillTool) ValidateInput(_ tooltypes.State, parameters string) error
- type SkillToolResult
- type ToolContext
- type ViewImageInput
- type ViewImageTool
- func (*ViewImageTool) CodeModeDescription() string
- func (t *ViewImageTool) Description() string
- func (t *ViewImageTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *ViewImageTool) GenerateSchema() *jsonschema.Schema
- func (t *ViewImageTool) Name() string
- func (t *ViewImageTool) Short() string
- func (t *ViewImageTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *ViewImageTool) ValidateInput(state tooltypes.State, parameters string) error
- type ViewImageToolResult
- func (r *ViewImageToolResult) AssistantFacing() string
- func (r *ViewImageToolResult) ContentParts() []tooltypes.ToolResultContentPart
- func (r *ViewImageToolResult) GetError() string
- func (r *ViewImageToolResult) GetResult() string
- func (r *ViewImageToolResult) IsError() bool
- func (r *ViewImageToolResult) StructuredData() tooltypes.StructuredToolResult
- type WebFetchInput
- type WebFetchTool
- func (t *WebFetchTool) Description() string
- func (t *WebFetchTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
- func (t *WebFetchTool) GenerateSchema() *jsonschema.Schema
- func (t *WebFetchTool) Name() string
- func (t *WebFetchTool) Short() string
- func (t *WebFetchTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
- func (t *WebFetchTool) ValidateInput(_ tooltypes.State, parameters string) error
- type WebFetchToolResult
Constants ¶
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 )
const NoToolsMarker = "none"
NoToolsMarker is a special value indicating no tools should be enabled
Variables ¶
var ( // BannedCommands lists commands that are not allowed to run through the bash tool BannedCommands = []string{ "vim", "view", "less", "more", "cd", } )
Functions ¶
func ContextWithCodeExecution ¶
func ContextWithCodeExecution(ctx context.Context, execution CodeExecutionContext) context.Context
ContextWithCodeExecution installs the authorized runner-local child dispatcher.
func ContextWithToolContext ¶
func ContextWithToolContext(ctx context.Context, toolContext ToolContext) context.Context
func FormatEditedBlock ¶
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 ¶
GetMainTools returns the main tools available for the agent
func GetMainToolsWithOptions ¶
func GetMainToolsWithOptions(ctx context.Context, allowedTools []string, enableFSSearchTools bool) []tooltypes.Tool
GetMainToolsWithOptions returns the main tools available for the agent with feature toggles applied.
func GetToolsFromNames ¶
GetToolsFromNames returns a list of tools from the given tool names
func PruneCodeExecutionAttachments ¶
func PruneCodeExecutionAttachments(result, original tooltypes.StructuredToolResult) tooltypes.StructuredToolResult
PruneCodeExecutionAttachments retains only host-owned references still selected after parent result hooks. Hook-provided descriptors cannot create authority.
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 RunToolImplementationWithUpdates ¶
func RunToolImplementationWithUpdates( ctx context.Context, state tooltypes.State, tool tooltypes.Tool, parameters string, onUpdate tooltypes.ToolUpdateCallback, ) tooltypes.ToolResult
RunToolImplementationWithUpdates validates and executes a specific tool implementation.
func RunToolWithUpdates ¶
func RunToolWithUpdates( ctx context.Context, state tooltypes.State, toolName string, parameters string, onUpdate tooltypes.ToolUpdateCallback, ) tooltypes.ToolResult
RunToolWithUpdates executes a tool and forwards transient result snapshots when the selected tool implements tooltypes.StreamingTool.
func ToOpenAITools ¶
ToOpenAITools converts internal tool format to OpenAI's format
func ValidateTools ¶
ValidateTools validates that all tool names are available
func VirtualToolNames ¶
func VirtualToolNames() []string
VirtualToolNames returns tool names that are exposed directly by providers rather than through the executable tool registry.
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) Short ¶
func (t *ApplyPatchTool) Short() string
Short returns the one-line summary used in compact tool listings.
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 ¶
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 ¶
NewBashTool creates a new BashTool with the specified allowed commands
func NewBashToolWithTimeout ¶
func NewBashToolWithTimeout(allowedCommands []string, enableFSSearchTools bool, maxTimeout time.Duration) *BashTool
NewBashToolWithTimeout creates a BashTool with the specified maximum timeout.
func (*BashTool) CodeModeDescription ¶
CodeModeDescription explains where code-mode scripts find bash output.
func (*BashTool) Description ¶
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) ExecuteStreaming ¶
func (b *BashTool) ExecuteStreaming( ctx context.Context, state tooltypes.State, parameters string, onUpdate tooltypes.ToolUpdateCallback, ) tooltypes.ToolResult
ExecuteStreaming runs the bash command and emits accumulated output snapshots while stdout and stderr are still being produced.
func (*BashTool) GenerateSchema ¶
func (b *BashTool) GenerateSchema() *jsonschema.Schema
GenerateSchema generates the JSON schema for the tool's input parameters
func (*BashTool) MatchesCommand ¶
MatchesCommand checks if a command matches any of the compiled glob patterns
func (*BashTool) RawOutputSchema ¶
RawOutputSchema describes the bounded, canonical command result.
func (*BashTool) Short ¶
Short returns the one-line summary used in compact tool listings. The timeout unit is spelled out because JavaScript callers default to milliseconds.
func (*BashTool) TracingKVs ¶
TracingKVs returns tracing key-value pairs for observability
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) DiscoverContexts ¶
func (s *BasicState) DiscoverContexts() map[string]string
DiscoverContexts discovers and returns context information for the current state
func (*BasicState) ExtensionTools ¶
func (s *BasicState) ExtensionTools() []tooltypes.Tool
ExtensionTools returns the list of extension-provided tools.
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) 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 WithExtensionTools ¶
func WithExtensionTools(extensionTools []tooltypes.Tool) BasicStateOption
WithExtensionTools returns an option that configures extension-provided tools.
func WithLLMConfig ¶
func WithLLMConfig(config llmtypes.Config) BasicStateOption
WithLLMConfig returns an option that sets the LLM configuration
func WithMainTools ¶
func WithMainTools() BasicStateOption
WithMainTools returns an option that configures main tools
func WithSkillTool ¶
func WithSkillTool() BasicStateOption
WithSkillTool returns an option that configures the skill tool with discovered skills
func WithWorkingDirectory ¶
func WithWorkingDirectory(workingDir string) BasicStateOption
WithWorkingDirectory returns an option that sets the explicit working directory.
type BrowserController ¶
type BrowserController interface {
Open(context.Context, browser.Scope) (browser.Info, error)
Command(context.Context, browser.Scope, string, json.RawMessage) (json.RawMessage, error)
Stop(browser.Scope, string) error
}
BrowserController is the runner-owned browser resource shared with the conversation's Web UI.
type BrowserInput ¶
type BrowserInput struct {
Action string `` /* 187-byte string literal not displayed */
URL string `` /* 174-byte string literal not displayed */
Expression string `` /* 157-byte string literal not displayed */
Path string `` /* 159-byte string literal not displayed */
SessionID string `json:"sessionId,omitempty" jsonschema:"description=Session ID returned by open; required for explicit stop."`
}
BrowserInput describes an operation on the current conversation's shared page.
type BrowserTool ¶
type BrowserTool struct {
// contains filtered or unexported fields
}
BrowserTool is installed only in environments with an explicitly enabled browser.
func NewBrowserTool ¶
func NewBrowserTool(controller BrowserController) *BrowserTool
NewBrowserTool attaches agent actions to an existing runner-owned manager.
func (*BrowserTool) CodeModeDescription ¶
func (*BrowserTool) CodeModeDescription() string
CodeModeDescription explains where code-mode scripts find browser results.
func (*BrowserTool) Description ¶
func (*BrowserTool) Description() string
func (*BrowserTool) Execute ¶
func (t *BrowserTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
func (*BrowserTool) GenerateSchema ¶
func (*BrowserTool) GenerateSchema() *jsonschema.Schema
func (*BrowserTool) Name ¶
func (*BrowserTool) Name() string
func (*BrowserTool) Short ¶
func (*BrowserTool) Short() string
Short returns the one-line summary used in compact tool listings.
func (*BrowserTool) TracingKVs ¶
func (*BrowserTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
func (*BrowserTool) ValidateInput ¶
func (*BrowserTool) ValidateInput(_ tooltypes.State, parameters string) error
type CodeExecuteResult ¶
type CodeExecuteResult struct {
Metadata tooltypes.CodeExecutionMetadata
Error string
Attachments []tooltypes.ToolAttachment
}
CodeExecuteResult persists selected output, artifact references, and bounded UI child details.
func (CodeExecuteResult) AssistantFacing ¶
func (r CodeExecuteResult) AssistantFacing() string
func (CodeExecuteResult) ContentParts ¶
func (r CodeExecuteResult) ContentParts() []tooltypes.ToolResultContentPart
ContentParts keeps selected text and images in emission order. Only explicit image items with retained host-owned descriptors can become image content.
func (CodeExecuteResult) GetError ¶
func (r CodeExecuteResult) GetError() string
func (CodeExecuteResult) GetResult ¶
func (r CodeExecuteResult) GetResult() string
func (CodeExecuteResult) IsError ¶
func (r CodeExecuteResult) IsError() bool
func (CodeExecuteResult) StructuredData ¶
func (r CodeExecuteResult) StructuredData() tooltypes.StructuredToolResult
type CodeExecuteTool ¶
type CodeExecuteTool struct{}
CodeExecuteTool runs an async JavaScript function body inside the runner.
func (*CodeExecuteTool) Description ¶
func (*CodeExecuteTool) Description() string
func (*CodeExecuteTool) Execute ¶
func (t *CodeExecuteTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
func (*CodeExecuteTool) ExecuteStreaming ¶
func (t *CodeExecuteTool) ExecuteStreaming(ctx context.Context, state tooltypes.State, parameters string, update tooltypes.ToolUpdateCallback) tooltypes.ToolResult
func (*CodeExecuteTool) GenerateSchema ¶
func (*CodeExecuteTool) GenerateSchema() *jsonschema.Schema
func (*CodeExecuteTool) Name ¶
func (*CodeExecuteTool) Name() string
func (*CodeExecuteTool) TracingKVs ¶
func (*CodeExecuteTool) TracingKVs(string) ([]attribute.KeyValue, error)
func (*CodeExecuteTool) ValidateInput ¶
func (*CodeExecuteTool) ValidateInput(_ tooltypes.State, parameters string) error
type CodeExecutionContext ¶
type CodeExecutionContext struct {
Definitions []codemode.Definition
// Call's optional callback carries effective UI-only snapshots, never values
// exposed to JavaScript. A nil callback disables transient child updates.
Call func(context.Context, string, string, string, func(CodeToolReply)) (CodeToolReply, error)
// ValidateImage checks current host permissions and model detail support.
// It must not perform I/O: emissions run on the VM's owning goroutine.
ValidateImage func(detail string) error
}
CodeExecutionContext is host-owned authority for one parent invocation. It is never decoded from tool input and cannot be replaced by an input hook.
type CodeSearchInput ¶
type CodeSearchInput tooltypes.CodeSearchInput
CodeSearchInput reuses the shared grep_tool input schema while preserving pkg/tools schema IDs.
type CodeToolError ¶
type CodeToolError struct {
Kind string `json:"kind"`
Tool string `json:"tool"`
CallID string `json:"callId"`
Outcome string `json:"outcome"`
Message string `json:"message"`
Result *CodeToolReply `json:"result,omitempty"`
}
CodeToolError preserves known execution outcomes without implying rollback.
func (*CodeToolError) Error ¶
func (e *CodeToolError) Error() string
func (*CodeToolError) MarshalJSON ¶
func (e *CodeToolError) MarshalJSON() ([]byte, error)
MarshalJSON exposes serializable error details to the runtime bridge.
type CodeToolReply ¶
type CodeToolReply struct {
Data any `json:"data"`
Text string `json:"text"`
Attachments []tooltypes.ToolAttachment `json:"attachments"`
Truncated bool `json:"truncated"`
// Host-only, effective display details; never exposed to JavaScript.
Input json.RawMessage `json:"-"`
Result *tooltypes.StructuredToolResult `json:"-"`
}
CodeToolReply is the uniform, post-policy value exposed to JavaScript.
type ContextDiscovery ¶
type ContextDiscovery struct {
// contains filtered or unexported fields
}
ContextDiscovery tracks context discovery results
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) Short ¶
func (t *FileEditTool) Short() string
Short returns the one-line summary used in compact tool listings.
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(_ 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 ¶
func (r *FileEditToolResult) StructuredData() tooltypes.StructuredToolResult
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) CodeModeDescription ¶
func (*FileReadTool) CodeModeDescription() string
CodeModeDescription explains where code-mode scripts find file content.
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) RawOutputSchema ¶
func (r *FileReadTool) RawOutputSchema() map[string]any
RawOutputSchema describes file content without display line numbers or notices.
func (*FileReadTool) Short ¶
func (r *FileReadTool) Short() string
Short returns the one-line summary used in compact tool listings.
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 ¶
func (r *FileReadToolResult) StructuredData() tooltypes.StructuredToolResult
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) Short ¶
func (t *FileWriteTool) Short() string
Short returns the one-line summary used in compact tool listings.
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(_ 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 ¶
func (r *FileWriteToolResult) StructuredData() tooltypes.StructuredToolResult
StructuredData returns structured metadata about the file write operation
type 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 ¶
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) TracingKVs ¶
TracingKVs returns tracing key-value pairs for observability
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 ¶
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) TracingKVs ¶
TracingKVs returns tracing key-value pairs for observability
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 MatchPosition ¶
MatchPosition represents the start and end position of a match within a line
type MetadataStore ¶
type MetadataStore interface {
GetMetadata() map[string]any
SetMetadataValue(key string, value any)
}
MetadataStore exposes provider-neutral conversation metadata to tools that need to inspect or mutate thread-level runtime state.
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, enableFSSearchTools 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, enableFSSearchTools bool) *SkillTool
NewSkillToolWithOptions creates a new skill tool with rendering options.
func (*SkillTool) Description ¶
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) ModelOnly ¶
ModelOnly keeps the skill tool out of code-execution scripts. Its instructions only reach the model through the direct tool result, and loading a skill marks it active, so a script call would consume the skill without delivering it.
func (*SkillTool) ResetActiveSkills ¶
func (t *SkillTool) ResetActiveSkills()
ResetActiveSkills clears all active skills
func (*SkillTool) TracingKVs ¶
TracingKVs returns tracing key-value pairs for observability
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 ToolContext ¶
type ToolContext struct {
ConversationID string
WorkingDir string
Provider string
Model string
Profile string
RecipeName string
MetadataStore MetadataStore
}
func ToolContextFromContext ¶
func ToolContextFromContext(ctx context.Context) ToolContext
ToolContextFromContext returns normalized tool execution context.
func ToolContextFromThreadState ¶
func ToolContextFromThreadState(threadConfig llmtypes.Config, conversationID string, stateWorkingDir string, metadataStore MetadataStore) ToolContext
type ViewImageInput ¶
type ViewImageInput struct {
Path string `` /* 140-byte string literal not displayed */
ArtifactID string `` /* 175-byte string literal not displayed */
Detail string `json:"detail,omitempty" jsonschema:"enum=original,description=Optional. Set to 'original' for maximum detail."`
}
ViewImageInput defines the input parameters for the view_image tool.
type ViewImageTool ¶
type ViewImageTool struct {
// contains filtered or unexported fields
}
ViewImageTool implements local and persisted-artifact image inspection.
func NewViewImageTool ¶
func NewViewImageTool(model, provider string) *ViewImageTool
NewViewImageTool creates a view_image tool configured for the active model/provider.
func (*ViewImageTool) CodeModeDescription ¶
func (*ViewImageTool) CodeModeDescription() string
CodeModeDescription explains that code-mode calls return image references.
func (*ViewImageTool) Description ¶
func (t *ViewImageTool) Description() string
func (*ViewImageTool) Execute ¶
func (t *ViewImageTool) Execute(ctx context.Context, state tooltypes.State, parameters string) tooltypes.ToolResult
func (*ViewImageTool) GenerateSchema ¶
func (t *ViewImageTool) GenerateSchema() *jsonschema.Schema
func (*ViewImageTool) Name ¶
func (t *ViewImageTool) Name() string
func (*ViewImageTool) Short ¶
func (t *ViewImageTool) Short() string
Short returns the one-line summary used in compact tool listings.
func (*ViewImageTool) TracingKVs ¶
func (t *ViewImageTool) TracingKVs(parameters string) ([]attribute.KeyValue, error)
func (*ViewImageTool) ValidateInput ¶
func (t *ViewImageTool) ValidateInput(state tooltypes.State, parameters string) error
type ViewImageToolResult ¶
type ViewImageToolResult struct {
// contains filtered or unexported fields
}
ViewImageToolResult represents the result of a view_image operation.
func (*ViewImageToolResult) AssistantFacing ¶
func (r *ViewImageToolResult) AssistantFacing() string
func (*ViewImageToolResult) ContentParts ¶
func (r *ViewImageToolResult) ContentParts() []tooltypes.ToolResultContentPart
func (*ViewImageToolResult) GetError ¶
func (r *ViewImageToolResult) GetError() string
func (*ViewImageToolResult) GetResult ¶
func (r *ViewImageToolResult) GetResult() string
func (*ViewImageToolResult) IsError ¶
func (r *ViewImageToolResult) IsError() bool
func (*ViewImageToolResult) StructuredData ¶
func (r *ViewImageToolResult) StructuredData() tooltypes.StructuredToolResult
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) Short ¶
func (t *WebFetchTool) Short() string
Short returns the one-line summary used in compact tool listings.
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 ¶
func (r *WebFetchToolResult) StructuredData() tooltypes.StructuredToolResult
StructuredData returns structured metadata about the web fetch operation