tools

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAppendDiaryTool added in v0.1.4

func NewAppendDiaryTool(workspacePath string) (tool.InvokableTool, error)

func NewAppendFileTool added in v0.3.1

func NewAppendFileTool(workspacePath string) (tool.InvokableTool, error)

NewAppendFileTool creates the append_file tool.

func NewCronTool added in v0.2.0

func NewCronTool(service *cron.Service) (tool.InvokableTool, error)

NewCronTool creates an agent tool for managing cron jobs.

func NewEditFileTool added in v0.3.1

func NewEditFileTool(workspacePath string) (tool.InvokableTool, error)

NewEditFileTool creates the edit_file tool.

func NewExecTool

func NewExecTool(timeoutSec int, restrictToWorkspace bool, workspaceDir string) (tool.InvokableTool, error)

NewExecTool creates the exec tool

func NewListDirTool

func NewListDirTool(workspacePath string) (tool.InvokableTool, error)

NewListDirTool creates the list_dir tool

func NewMessageTool added in v0.3.0

func NewMessageTool(publisher interface {
	PublishOutbound(msg *bus.OutboundMessage)
}) (tool.InvokableTool, error)

NewMessageTool creates a tool that sends a message through the message bus.

func NewReadFileTool

func NewReadFileTool(workspacePath string) (tool.InvokableTool, error)

NewReadFileTool creates the read_file tool

func NewReadMemoryTool added in v0.1.4

func NewReadMemoryTool(workspacePath string) (tool.InvokableTool, error)

func NewSpawnTool added in v0.3.0

func NewSpawnTool(executor SubagentExecutor) (tool.InvokableTool, error)

NewSpawnTool creates an async subagent delegation tool.

func NewSubagentTool added in v0.3.0

func NewSubagentTool(executor SubagentExecutor) (tool.InvokableTool, error)

NewSubagentTool creates a sync subagent delegation tool.

func NewWebFetchTool added in v0.1.4

func NewWebFetchTool() (tool.InvokableTool, error)

func NewWebSearchTool added in v0.1.4

func NewWebSearchTool(apiKey string, maxResults int) (tool.InvokableTool, error)

func NewWorkflowTool added in v0.5.0

func NewWorkflowTool(executor WorkflowExecutor) (tool.InvokableTool, error)

NewWorkflowTool creates a workflow orchestration tool.

func NewWriteFileTool

func NewWriteFileTool(workspacePath string) (tool.InvokableTool, error)

NewWriteFileTool creates the write_file tool

func NewWriteMemoryTool added in v0.1.4

func NewWriteMemoryTool(workspacePath string) (tool.InvokableTool, error)

func WithInvocationContext added in v0.3.0

func WithInvocationContext(ctx context.Context, meta InvocationContext) context.Context

WithInvocationContext stores invocation metadata in context for tools.

Types

type AppendDiaryInput added in v0.1.4

type AppendDiaryInput struct {
	Entry string `json:"entry" jsonschema:"required,description=Diary entry content to append"`
}

type AppendDiaryOutput added in v0.1.4

type AppendDiaryOutput struct {
	DiaryPath string `json:"diary_path"`
}

type AppendFileInput added in v0.3.1

type AppendFileInput struct {
	Path    string `json:"path" jsonschema:"required,description=Absolute path to the file"`
	Content string `json:"content" jsonschema:"required,description=Content to append to file end"`
}

AppendFileInput parameters for append_file tool.

type CronToolInput added in v0.2.0

type CronToolInput struct {
	Action       string `` /* 153-byte string literal not displayed */
	Name         string `json:"name,omitempty" jsonschema:"description=Job name (required for add)"`
	Message      string `json:"message,omitempty" jsonschema:"description=Message to send to agent (required for add)"`
	EverySeconds int64  `json:"every_seconds,omitempty" jsonschema:"description=Repeat interval in seconds (for add with every schedule)"`
	CronExpr     string `json:"cron_expr,omitempty" jsonschema:"description=Cron expression like '0 9 * * *' (for add with cron schedule)"`
	AtTimestamp  string `json:"at_timestamp,omitempty" jsonschema:"description=RFC3339 timestamp for one-shot (for add with at schedule)"`
	JobID        string `json:"job_id,omitempty" jsonschema:"description=Job ID (required for remove/enable/disable)"`
	Deliver      bool   `json:"deliver,omitempty" jsonschema:"description=If true deliver response directly without agent processing"`
}

