tools

package
v0.0.1-beta1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Browser, Canvas, and Nodes tools (mock implementations)

Edit Tool - precise in-file replacements

Exec Tool - run shell commands

Memory Tool - vector memory tool (FAISS/SQLite)

Package tools - OpenClaw-Go tool invocation framework

Provides exec, read, write, process, edit, memory, web, browser, sessions tools Also provides adapter-based plugin system for dynamic tool loading

Process Tool - manage running processes with optional PTY

Read Tool - read file content

Sessions tools - session management

Tools module - tool invocation framework

Web search and fetch tools

Write Tool - create or overwrite files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectCategory

func DetectCategory(text string) string

func ErrorResult

func ErrorResult(toolName string, err error) map[string]interface{}

ErrorResult returns an error payload

func FindRelevantMemories

func FindRelevantMemories(store *memory.VectorMemoryStore, prompt string, limit int) ([]memory.MemoryResult, error)

FindRelevantMemories to find relevant memories (auto recall)

func FormatMemoriesForContext

func FormatMemoriesForContext(results []memory.MemoryResult) string

Format memories for context injection

func FormatToolResult

func FormatToolResult(toolName string, result interface{}) map[string]interface{}

FormatToolResult formats tool result as a message

func GetBool

func GetBool(args map[string]interface{}, key string) bool

GetBool gets a bool arg

func GetFloat64

func GetFloat64(args map[string]interface{}, key string) float64

GetFloat64 gets a float arg

func GetInt

func GetInt(args map[string]interface{}, key string) int

GetInt gets an int arg

func GetString

func GetString(args map[string]interface{}, key string) string

GetString gets a string arg

func NewAdapterRegistry

func NewAdapterRegistry(workspace string) *adapter.ToolAdapter

NewAdapterRegistry creates a new plugin-based adapter registry This enables dynamic tool loading and plugin support

func ParseArgs

func ParseArgs(argsJSON string) (map[string]interface{}, error)

ParseArgs parses JSON args

func ParseToolCalls

func ParseToolCalls(response map[string]interface{}) []map[string]interface{}

ParseToolCalls parse OpenAI tool_calls response

func RegisterBuiltinWithAdapter

func RegisterBuiltinWithAdapter(a *adapter.ToolAdapter)

RegisterBuiltinWithAdapter registers all built-in tools with the adapter

func ShouldCapture

func ShouldCapture(text string) bool

func Summarize

func Summarize(s string, maxLen int) string

Summarize text (for AI responses)

func Truncate

func Truncate(s string, maxLen int) string

Truncate long text

Types

type AgentsListTool

type AgentsListTool struct{}

Agents List Tool

func NewAgentsListTool

func NewAgentsListTool() *AgentsListTool

func (*AgentsListTool) Description

func (t *AgentsListTool) Description() string

func (*AgentsListTool) Execute

func (t *AgentsListTool) Execute(args map[string]interface{}) (interface{}, error)

func (*AgentsListTool) Name

func (t *AgentsListTool) Name() string

func (*AgentsListTool) Parameters

func (t *AgentsListTool) Parameters() map[string]interface{}

type BrowserTool

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

func NewBrowserTool

func NewBrowserTool() *BrowserTool

func (*BrowserTool) Description

func (t *BrowserTool) Description() string

func (*BrowserTool) Execute

func (t *BrowserTool) Execute(args map[string]interface{}) (interface{}, error)

func (*BrowserTool) Name

func (t *BrowserTool) Name() string

func (*BrowserTool) Parameters

func (t *BrowserTool) Parameters() map[string]interface{}

type CanvasTool

type CanvasTool struct{}

Canvas Tool (mock)

func NewCanvasTool

func NewCanvasTool() *CanvasTool

func (*CanvasTool) Description

func (t *CanvasTool) Description() string

func (*CanvasTool) Execute

func (t *CanvasTool) Execute(args map[string]interface{}) (interface{}, error)

func (*CanvasTool) Name

func (t *CanvasTool) Name() string

func (*CanvasTool) Parameters

func (t *CanvasTool) Parameters() map[string]interface{}

type EditError

type EditError struct {
	Message string
}

func (*EditError) Error

func (e *EditError) Error() string

type EditResult

type EditResult struct {
	Path      string `json:"path"`
	Changed   bool   `json:"changed"`
	MatchInfo string `json:"match_info"`
}

type EditTool

type EditTool struct{}

func (*EditTool) Description

