tools

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolToSchema

func ToolToSchema(tool Tool) map[string]interface{}

Types

type AppendFileTool

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

func NewAppendFileTool

func NewAppendFileTool(workspace string, restrict bool) *AppendFileTool

func (*AppendFileTool) Description

func (t *AppendFileTool) Description() string

func (*AppendFileTool) Execute

func (t *AppendFileTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*AppendFileTool) Name

func (t *AppendFileTool) Name() string

func (*AppendFileTool) Parameters

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

type ContextualTool added in v0.1.1

type ContextualTool interface {
	Tool
	SetContext(channel, chatID string)
}

ContextualTool is an optional interface that tools can implement to receive the current message context (channel, chatID)

type CronTool added in v0.1.1

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

CronTool provides scheduling capabilities for the agent

func NewCronTool added in v0.1.1

func NewCronTool(cronService *cron.CronService, executor JobExecutor, msgBus *bus.MessageBus, workspace string) *CronTool

NewCronTool creates a new CronTool

func (*CronTool) Description added in v0.1.1

func (t *CronTool) Description() string

Description returns the tool description

func (*CronTool) Execute added in v0.1.1

func (t *CronTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

Execute runs the tool with given arguments

func (*CronTool) ExecuteJob added in v0.1.1

func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string

ExecuteJob executes a cron job through the agent

func (*CronTool) Name added in v0.1.1

func (t *CronTool) Name() string

Name returns the tool name

func (*CronTool) Parameters added in v0.1.1

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

Parameters returns the tool parameters schema

func (*CronTool) SetContext added in v0.1.1

func (t *CronTool) SetContext(channel, chatID string)

SetContext sets the current session context for job creation

type EditFileTool

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

EditFileTool edits a file by replacing old_text with new_text. The old_text must exist exactly in the file.

func NewEditFileTool

func NewEditFileTool(allowedDir string, restrict bool) *EditFileTool

NewEditFileTool creates a new EditFileTool with optional directory restriction.

func (*EditFileTool) Description

func (t *EditFileTool) Description() string

func (*EditFileTool) Execute

func (t *EditFileTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*EditFileTool) Name

func (t *EditFileTool) Name() string

func (*EditFileTool) Parameters

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

type ExecTool

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

func NewExecTool

func NewExecTool(workingDir string, restrict bool) *ExecTool

func (*ExecTool) Description

func (t *ExecTool) Description() string

func (*ExecTool) Execute

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

func (*ExecTool) Name

func (t *ExecTool) Name() string

func (*ExecTool) Parameters

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

func (*ExecTool) SetAllowPatterns

func (t *ExecTool) SetAllowPatterns(patterns []string) error

func (*ExecTool) SetRestrictToWorkspace

func (t *ExecTool) SetRestrictToWorkspace(restrict bool)

func (*ExecTool) SetTimeout

func (t *ExecTool) SetTimeout(timeout time.Duration)

type FunctionCall

type FunctionCall struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type JobExecutor added in v0.1.1

type JobExecutor interface {
	ProcessDirectWithChannel(ctx context.Context, content, sessionKey, channel, chatID string) (string, error)
}

JobExecutor is the interface for executing cron jobs through the agent

type LLMProvider

type LLMProvider interface {
	Chat(ctx context.Context, messages []Message, tools []ToolDefinition, model string, options map[string]interface{}) (*LLMResponse, error)
	GetDefaultModel() string
}

type LLMResponse

type LLMResponse struct {
	Content      string     `json:"content"`
	ToolCalls    []ToolCall `json:"tool_calls,omitempty"`
	FinishReason string     `json:"finish_reason"`
	Usage        *UsageInfo `json:"usage,omitempty"`
}

type ListDirTool

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

func NewListDirTool added in v0.1.1

func NewListDirTool(workspace string, restrict bool) *ListDirTool

func (*ListDirTool) Description

func (t *ListDirTool) Description() string

func (*ListDirTool) Execute

func (t *ListDirTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*ListDirTool) Name

func (t *ListDirTool) Name() string

func (*ListDirTool) Parameters

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

type Message

type Message struct {
	Role       string     `json:"role"`
	Content    string     `json:"content"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string     `json:"tool_call_id,omitempty"`
}

type MessageTool

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

func NewMessageTool

func NewMessageTool() *MessageTool

func (*MessageTool) Description

func (t *MessageTool) Description() string

func (*MessageTool) Execute

func (t *MessageTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*MessageTool) Name

func (t *MessageTool) Name() string

func (*MessageTool) Parameters

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

func (*MessageTool) SetContext

func (t *MessageTool) SetContext(channel, chatID string)

func (*MessageTool) SetSendCallback

func (t *MessageTool) SetSendCallback(callback SendCallback)

type ReadFileTool

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

func NewReadFileTool added in v0.1.1

func NewReadFileTool(workspace string, restrict bool) *ReadFileTool

func (*ReadFileTool) Description

func (t *ReadFileTool) Description() string

func (*ReadFileTool) Execute

func (t *ReadFileTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*ReadFileTool) Name

func (t *ReadFileTool) Name() string

func (*ReadFileTool) Parameters

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

type SendCallback

type SendCallback func(channel, chatID, content string) error

type SpawnTool

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

func NewSpawnTool

func NewSpawnTool(manager *SubagentManager) *SpawnTool

func (*SpawnTool) Description

func (t *SpawnTool) Description() string

func (*SpawnTool) Execute

func (t *SpawnTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*SpawnTool) Name

func (t *SpawnTool) Name() string

func (*SpawnTool) Parameters

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

func (*SpawnTool) SetContext

func (t *SpawnTool) SetContext(channel, chatID string)

type SubagentManager

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

func NewSubagentManager

func NewSubagentManager(provider providers.LLMProvider, workspace string, bus *bus.MessageBus) *SubagentManager

func (*SubagentManager) GetTask

func (sm *SubagentManager) GetTask(taskID string) (*SubagentTask, bool)

func (*SubagentManager) ListTasks

func (sm *SubagentManager) ListTasks() []*SubagentTask

func (*SubagentManager) Spawn

func (sm *SubagentManager) Spawn(ctx context.Context, task, label, originChannel, originChatID string) (string, error)

type SubagentTask

type SubagentTask struct {
	ID            string
	Task          string
	Label         string
	OriginChannel string
	OriginChatID  string
	Status        string
	Result        string
	Created       int64
}

type Tool

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

type ToolCall

type ToolCall struct {
	ID        string                 `json:"id"`
	Type      string                 `json:"type"`
	Function  *FunctionCall          `json:"function,omitempty"`
	Name      string                 `json:"name,omitempty"`
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

type ToolDefinition

type ToolDefinition struct {
	Type     string                 `json:"type"`
	Function ToolFunctionDefinition `json:"function"`
}

type ToolFunctionDefinition

type ToolFunctionDefinition struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"parameters"`
}

type ToolRegistry

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

func NewToolRegistry

func NewToolRegistry() *ToolRegistry

func (*ToolRegistry) Count added in v0.1.1

func (r *ToolRegistry) Count() int

Count returns the number of registered tools.

func (*ToolRegistry) Execute

func (r *ToolRegistry) Execute(ctx context.Context, name string, args map[string]interface{}) (string, error)

func (*ToolRegistry) ExecuteWithContext added in v0.1.1

func (r *ToolRegistry) ExecuteWithContext(ctx context.Context, name string, args map[string]interface{}, channel, chatID string) (string, error)

func (*ToolRegistry) Get

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

func (*ToolRegistry) GetDefinitions

func (r *ToolRegistry) GetDefinitions() []map[string]interface{}

func (*ToolRegistry) GetSummaries added in v0.1.1

func (r *ToolRegistry) GetSummaries() []string

GetSummaries returns human-readable summaries of all registered tools. Returns a slice of "name - description" strings.

func (*ToolRegistry) List added in v0.1.1

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

List returns a list of all registered tool names.

func (*ToolRegistry) Register

func (r *ToolRegistry) Register(tool Tool)

type UsageInfo

type UsageInfo struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type WebFetchTool

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

func NewWebFetchTool

func NewWebFetchTool(maxChars int) *WebFetchTool

func (*WebFetchTool) Description

func (t *WebFetchTool) Description() string

func (*WebFetchTool) Execute

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

func (*WebFetchTool) Name

func (t *WebFetchTool) Name() string

func (*WebFetchTool) Parameters

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

type WebSearchTool

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

func NewWebSearchTool

func NewWebSearchTool(apiKey string, maxResults int) *WebSearchTool

func (*WebSearchTool) Description

func (t *WebSearchTool) Description() string

func (*WebSearchTool) Execute

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

func (*WebSearchTool) Name

func (t *WebSearchTool) Name() string

func (*WebSearchTool) Parameters

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

type WriteFileTool

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

func NewWriteFileTool added in v0.1.1

func NewWriteFileTool(workspace string, restrict bool) *WriteFileTool

func (*WriteFileTool) Description

func (t *WriteFileTool) Description() string

func (*WriteFileTool) Execute

func (t *WriteFileTool) Execute(ctx context.Context, args map[string]interface{}) (string, error)

func (*WriteFileTool) Name

func (t *WriteFileTool) Name() string

func (*WriteFileTool) Parameters

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

Jump to

Keyboard shortcuts

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