Documentation
¶
Overview ¶
Package tools defines interfaces and types for kodelet's tool system including tool execution, result structures, state management, and JSON schema generation for LLM tool integration.
Index ¶
- Constants
- func CodeModeDescriptionForTool(tool Tool) string
- func ContextWithArtifactResolver(ctx context.Context, resolver ArtifactResolver) context.Context
- func ContextWithModelHelper(ctx context.Context, helper ModelHelper) context.Context
- func ExtractExtensionToolPresentation(result *StructuredToolResult) (ExtensionToolPresentation, ExtensionToolMetadata, bool)
- func ExtractMetadata(metadata ToolMetadata, target any) bool
- func ExtractTaskRunSnapshot(result *StructuredToolResult) (TaskRunSnapshot, ExtensionToolMetadata, bool)
- func IsModelOnly(tool Tool) bool
- func JSONSchemaForTool(tool Tool) map[string]any
- func OutputSchemaForTool(tool Tool) map[string]any
- func RunModelHelper(ctx context.Context, request ModelHelperRequest) (string, error)
- func ShortForTool(tool Tool) string
- func StringifyToolResult(result, err string) string
- type ApplyPatchChange
- type ApplyPatchInput
- type ApplyPatchMetadata
- type ArtifactResolver
- type BaseToolResult
- type BashInput
- type BashMetadata
- type BashOutputTruncation
- type BlockedMetadata
- type BlockedToolResult
- type BrowserMetadata
- type CodeExecutionCall
- type CodeExecutionMetadata
- type CodeExecutionOutput
- type CodeModeDescriber
- type CodeSearchInput
- type Edit
- type ExtensionToolMetadata
- type ExtensionToolPresentation
- type FileEditInput
- type FileEditMetadata
- type FileInfo
- type FileReadInput
- type FileReadMetadata
- type FileWriteInput
- type FileWriteMetadata
- type GlobInput
- type GlobMetadata
- type GrepMetadata
- type ImageDimensions
- type ModelHelper
- type ModelHelperRequest
- type ModelOnlyTool
- type MultiModalToolResult
- type OpenAIWebSearchMetadata
- type RawInputSchemaProvider
- type RawOutputSchemaProvider
- type ReadConversationInput
- type ReadConversationMetadata
- type SearchMatch
- type SearchResult
- type ShortDescriber
- type SkillMetadata
- type State
- type StreamingTool
- type StructuredToolResult
- type TaskRunActivity
- type TaskRunCounts
- type TaskRunSnapshot
- type Tool
- type ToolAttachment
- type ToolFailureProvider
- type ToolGroupProvider
- type ToolMetadata
- type ToolResult
- type ToolResultContentPart
- type ToolResultContentPartType
- type ToolUpdateCallback
- type ViewImageMetadata
- type WebFetchMetadata
Constants ¶
const ( // MaxExtensionToolPresentationSummaryRunes bounds compact presentation labels. MaxExtensionToolPresentationSummaryRunes = 160 // MaxExtensionToolPresentationBodyBytes bounds expanded presentation content. MaxExtensionToolPresentationBodyBytes = 100 * 1024 )
const ( // ApplyPatchOperationAdd indicates a file add operation. ApplyPatchOperationAdd = "add" // ApplyPatchOperationDelete indicates a file delete operation. ApplyPatchOperationDelete = "delete" // ApplyPatchOperationUpdate indicates a file update operation. ApplyPatchOperationUpdate = "update" )
const ( GrepTruncatedByFileLimit = "file_limit" GrepTruncatedByOutputSize = "output_size" )
GrepTruncationReason constants for truncation messaging
const ModelHelperWebFetchExtract = "web_fetch.extract"
ModelHelperWebFetchExtract is the only runner-delegated utility operation.
Variables ¶
This section is empty.
Functions ¶
func CodeModeDescriptionForTool ¶
CodeModeDescriptionForTool returns a tool's code-mode notes, or "" when it has none.
func ContextWithArtifactResolver ¶
func ContextWithArtifactResolver(ctx context.Context, resolver ArtifactResolver) context.Context
ContextWithArtifactResolver binds artifact access to a tool execution.
func ContextWithModelHelper ¶
func ContextWithModelHelper(ctx context.Context, helper ModelHelper) context.Context
ContextWithModelHelper installs the capability for one tool operation.
func ExtractExtensionToolPresentation ¶
func ExtractExtensionToolPresentation(result *StructuredToolResult) (ExtensionToolPresentation, ExtensionToolMetadata, bool)
ExtractExtensionToolPresentation reads data.presentation from an extension tool result.
func ExtractMetadata ¶
func ExtractMetadata(metadata ToolMetadata, target any) bool
ExtractMetadata is a helper that handles both pointer and value type assertions This is necessary because JSON unmarshaling creates value types, while direct creation uses pointer types
func ExtractTaskRunSnapshot ¶
func ExtractTaskRunSnapshot(result *StructuredToolResult) (TaskRunSnapshot, ExtensionToolMetadata, bool)
ExtractTaskRunSnapshot reads data.taskRun from an extension tool result.
func IsModelOnly ¶
IsModelOnly reports whether a tool is declared directly to the model and excluded from code-execution scripts.
func JSONSchemaForTool ¶
JSONSchemaForTool returns the model-facing schema without narrowing raw extension schemas through the typed jsonschema representation.
func OutputSchemaForTool ¶
OutputSchemaForTool returns a tool's optional machine-result JSON Schema.
func RunModelHelper ¶
func RunModelHelper(ctx context.Context, request ModelHelperRequest) (string, error)
RunModelHelper fails closed when no central capability is available.
func ShortForTool ¶
ShortForTool returns a tool's explicit one-line summary, or "" when it has none.
func StringifyToolResult ¶
StringifyToolResult formats a tool result and optional error into a string representation
Types ¶
type ApplyPatchChange ¶
type ApplyPatchChange struct {
Path string `json:"path"`
Operation string `json:"operation"` // add|delete|update
OldContent string `json:"oldContent,omitempty"`
NewContent string `json:"newContent,omitempty"`
UnifiedDiff string `json:"unifiedDiff,omitempty"`
MovePath string `json:"movePath,omitempty"`
}
ApplyPatchChange describes one file-level change from an apply_patch invocation.
type ApplyPatchInput ¶
type ApplyPatchInput struct {
Input string `json:"input" jsonschema:"description=The entire contents of the apply_patch command"`
}
ApplyPatchInput defines the JSON input for the apply_patch tool.
type ApplyPatchMetadata ¶
type ApplyPatchMetadata struct {
Changes []ApplyPatchChange `json:"changes"`
}
ApplyPatchMetadata contains metadata about an apply_patch operation.
func (ApplyPatchMetadata) ToolType ¶
func (m ApplyPatchMetadata) ToolType() string
ToolType returns the tool type identifier for apply_patch operations.
type ArtifactResolver ¶
type ArtifactResolver func(context.Context, string) (ToolAttachment, error)
ArtifactResolver authorizes an image reference against the current tool's conversation. It returns metadata only; image bytes are materialized by the control plane.
func ArtifactResolverFromContext ¶
func ArtifactResolverFromContext(ctx context.Context) ArtifactResolver
ArtifactResolverFromContext returns the resolver for this tool execution, if available.
type BaseToolResult ¶
type BaseToolResult struct {
Result string `json:"result"`
Error string `json:"error"`
FailureKind string `json:"-"`
FailureOutcome string `json:"-"`
}
BaseToolResult provides a basic implementation of the ToolResult interface
func (BaseToolResult) AssistantFacing ¶
func (t BaseToolResult) AssistantFacing() string
AssistantFacing returns a formatted string representation of the result for the LLM
func (BaseToolResult) GetError ¶
func (t BaseToolResult) GetError() string
GetError returns the error message if any
func (BaseToolResult) GetResult ¶
func (t BaseToolResult) GetResult() string
GetResult returns the result string
func (BaseToolResult) IsError ¶
func (t BaseToolResult) IsError() bool
IsError returns true if the tool execution resulted in an error
func (BaseToolResult) StructuredData ¶
func (t BaseToolResult) StructuredData() StructuredToolResult
StructuredData returns a structured representation of the tool result
func (BaseToolResult) ToolFailure ¶
func (t BaseToolResult) ToolFailure() (string, string)
ToolFailure returns execution provenance that result hooks cannot change.
type BashInput ¶
type BashInput struct {
Description string `json:"description" jsonschema:"description=A description of the command to run"`
Command string `json:"command" jsonschema:"description=The bash command to run"`
Timeout int `json:"timeout" jsonschema:"description=Timeout in seconds"`
}
BashInput defines the input parameters for the bash tool.
type BashMetadata ¶
type BashMetadata struct {
Command string `json:"command"`
ExitCode int `json:"exitCode"`
Output string `json:"output"`
ExecutionTime time.Duration `json:"executionTime"`
WorkingDir string `json:"workingDir,omitempty"`
Truncation *BashOutputTruncation `json:"truncation,omitempty"`
FullOutputPath string `json:"fullOutputPath,omitempty"`
}
BashMetadata contains metadata about a bash command execution
func (BashMetadata) ToolType ¶
func (m BashMetadata) ToolType() string
ToolType returns the tool type identifier for bash command execution
type BashOutputTruncation ¶
type BashOutputTruncation struct {
Truncated bool `json:"truncated"`
TotalLines int `json:"totalLines"`
TotalBytes int64 `json:"totalBytes"`
MaxBytes int `json:"maxBytes"`
}
BashOutputTruncation describes output omitted from the model-facing snapshot.
type BlockedMetadata ¶
BlockedMetadata contains metadata about a blocked tool invocation
func (BlockedMetadata) ToolType ¶
func (m BlockedMetadata) ToolType() string
ToolType returns the tool type identifier for blocked tools
type BlockedToolResult ¶
BlockedToolResult represents a tool that was blocked by an extension policy.
func NewBlockedToolResult ¶
func NewBlockedToolResult(toolName, reason string) BlockedToolResult
NewBlockedToolResult creates a new BlockedToolResult with the given tool name and reason
func (BlockedToolResult) AssistantFacing ¶
func (t BlockedToolResult) AssistantFacing() string
AssistantFacing returns a formatted string representation of the blocked result for the LLM
func (BlockedToolResult) GetError ¶
func (t BlockedToolResult) GetError() string
GetError returns the blocked reason as an error message
func (BlockedToolResult) GetResult ¶
func (t BlockedToolResult) GetResult() string
GetResult returns an empty string as blocked tools have no result
func (BlockedToolResult) IsError ¶
func (t BlockedToolResult) IsError() bool
IsError returns true as blocked tools are treated as errors
func (BlockedToolResult) StructuredData ¶
func (t BlockedToolResult) StructuredData() StructuredToolResult
StructuredData returns a structured representation of the blocked tool result
type BrowserMetadata ¶
type BrowserMetadata struct {
Action string `json:"action"`
URL string `json:"url,omitempty"`
Expression string `json:"expression,omitempty"`
Path string `json:"path,omitempty"`
SessionID string `json:"sessionId,omitempty"`
Output string `json:"output,omitempty"`
}
BrowserMetadata retains the browser action and its displayable input and output. Screenshots use StructuredToolResult.Attachments rather than embedding image data.
func (BrowserMetadata) ToolType ¶
func (m BrowserMetadata) ToolType() string
ToolType returns the tool type identifier for browser operations.
type CodeExecutionCall ¶
type CodeExecutionCall struct {
CallID string `json:"callId"`
ToolName string `json:"toolName"`
Status string `json:"status"`
DurationMs int64 `json:"durationMs"`
ErrorKind string `json:"errorKind,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
Result *StructuredToolResult `json:"result,omitempty"`
DetailsOmitted bool `json:"detailsOmitted,omitempty"`
}
CodeExecutionCall describes one child, with bounded live or final details for the UI.
type CodeExecutionMetadata ¶
type CodeExecutionMetadata struct {
Status string `json:"status"`
DurationMs int64 `json:"durationMs"`
Outputs []json.RawMessage `json:"outputs,omitempty"` // Legacy text/JSON snapshots.
Items []CodeExecutionOutput `json:"items,omitempty"`
Calls []CodeExecutionCall `json:"calls"`
}
CodeExecutionMetadata is the persisted parent snapshot of a code invocation. Child details are UI-only; model output contains only explicit selections.
func (CodeExecutionMetadata) ToolType ¶
func (CodeExecutionMetadata) ToolType() string
ToolType identifies the code execution result renderer.
type CodeExecutionOutput ¶
type CodeExecutionOutput struct {
Type string `json:"type"`
Value json.RawMessage `json:"value,omitempty"`
ArtifactID string `json:"artifactId,omitempty"`
Detail string `json:"detail,omitempty"`
}
CodeExecutionOutput distinguishes explicit media selections from ordinary JSON. Binary image data is stored separately, never in code execution metadata.
type CodeModeDescriber ¶
type CodeModeDescriber interface {
CodeModeDescription() string
}
CodeModeDescriber explains a tool's code-mode reply, such as which envelope field carries its output. Runners append it to the tool's description only when code mode is negotiated, so other sessions do not carry it.
type CodeSearchInput ¶
type CodeSearchInput struct {
Pattern string `` /* 127-byte string literal not displayed */
Path string `` /* 203-byte string literal not displayed */
Include string `` /* 166-byte string literal not displayed */
IgnoreCase bool `` /* 180-byte string literal not displayed */
FixedStrings bool `` /* 144-byte string literal not displayed */
SurroundLines int `` /* 151-byte string literal not displayed */
MaxResults int `` /* 171-byte string literal not displayed */
}
CodeSearchInput defines the input parameters for the grep_tool.
type Edit ¶
type Edit struct {
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
OldContent string `json:"oldContent"`
NewContent string `json:"newContent"`
}
Edit represents a single text replacement in a file
type ExtensionToolMetadata ¶
type ExtensionToolMetadata struct {
ExtensionID string `json:"extensionId"`
ToolName string `json:"toolName"`
Output string `json:"output"`
Truncated bool `json:"truncated,omitempty"`
Data map[string]any `json:"data,omitempty"`
ExecutionTime time.Duration `json:"executionTime"`
}
ExtensionToolMetadata contains metadata about an extension tool execution.
func (ExtensionToolMetadata) ToolType ¶
func (m ExtensionToolMetadata) ToolType() string
ToolType returns the tool type identifier for extension tool execution.
type ExtensionToolPresentation ¶
type ExtensionToolPresentation struct {
Summary string `json:"summary"`
Body string `json:"body,omitempty"`
Format string `json:"format,omitempty"`
// contains filtered or unexported fields
}
ExtensionToolPresentation controls the generic user-facing rendering of an extension result.
func ParseExtensionToolPresentation ¶
func ParseExtensionToolPresentation(raw any) (ExtensionToolPresentation, bool)
ParseExtensionToolPresentation validates and normalizes a presentation payload.
func (ExtensionToolPresentation) HasBody ¶
func (p ExtensionToolPresentation) HasBody() bool
HasBody reports whether the presentation explicitly supplied expanded content.
func (ExtensionToolPresentation) Valid ¶
func (p ExtensionToolPresentation) Valid() bool
Valid reports whether an extension presentation can be rendered safely.
type FileEditInput ¶
type FileEditInput struct {
FilePath string `json:"file_path" jsonschema:"description=The absolute path of the file to edit"`
OldText string `json:"old_text" jsonschema:"description=The text to be replaced"`
NewText string `json:"new_text" jsonschema:"description=The text to replace the old text with"`
ReplaceAll bool `` /* 161-byte string literal not displayed */
}
FileEditInput defines the input parameters for the file_edit tool.
type FileEditMetadata ¶
type FileEditMetadata struct {
FilePath string `json:"filePath"`
Edits []Edit `json:"edits"`
Language string `json:"language,omitempty"`
ReplaceAll bool `json:"replaceAll,omitempty"`
ReplacedCount int `json:"replacedCount,omitempty"`
UnifiedDiff string `json:"unifiedDiff,omitempty"`
}
FileEditMetadata contains metadata about a file edit operation
func (FileEditMetadata) ToolType ¶
func (m FileEditMetadata) ToolType() string
ToolType returns the tool type identifier for file edit operations
type FileInfo ¶
type FileInfo struct {
Path string `json:"path"`
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
Type string `json:"type"` // "file" or "directory"
Language string `json:"language,omitempty"`
}
FileInfo represents information about a matched file
type FileReadInput ¶
type FileReadInput struct {
FilePath string `json:"file_path" jsonschema:"description=The absolute path of the file to read"`
Offset int `json:"offset,omitempty" jsonschema:"default=1,description=The 1-indexed line number to start reading from. Default: 1"`
LineLimit int `` /* 143-byte string literal not displayed */
}
FileReadInput defines the input parameters for the file_read tool.
type FileReadMetadata ¶
type FileReadMetadata struct {
FilePath string `json:"filePath"`
Offset int `json:"offset"`
LineLimit int `json:"lineLimit"`
Lines []string `json:"lines"`
Language string `json:"language,omitempty"`
Truncated bool `json:"truncated"`
RemainingLines int `json:"remainingLines,omitempty"`
}
FileReadMetadata contains metadata about a file read operation
func (FileReadMetadata) ToolType ¶
func (m FileReadMetadata) ToolType() string
ToolType returns the tool type identifier for file read operations
type FileWriteInput ¶
type FileWriteInput struct {
FilePath string `json:"file_path" jsonschema:"description=The absolute path of the file to write,required"`
Text string `json:"text" jsonschema:"description=The text of the file MUST BE provided"`
}
FileWriteInput defines the input parameters for the file_write tool.
type FileWriteMetadata ¶
type FileWriteMetadata struct {
FilePath string `json:"filePath"`
Content string `json:"content"`
Size int64 `json:"size"`
Language string `json:"language,omitempty"`
UnifiedDiff string `json:"unifiedDiff,omitempty"`
}
FileWriteMetadata contains metadata about a file write operation
func (FileWriteMetadata) ToolType ¶
func (m FileWriteMetadata) ToolType() string
ToolType returns the tool type identifier for file write operations
type GlobInput ¶
type GlobInput struct {
Pattern string `json:"pattern" jsonschema:"description=The glob pattern"`
Path string `` /* 166-byte string literal not displayed */
IgnoreGitignore bool `` /* 167-byte string literal not displayed */
}
GlobInput defines the input parameters for the glob_tool.
type GlobMetadata ¶
type GlobMetadata struct {
Pattern string `json:"pattern"`
Path string `json:"path,omitempty"`
Files []FileInfo `json:"files"`
Truncated bool `json:"truncated"`
}
GlobMetadata contains metadata about a glob pattern match operation
func (GlobMetadata) ToolType ¶
func (m GlobMetadata) ToolType() string
ToolType returns the tool type identifier for glob operations
type GrepMetadata ¶
type GrepMetadata struct {
Pattern string `json:"pattern"`
Path string `json:"path,omitempty"`
Include string `json:"include,omitempty"`
Results []SearchResult `json:"results"`
Truncated bool `json:"truncated"`
TruncationReason string `json:"truncationReason,omitempty"`
MaxResults int `json:"maxResults,omitempty"`
}
GrepMetadata contains metadata about a grep search operation
func (GrepMetadata) ToolType ¶
func (m GrepMetadata) ToolType() string
ToolType returns the tool type identifier for grep operations
type ImageDimensions ¶
ImageDimensions represents the dimensions of an image
type ModelHelper ¶
type ModelHelper func(context.Context, ModelHelperRequest) (string, error)
ModelHelper is an explicitly installed internal utility, not a client API.
func ModelHelperFromContext ¶
func ModelHelperFromContext(ctx context.Context) ModelHelper
ModelHelperFromContext returns the capability, if the tool's host installed it.
type ModelHelperRequest ¶
type ModelHelperRequest struct {
Operation string `json:"operation"`
URL string `json:"url"`
Content string `json:"content"`
Prompt string `json:"prompt"`
}
ModelHelperRequest supplies a document for an internal model utility. It accepts no configuration, paths, or persistence mode.
func (ModelHelperRequest) Validate ¶
func (r ModelHelperRequest) Validate() error
Validate rejects unsupported operations and bounds input below the RPC limit.
type ModelOnlyTool ¶
type ModelOnlyTool interface {
ModelOnly() bool
}
ModelOnlyTool marks a tool whose result is meant for the model's own context, such as skill instructions. Code mode declares such a tool to the model directly in every mode, and code-execution scripts can never call it.
type MultiModalToolResult ¶
type MultiModalToolResult interface {
ContentParts() []ToolResultContentPart
}
MultiModalToolResult is implemented by tool results that can provide structured multimodal content beyond the plain AssistantFacing text representation.
type OpenAIWebSearchMetadata ¶
type OpenAIWebSearchMetadata struct {
CallID string `json:"callId"`
Status string `json:"status"`
Action string `json:"action"`
Queries []string `json:"queries,omitempty"`
Sources []string `json:"sources,omitempty"`
Results []string `json:"results,omitempty"`
URL string `json:"url,omitempty"`
Pattern string `json:"pattern,omitempty"`
}
OpenAIWebSearchMetadata contains metadata about a native OpenAI web search operation.
func (OpenAIWebSearchMetadata) ToolType ¶
func (m OpenAIWebSearchMetadata) ToolType() string
ToolType returns the tool type identifier for native OpenAI web search operations.
type RawInputSchemaProvider ¶
RawInputSchemaProvider lets tools preserve JSON Schema constructs that the typed jsonschema representation cannot express.
type RawOutputSchemaProvider ¶
RawOutputSchemaProvider describes the canonical StructuredToolResult.Data value. Tools without a machine-readable result need not implement this interface.
type ReadConversationInput ¶
type ReadConversationInput struct {
ConversationID string `json:"conversation_id" jsonschema:"description=The ID of the saved conversation to read"`
Goal string `json:"goal" jsonschema:"description=What information to extract from the conversation"`
}
ReadConversationInput defines the input parameters for the read_conversation tool.
type ReadConversationMetadata ¶
type ReadConversationMetadata struct {
ConversationID string `json:"conversationID"`
Goal string `json:"goal"`
Content string `json:"content"`
}
ReadConversationMetadata contains metadata about a read_conversation operation.
func (ReadConversationMetadata) ToolType ¶
func (m ReadConversationMetadata) ToolType() string
ToolType returns the tool type identifier for read_conversation operations.
type SearchMatch ¶
type SearchMatch struct {
LineNumber int `json:"lineNumber"`
Content string `json:"content"`
MatchStart int `json:"matchStart"`
MatchEnd int `json:"matchEnd"`
IsContext bool `json:"isContext,omitempty"`
}
SearchMatch represents a single match in a search result
type SearchResult ¶
type SearchResult struct {
FilePath string `json:"filePath"`
Language string `json:"language,omitempty"`
Matches []SearchMatch `json:"matches"`
}
SearchResult represents the search results for a single file
type ShortDescriber ¶
type ShortDescriber interface {
Short() string
}
ShortDescriber supplies a one-line summary for compact tool listings, such as the code-mode tool index. Tools without one fall back to the first sentence of their description.
type SkillMetadata ¶
type SkillMetadata struct {
SkillName string `json:"skillName"`
Directory string `json:"directory"`
}
SkillMetadata contains metadata about a skill invocation
func (SkillMetadata) ToolType ¶
func (m SkillMetadata) ToolType() string
ToolType returns the tool type identifier for skill operations
type State ¶
type State interface {
BasicTools() []Tool
Tools() []Tool
// Context discovery
DiscoverContexts() map[string]string
// LLM configuration access
GetLLMConfig() any // Returns llmtypes.Config but using any to avoid circular import
WorkingDirectory() string
// File locking for atomic operations
// LockFile acquires an exclusive lock for the given file path to prevent race conditions
// during read-modify-write operations. Must be paired with UnlockFile.
LockFile(path string)
// UnlockFile releases the lock for the given file path
UnlockFile(path string)
}
State defines the interface for managing tool execution state and context
type StreamingTool ¶
type StreamingTool interface {
Tool
ExecuteStreaming(ctx context.Context, state State, parameters string, onUpdate ToolUpdateCallback) ToolResult
}
StreamingTool is optionally implemented by tools that can report transient result snapshots during execution. Only the final return value is persisted or sent back to the model.
type StructuredToolResult ¶
type StructuredToolResult struct {
ToolName string `json:"toolName"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Data any `json:"data,omitempty"`
Metadata ToolMetadata `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
Attachments []ToolAttachment `json:"attachments,omitempty"`
}
StructuredToolResult represents a tool's execution result with structured metadata
func (StructuredToolResult) MarshalJSON ¶
func (s StructuredToolResult) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for StructuredToolResult
func (*StructuredToolResult) UnmarshalJSON ¶
func (s *StructuredToolResult) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for StructuredToolResult
type TaskRunActivity ¶
type TaskRunActivity struct {
ID string `json:"id"`
Sequence int `json:"sequence"`
Kind string `json:"kind"`
Label string `json:"label"`
Detail string `json:"detail,omitempty"`
Status string `json:"status"`
Preview string `json:"preview,omitempty"`
}
TaskRunActivity describes one visible task activity.
type TaskRunCounts ¶
type TaskRunCounts struct {
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
Running int `json:"running"`
}
TaskRunCounts contains observed activity counts by state.
func (TaskRunCounts) Total ¶
func (c TaskRunCounts) Total() int
Total returns the number of activities observed so far.
type TaskRunSnapshot ¶
type TaskRunSnapshot struct {
Version int `json:"version"`
Revision int `json:"revision"`
Kind string `json:"kind"`
Status string `json:"status"`
Phase string `json:"phase"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Task string `json:"task,omitempty"`
CWD string `json:"cwd,omitempty"`
ElapsedMS int64 `json:"elapsedMs"`
Counts TaskRunCounts `json:"counts"`
Activities []TaskRunActivity `json:"activities"`
OmittedSucceeded int `json:"omittedSucceeded,omitempty"`
OmittedFailed int `json:"omittedFailed,omitempty"`
OmittedRunning int `json:"omittedRunning,omitempty"`
}
TaskRunSnapshot is a bounded accumulated view of a long-running task.
func (TaskRunSnapshot) Valid ¶
func (s TaskRunSnapshot) Valid() bool
Valid reports whether a task-run snapshot can be rendered safely.
type Tool ¶
type Tool interface {
GenerateSchema() *jsonschema.Schema
Name() string
Description() string
ValidateInput(state State, parameters string) error
Execute(ctx context.Context, state State, parameters string) ToolResult
TracingKVs(parameters string) ([]attribute.KeyValue, error)
}
Tool defines the interface for all kodelet tools
type ToolAttachment ¶
type ToolAttachment struct {
Type string `json:"type"`
Path string `json:"path,omitempty"`
Data string `json:"data,omitempty"`
ArtifactID string `json:"artifactId,omitempty"`
ShortCode string `json:"shortCode,omitempty"`
ViewURL string `json:"viewUrl,omitempty"`
Filename string `json:"filename,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Alt string `json:"alt,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Size int64 `json:"size,omitempty"`
Error string `json:"error,omitempty"`
}
ToolAttachment declares a runner-local output or references an ingested artifact. Exactly one of Path or base64 Data is consumed during ingestion; ArtifactID and ShortCode are assigned by the control plane. ViewURL is presentation-only and is not persisted with history.
type ToolFailureProvider ¶
type ToolFailureProvider interface {
ToolFailure() (kind, outcome string)
}
ToolFailureProvider records host-known execution failures independently of hook-editable display metadata. Empty fields mean no additional provenance.
type ToolGroupProvider ¶
type ToolGroupProvider interface {
ToolGroup() string
}
ToolGroupProvider supplies recorded provenance for tool catalog grouping.
type ToolMetadata ¶
type ToolMetadata interface {
ToolType() string
}
ToolMetadata is a marker interface for tool-specific metadata structures
type ToolResult ¶
type ToolResult interface {
AssistantFacing() string
IsError() bool
GetError() string // xxx: to be removed
GetResult() string // xxx: to be removed
StructuredData() StructuredToolResult
}
ToolResult represents the outcome of a tool execution
type ToolResultContentPart ¶
type ToolResultContentPart struct {
Type ToolResultContentPartType `json:"type"`
Text string `json:"text,omitempty"`
ImageURL string `json:"image_url,omitempty"`
ArtifactID string `json:"artifactId,omitempty"`
MimeType string `json:"mime_type,omitempty"`
Detail string `json:"detail,omitempty"`
}
ToolResultContentPart describes one rich content block attached to a tool result. Providers can translate these parts into their native multimodal message formats.
type ToolResultContentPartType ¶
type ToolResultContentPartType string
ToolResultContentPartType enumerates rich tool result content block types.
const ( // ToolResultContentPartTypeText represents plain text tool result content. ToolResultContentPartTypeText ToolResultContentPartType = "text" // ToolResultContentPartTypeImage represents image tool result content. ToolResultContentPartTypeImage ToolResultContentPartType = "image" )
type ToolUpdateCallback ¶
type ToolUpdateCallback func(ToolResult)
ToolUpdateCallback receives the latest accumulated result snapshot while a streaming tool is still running.
type ViewImageMetadata ¶
type ViewImageMetadata struct {
Path string `json:"path"`
ArtifactID string `json:"artifactId,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Detail string `json:"detail,omitempty"`
ImageSize ImageDimensions `json:"imageSize,omitempty"`
}
ViewImageMetadata contains metadata about a view_image operation.
func (ViewImageMetadata) ToolType ¶
func (m ViewImageMetadata) ToolType() string
ToolType returns the tool type identifier for view_image operations.
type WebFetchMetadata ¶
type WebFetchMetadata struct {
URL string `json:"url"`
ContentType string `json:"contentType"`
Size int64 `json:"size"`
SavedPath string `json:"savedPath,omitempty"`
Prompt string `json:"prompt,omitempty"`
ProcessedType string `json:"processedType"` // "saved", "markdown", "ai_extracted"
Content string `json:"content"` // The actual fetched content
}
WebFetchMetadata contains metadata about a web fetch operation
func (WebFetchMetadata) ToolType ¶
func (m WebFetchMetadata) ToolType() string
ToolType returns the tool type identifier for web fetch operations