type EditFileInput added in v0.3.1

type EditFileInput struct {
	Path    string `json:"path" jsonschema:"required,description=Absolute path to the file"`
	OldText string `json:"old_text" jsonschema:"required,description=Exact existing text to replace"`
	NewText string `json:"new_text" jsonschema:"required,description=Replacement text"`
}

EditFileInput parameters for edit_file tool.

type ExecInput

type ExecInput struct {
	Command    string `json:"command" jsonschema:"required,description=Shell command to execute"`
	WorkingDir string `json:"working_dir" jsonschema:"description=Working directory for the command"`
}

ExecInput parameters for exec tool

type ExecOutput

type ExecOutput struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

ExecOutput result of exec tool

type GuardAction added in v0.4.0

type GuardAction string
const (
	GuardAllow           GuardAction = "allow"
	GuardDeny            GuardAction = "deny"
	GuardRequireApproval GuardAction = "require_approval"
)

type GuardFunc added in v0.4.0

type GuardFunc func(ctx context.Context, name, argsJSON string) (GuardResult, error)

type GuardResult added in v0.4.0

type GuardResult struct {
	Action  GuardAction
	Message string
}

type InvocationContext added in v0.3.0

type InvocationContext struct {
	Channel   string
	ChatID    string
	SenderID  string
	RequestID string
	SessionID string
}

InvocationContext carries caller metadata for tool execution.

func InvocationFromContext added in v0.3.0

func InvocationFromContext(ctx context.Context) InvocationContext

InvocationFromContext reads invocation metadata from context.

type ListDirInput

type ListDirInput struct {
	Path string `json:"path" jsonschema:"required,description=Directory path to list"`
}

ListDirInput parameters for list_dir tool

type MessageInput added in v0.3.0

type MessageInput struct {
	Content string `json:"content" jsonschema:"required,description=Message content to send"`
	Channel string `json:"channel,omitempty" jsonschema:"description=Target channel (optional; defaults to current channel)"`
	ChatID  string `json:"chat_id,omitempty" jsonschema:"description=Target chat/session id (optional; defaults to current chat)"`
}

type ReadFileInput

type ReadFileInput struct {
	Path   string `json:"path" jsonschema:"required,description=Absolute path to the file"`
	Offset int    `json:"offset" jsonschema:"description=Starting line number (0-based)"`
	Limit  int    `json:"limit" jsonschema:"description=Maximum number of lines to read"`
}

ReadFileInput parameters for read_file tool

type ReadFileOutput

type ReadFileOutput struct {
	Content    string `json:"content"`
	TotalLines int    `json:"total_lines"`
}

ReadFileOutput result of read_file tool

type ReadMemoryInput added in v0.1.4

type ReadMemoryInput struct{}

type ReadMemoryOutput added in v0.1.4

type ReadMemoryOutput struct {
	Content string `json:"content"`
}

type Registry

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

Registry manages tools by name

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, argsJSON string) (string, error)

Execute runs a tool by name

func (*Registry) Get

func (r *Registry) Get(name string) (tool.InvokableTool, bool)

Get retrieves a tool by name

func (*Registry) GetToolInfos

func (r *Registry) GetToolInfos(ctx context.Context) ([]*schema.ToolInfo, error)

GetToolInfos returns all tool schemas for ChatModel binding

func (*Registry) List

func (r *Registry) List() []tool.InvokableTool

List returns all tools

func (*Registry) Names

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

Names returns all registered tool names

func (*Registry) Register

func (r *Registry) Register(t tool.InvokableTool) error

Register adds a tool to registry

func (*Registry) SetGuard added in v0.4.0

func (r *Registry) SetGuard(fn GuardFunc)

SetGuard sets a pre-execution guard for tool execution.

type SpawnInput added in v0.3.0

