- Update all Tool implementations to return *ToolResult instead of (string, error) - ShellTool: returns UserResult for command output, ErrorResult for failures - SpawnTool: returns NewToolResult on success, ErrorResult on failure - WebTool: returns ToolResult with ForUser=content, ForLLM=summary - EditTool: returns SilentResult for silent edits, ErrorResult on failure - FilesystemTool: returns SilentResult/NewToolResult for operations, ErrorResult on failure - Temporarily disable cronTool in main.go (will be re-enabled in US-016) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
670 B
Go
29 lines
670 B
Go
package tools
|
|
|
|
import "context"
|
|
|
|
type Tool interface {
|
|
Name() string
|
|
Description() string
|
|
Parameters() map[string]interface{}
|
|
Execute(ctx context.Context, args map[string]interface{}) *ToolResult
|
|
}
|
|
|
|
// ContextualTool is an optional interface that tools can implement
|
|
// to receive the current message context (channel, chatID)
|
|
type ContextualTool interface {
|
|
Tool
|
|
SetContext(channel, chatID string)
|
|
}
|
|
|
|
func ToolToSchema(tool Tool) map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"type": "function",
|
|
"function": map[string]interface{}{
|
|
"name": tool.Name(),
|
|
"description": tool.Description(),
|
|
"parameters": tool.Parameters(),
|
|
},
|
|
}
|
|
}
|