func (t *EditTool) Description() string

func (*EditTool) Execute

func (t *EditTool) Execute(args map[string]interface{}) (interface{}, error)

func (*EditTool) Name

func (t *EditTool) Name() string

func (*EditTool) Parameters

func (t *EditTool) Parameters() map[string]interface{}

type EditToolWrapper

type EditToolWrapper struct{}

func (*EditToolWrapper) Execute

func (w *EditToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*EditToolWrapper) HealthCheck

func (w *EditToolWrapper) HealthCheck() error

func (*EditToolWrapper) Initialize

func (w *EditToolWrapper) Initialize(cfg map[string]interface{}) error

func (*EditToolWrapper) PluginInfo

func (w *EditToolWrapper) PluginInfo() adapter.PluginInfo

func (*EditToolWrapper) Shutdown

func (w *EditToolWrapper) Shutdown() error

type ExecError

type ExecError struct {
	Message  string
	Metadata map[string]interface{}
}

func (*ExecError) Error

func (e *ExecError) Error() string

type ExecResult

type ExecResult struct {
	Command  string `json:"command"`
	Timeout  int    `json:"timeout"`
	Workdir  string `json:"workdir,omitempty"`
	Success  bool   `json:"success"`
	ExitCode int    `json:"exit_code"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	Error    string `json:"error,omitempty"`
}

type ExecTool

type ExecTool struct{}

func (*ExecTool) Description

func (t *ExecTool) Description() string

func (*ExecTool) Execute

func (t *ExecTool) Execute(args map[string]interface{}) (interface{}, error)

func (*ExecTool) Name

func (t *ExecTool) Name() string

func (*ExecTool) Parameters

func (t *ExecTool) Parameters() map[string]interface{}

type ExecToolWrapper

type ExecToolWrapper struct{}

func (*ExecToolWrapper) Execute

func (w *ExecToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*ExecToolWrapper) HealthCheck

func (w *ExecToolWrapper) HealthCheck() error

func (*ExecToolWrapper) Initialize

func (w *ExecToolWrapper) Initialize(cfg map[string]interface{}) error

func (*ExecToolWrapper) PluginInfo

func (w *ExecToolWrapper) PluginInfo() adapter.PluginInfo

func (*ExecToolWrapper) Shutdown

func (w *ExecToolWrapper) Shutdown() error

type MemoryGetTool

type MemoryGetTool struct {
	Store *memory.VectorMemoryStore
}

func NewMemoryGetTool

func NewMemoryGetTool(store *memory.VectorMemoryStore) *MemoryGetTool

func (*MemoryGetTool) Description

func (t *MemoryGetTool) Description() string

func (*MemoryGetTool) Execute

func (t *MemoryGetTool) Execute(args map[string]interface{}) (interface{}, error)

func (*MemoryGetTool) Name

func (t *MemoryGetTool) Name() string

func (*MemoryGetTool) Parameters

func (t *MemoryGetTool) Parameters() map[string]interface{}

type MemorySearchResult

type MemorySearchResult struct {
	Query  string                   `json:"query"`
	Count  int                      `json:"count"`
	Items  []map[string]interface{} `json:"items,omitempty"`
	Result string                   `json:"result"`
}

type MemoryStoreTool

type MemoryStoreTool struct {
	Store *memory.VectorMemoryStore
}

func NewMemoryStoreTool

func NewMemoryStoreTool(store *memory.VectorMemoryStore) *MemoryStoreTool

func (*MemoryStoreTool) Description

func (t *MemoryStoreTool) Description() string

func (*MemoryStoreTool) Execute

func (t *MemoryStoreTool) Execute(args map[string]interface{}) (interface{}, error)

func (*MemoryStoreTool) Name

func (t *MemoryStoreTool) Name() string

func (*MemoryStoreTool) Parameters

func (t *MemoryStoreTool) Parameters() map[string]interface{}

type MemoryTool

type MemoryTool struct {
	Store *memory.VectorMemoryStore
}

func NewMemoryTool

func NewMemoryTool(store *memory.VectorMemoryStore) *MemoryTool

func (*MemoryTool) Description

func (t *MemoryTool) Description() string

func (*MemoryTool) Execute

func (t *MemoryTool) Execute(args map[string]interface{}) (interface{}, error)

func (*MemoryTool) Name

func (t *MemoryTool) Name() string

func (*MemoryTool) Parameters

func (t *MemoryTool) Parameters() map[string]interface{}

type MemoryToolWrapper

type MemoryToolWrapper struct{}

func (*MemoryToolWrapper) Execute

func (w *MemoryToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*MemoryToolWrapper) HealthCheck

func (w *MemoryToolWrapper) HealthCheck() error

func (*MemoryToolWrapper) Initialize

func (w *MemoryToolWrapper) Initialize(cfg map[string]interface{}) error

func (*MemoryToolWrapper) PluginInfo

func (w *MemoryToolWrapper) PluginInfo() adapter.PluginInfo

func (*MemoryToolWrapper) Shutdown

func (w *MemoryToolWrapper) Shutdown() error

type NodesTool

type NodesTool struct{}

Nodes Tool (mock)

func NewNodesTool

func NewNodesTool() *NodesTool

func (*NodesTool) Description

func (t *NodesTool) Description() string

func (*NodesTool) Execute

func (t *NodesTool) Execute(args map[string]interface{}) (interface{}, error)

func (*NodesTool) Name

func (t *NodesTool) Name() string

func (*NodesTool) Parameters

func (t *NodesTool) Parameters() map[string]interface{}

type ProcessInfo

type ProcessInfo struct {
	ID        string
	Cmd       *exec.Cmd
	Buffer    *bytes.Buffer
	Pty       *os.File
	StdinPipe io.WriteCloser
	Mutex     sync.Mutex
	CreatedAt time.Time
}

type ProcessLogResult

type ProcessLogResult struct {
	SessionID string `json:"sessionId"`
	Offset    int    `json:"offset"`
	Content   string `json:"content"`
	Truncated bool   `json:"truncated,omitempty"`
}

type ProcessStartResult

type ProcessStartResult struct {
	SessionID string `json:"sessionId"`
	PID       int    `json:"pid"`
	Command   string `json:"command"`
	Pty       bool   `json:"pty,omitempty"`
	Success   bool   `json:"success"`
}

type ProcessTool

type ProcessTool struct{}

func (*ProcessTool) Description

func (t *ProcessTool) Description() string

func (*ProcessTool) Execute

func (t *ProcessTool) Execute(args map[string]interface{}) (interface{}, error)

func (*ProcessTool) Name

func (t *ProcessTool) Name() string

func (*ProcessTool) Parameters

func (t *ProcessTool) Parameters() map[string]interface{}

type ProcessToolWrapper

type ProcessToolWrapper struct{}

func (*ProcessToolWrapper) Execute

func (w *ProcessToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*ProcessToolWrapper) HealthCheck

func (w *ProcessToolWrapper) HealthCheck() error

func (*ProcessToolWrapper) Initialize

func (w *ProcessToolWrapper) Initialize(cfg map[string]interface{}) error

func (*ProcessToolWrapper) PluginInfo

func (w *ProcessToolWrapper) PluginInfo() adapter.PluginInfo

func (*ProcessToolWrapper) Shutdown

func (w *ProcessToolWrapper) Shutdown() error

type PulseAgentInterface

type PulseAgentInterface interface {
	AddPulseEvent(title string, content string, priority int, channel string) (int64, error)
	GetPulseStatus() (map[string]interface{}, error)
}

PulseAgentInterface defines the interface for pulse functionality

type PulseTool

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

PulseTool allows adding events to the pulse system

func NewPulseTool

func NewPulseTool(a PulseAgentInterface) *PulseTool

NewPulseTool creates a new pulse tool

func (*PulseTool) Description

func (t *PulseTool) Description() string

func (*PulseTool) Execute

func (t *PulseTool) Execute(args map[string]interface{}) (interface{}, error)

func (*PulseTool) Name

func (t *PulseTool) Name() string

func (*PulseTool) Parameters

func (t *PulseTool) Parameters() map[string]interface{}

type ReadError

type ReadError struct {
	Message string
}

func (*ReadError) Error

func (e *ReadError) Error() string

type ReadResult

type ReadResult struct {
	Path     string `json:"path"`
	Size     int    `json:"size"`
	Content  string `json:"content"`
	IsBinary bool   `json:"is_binary"`
	Bytes    []byte `json:"-"`
}

type ReadTool

type ReadTool struct{}

func (*ReadTool) Description

func (t *ReadTool) Description() string

func (*ReadTool) Execute

func (t *ReadTool) Execute(args map[string]interface{}) (interface{}, error)

func (*ReadTool) Name

func (t *ReadTool) Name() string

func (*ReadTool) Parameters

func (t *ReadTool) Parameters() map[string]interface{}

type ReadToolWrapper

type ReadToolWrapper struct{}

func (*ReadToolWrapper) Execute

func (w *ReadToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*ReadToolWrapper) HealthCheck

func (w *ReadToolWrapper) HealthCheck() error

func (*ReadToolWrapper) Initialize

func (w *ReadToolWrapper) Initialize(cfg map[string]interface{}) error

func (*ReadToolWrapper) PluginInfo

func (w *ReadToolWrapper) PluginInfo() adapter.PluginInfo

func (*ReadToolWrapper) Shutdown

func (w *ReadToolWrapper) Shutdown() error

type Registry

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

Registry holds registered tools

func NewDefaultRegistry

func NewDefaultRegistry() *Registry

NewDefaultRegistry creates the default registry and registers all tools

func NewMemoryRegistry

func NewMemoryRegistry(store *memory.VectorMemoryStore) *Registry

NewMemoryRegistry creates a registry with memory store

func NewRegistry

func NewRegistry() *Registry

func (*Registry) CallTool

func (r *Registry) CallTool(name string, args map[string]interface{}) (interface{}, error)

CallTool and return its result

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get returns a tool by name

func (*Registry) GetToolSpecs

func (r *Registry) GetToolSpecs() []map[string]interface{}

GetToolSpecs returns OpenAI-format specs with function wrapper

func (*Registry) List

func (r *Registry) List() []string

List all tools

func (*Registry) Register

func (r *Registry) Register(t Tool)

Register a tool

type SessionStatusTool

type SessionStatusTool struct{}

Session Status Tool

func NewSessionStatusTool

func NewSessionStatusTool() *SessionStatusTool

func (*SessionStatusTool) Description

func (t *SessionStatusTool) Description() string

func (*SessionStatusTool) Execute

func (t *SessionStatusTool) Execute(args map[string]interface{}) (interface{}, error)

func (*SessionStatusTool) Name

func (t *SessionStatusTool) Name() string

func (*SessionStatusTool) Parameters

func (t *SessionStatusTool) Parameters() map[string]interface{}

type SessionsHistoryTool

type SessionsHistoryTool struct{}

Sessions History Tool - fetch history

func NewSessionsHistoryTool

func NewSessionsHistoryTool() *SessionsHistoryTool

func (*SessionsHistoryTool) Description

func (t *SessionsHistoryTool) Description() string

func (*SessionsHistoryTool) Execute

func (t *SessionsHistoryTool) Execute(args map[string]interface{}) (interface{}, error)

func (*SessionsHistoryTool) Name

func (t *SessionsHistoryTool) Name() string

func (*SessionsHistoryTool) Parameters

func (t *SessionsHistoryTool) Parameters() map[string]interface{}

type SessionsListTool

type SessionsListTool struct{}

func NewSessionsListTool

func NewSessionsListTool() *SessionsListTool

func (*SessionsListTool) Description

func (t *SessionsListTool) Description() string

func (*SessionsListTool) Execute

func (t *SessionsListTool) Execute(args map[string]interface{}) (interface{}, error)

func (*SessionsListTool) Name

func (t *SessionsListTool) Name() string

func (*SessionsListTool) Parameters

func (t *SessionsListTool) Parameters() map[string]interface{}

type SessionsSendTool

type SessionsSendTool struct{}

Sessions Send Tool - send message to another session

func NewSessionsSendTool

func NewSessionsSendTool() *SessionsSendTool

func (*SessionsSendTool) Description

func (t *SessionsSendTool) Description() string

func (*SessionsSendTool) Execute

func (t *SessionsSendTool) Execute(args map[string]interface{}) (interface{}, error)

func (*SessionsSendTool) Name

func (t *SessionsSendTool) Name() string

func (*SessionsSendTool) Parameters

func (t *SessionsSendTool) Parameters() map[string]interface{}

type SessionsSpawnTool

type SessionsSpawnTool struct{}

Sessions Spawn Tool - start a sub-session

func NewSessionsSpawnTool

func NewSessionsSpawnTool() *SessionsSpawnTool

func (*SessionsSpawnTool) Description

func (t *SessionsSpawnTool) Description() string

func (*SessionsSpawnTool) Execute

func (t *SessionsSpawnTool) Execute(args map[string]interface{}) (interface{}, error)

func (*SessionsSpawnTool) Name

func (t *SessionsSpawnTool) Name() string

func (*SessionsSpawnTool) Parameters

func (t *SessionsSpawnTool) Parameters() map[string]interface{}

type Tool

type Tool interface {
	Name() string
	Description() string
	Parameters() map[string]interface{}
	Execute(args map[string]interface{}) (interface{}, error)
}

Tool defines the tool interface

type WebFetchTool

type WebFetchTool struct{}

Web Fetch Tool - fetch and extract readable content

func NewWebFetchTool

func NewWebFetchTool() *WebFetchTool

func (*WebFetchTool) Description

func (t *WebFetchTool) Description() string

func (*WebFetchTool) Execute

func (t *WebFetchTool) Execute(args map[string]interface{}) (interface{}, error)

func (*WebFetchTool) Name

func (t *WebFetchTool) Name() string

func (*WebFetchTool) Parameters

func (t *WebFetchTool) Parameters() map[string]interface{}

type WebFetchToolWrapper

type WebFetchToolWrapper struct{}

func (*WebFetchToolWrapper) Execute

func (w *WebFetchToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*WebFetchToolWrapper) HealthCheck

func (w *WebFetchToolWrapper) HealthCheck() error

func (*WebFetchToolWrapper) Initialize

func (w *WebFetchToolWrapper) Initialize(cfg map[string]interface{}) error

func (*WebFetchToolWrapper) PluginInfo

func (w *WebFetchToolWrapper) PluginInfo() adapter.PluginInfo

func (*WebFetchToolWrapper) Shutdown

func (w *WebFetchToolWrapper) Shutdown() error

type WebSearchTool

type WebSearchTool struct{}

func NewWebSearchTool

func NewWebSearchTool() *WebSearchTool

func (*WebSearchTool) Description

func (t *WebSearchTool) Description() string

func (*WebSearchTool) Execute

func (t *WebSearchTool) Execute(args map[string]interface{}) (interface{}, error)

func (*WebSearchTool) Name

func (t *WebSearchTool) Name() string

func (*WebSearchTool) Parameters

func (t *WebSearchTool) Parameters() map[string]interface{}

type WebSearchToolWrapper

type WebSearchToolWrapper struct{}

func (*WebSearchToolWrapper) Execute

func (w *WebSearchToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*WebSearchToolWrapper) HealthCheck

func (w *WebSearchToolWrapper) HealthCheck() error

func (*WebSearchToolWrapper) Initialize

func (w *WebSearchToolWrapper) Initialize(cfg map[string]interface{}) error

func (*WebSearchToolWrapper) PluginInfo

func (w *WebSearchToolWrapper) PluginInfo() adapter.PluginInfo

func (*WebSearchToolWrapper) Shutdown

func (w *WebSearchToolWrapper) Shutdown() error

type WriteError

type WriteError struct {
	Message string
}

func (*WriteError) Error

func (e *WriteError) Error() string

type WriteResult

type WriteResult struct {
	Path    string `json:"path"`
	Bytes   int    `json:"bytes"`
	Append  bool   `json:"append"`
	Created bool   `json:"created,omitempty"`
}

type WriteTool

type WriteTool struct{}

func (*WriteTool) Description

func (t *WriteTool) Description() string

func (*WriteTool) Execute

func (t *WriteTool) Execute(args map[string]interface{}) (interface{}, error)

func (*WriteTool) Name

func (t *WriteTool) Name() string

func (*WriteTool) Parameters

func (t *WriteTool) Parameters() map[string]interface{}

type WriteToolWrapper

type WriteToolWrapper struct{}

func (*WriteToolWrapper) Execute

func (w *WriteToolWrapper) Execute(args map[string]interface{}) (interface{}, error)

func (*WriteToolWrapper) HealthCheck

func (w *WriteToolWrapper) HealthCheck() error

func (*WriteToolWrapper) Initialize

func (w *WriteToolWrapper) Initialize(cfg map[string]interface{}) error

func (*WriteToolWrapper) PluginInfo

func (w *WriteToolWrapper) PluginInfo() adapter.PluginInfo

func (*WriteToolWrapper) Shutdown

func (w *WriteToolWrapper) Shutdown() error

Directories

Path Synopsis
Package adapter - Tool plugin adapter system Provides plugin-based tool loading with hot-reload support
Package adapter - Tool plugin adapter system Provides plugin-based tool loading with hot-reload support
Package plugin provides plugin utilities for the tool adapter
Package plugin provides plugin utilities for the tool adapter

Jump to

Keyboard shortcuts

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