type SpawnInput struct {
	Task    string `json:"task" jsonschema:"required,description=Task to delegate to a background subagent"`
	Label   string `json:"label,omitempty" jsonschema:"description=Optional label for task tracking"`
	Channel string `json:"channel,omitempty" jsonschema:"description=Optional origin channel override"`
	ChatID  string `json:"chat_id,omitempty" jsonschema:"description=Optional origin chat id override"`
}

type SubagentExecutor added in v0.3.0

type SubagentExecutor interface {
	Spawn(ctx context.Context, req SubagentRequest) (string, error)
	RunSync(ctx context.Context, req SubagentRequest) (string, error)
}

SubagentExecutor executes delegated subagent tasks.

type SubagentInput added in v0.3.0

type SubagentInput struct {
	Task    string `json:"task" jsonschema:"required,description=Task to execute via a delegated subagent"`
	Label   string `json:"label,omitempty" jsonschema:"description=Optional label for this delegated run"`
	Channel string `json:"channel,omitempty" jsonschema:"description=Optional origin channel override"`
	ChatID  string `json:"chat_id,omitempty" jsonschema:"description=Optional origin chat id override"`
}

type SubagentRequest added in v0.3.0

type SubagentRequest struct {
	Task           string
	Label          string
	OriginChannel  string
	OriginChatID   string
	OriginSenderID string
	RequestID      string
}

SubagentRequest is the normalized execution request for subagent tools.

type WebFetchInput added in v0.1.4

type WebFetchInput struct {
	URL      string `json:"url" jsonschema:"required,description=The target URL to fetch"`
	MaxBytes int    `json:"max_bytes" jsonschema:"description=Optional maximum response bytes to keep"`
}

type WebFetchOutput added in v0.1.4

type WebFetchOutput struct {
	URL         string `json:"url"`
	Status      int    `json:"status"`
	ContentType string `json:"content_type"`
	Content     string `json:"content"`
	Truncated   bool   `json:"truncated"`
}

type WebSearchInput added in v0.1.4

type WebSearchInput struct {
	Query      string `json:"query" jsonschema:"required,description=The search query"`
	MaxResults int    `json:"max_results" jsonschema:"description=Optional per-request result limit"`
}

type WebSearchOutput added in v0.1.4

type WebSearchOutput struct {
	Query   string            `json:"query"`
	Results []WebSearchResult `json:"results"`
}

type WebSearchResult added in v0.1.4

type WebSearchResult struct {
	Title       string `json:"title"`
	URL         string `json:"url"`
	Description string `json:"description"`
}

type WorkflowExecutor added in v0.5.0

type WorkflowExecutor interface {
	RunWorkflow(ctx context.Context, req WorkflowRequest) (string, error)
}

WorkflowExecutor executes delegated subagent workflows.

type WorkflowInput added in v0.5.0

type WorkflowInput struct {
	Goal     string   `json:"goal" jsonschema:"required,description=Overall workflow goal for decomposition and execution"`
	Mode     string   `json:"mode,omitempty" jsonschema:"description=Execution mode: sequential or parallel"`
	Subtasks []string `json:"subtasks,omitempty" jsonschema:"description=Optional predefined subtasks"`
	Label    string   `json:"label,omitempty" jsonschema:"description=Optional workflow label for tracking"`
}

type WorkflowRequest added in v0.5.0

type WorkflowRequest struct {
	Goal           string
	Mode           string
	Subtasks       []string
	Label          string
	OriginChannel  string
	OriginChatID   string
	OriginSenderID string
	RequestID      string
}

WorkflowRequest describes a structured subagent workflow run.

type WriteFileInput

type WriteFileInput struct {
	Path    string `json:"path" jsonschema:"required,description=Absolute path to the file"`
	Content string `json:"content" jsonschema:"required,description=Content to write"`
}

WriteFileInput parameters for write_file tool

type WriteMemoryInput added in v0.1.4

type WriteMemoryInput struct {
	Content string `json:"content" jsonschema:"required,description=Content to store as long-term memory"`
}

Jump to

Keyboard shortcuts

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