tools

package
v0.0.0-...-3bc99eb Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateParams

func ValidateParams(schema, params json.RawMessage) error

ValidateParams performs lightweight JSON schema validation: checks required fields, basic types (string/integer/number/boolean/object/array), and enum values.

func WithApproved

func WithApproved(ctx context.Context) context.Context

WithApproved returns a context that bypasses security approval checks. Only use after the user has explicitly approved the command.

Types

type CronManageTool

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

CronManageTool allows the LLM to manage scheduled jobs.

func NewCronManage

func NewCronManage(sched *scheduler.Scheduler) *CronManageTool

func (*CronManageTool) Description

func (t *CronManageTool) Description() string

func (*CronManageTool) Execute

func (t *CronManageTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*CronManageTool) Name

func (t *CronManageTool) Name() string

func (*CronManageTool) Parameters

func (t *CronManageTool) Parameters() json.RawMessage

type DNATools

type DNATools struct {
	ShellExec *ShellExecTool
	FileRead  *FileReadTool
	FileWrite *FileWriteTool
	FileEdit  *FileEditTool
	WebRead   *WebReadTool
}

DNATools holds references to built-in tools that need security wiring.

func RegisterDNATools

func RegisterDNATools(r *Registry) *DNATools

RegisterDNATools registers all built-in (DNA) tools into the registry. Returns a DNATools struct so security can be wired to all tools that need it.

type FileEditTool

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

func NewFileEdit

func NewFileEdit() *FileEditTool

func (*FileEditTool) Description

func (t *FileEditTool) Description() string

func (*FileEditTool) Execute

func (t *FileEditTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*FileEditTool) Name

func (t *FileEditTool) Name() string

func (*FileEditTool) Parameters

func (t *FileEditTool) Parameters() json.RawMessage

func (*FileEditTool) SetSecurity

func (t *FileEditTool) SetSecurity(s PathChecker)

type FileReadTool

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

func NewFileRead

func NewFileRead() *FileReadTool

func (*FileReadTool) Description

func (t *FileReadTool) Description() string

func (*FileReadTool) Execute

func (t *FileReadTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*FileReadTool) Name

func (t *FileReadTool) Name() string

func (*FileReadTool) Parameters

func (t *FileReadTool) Parameters() json.RawMessage

func (*FileReadTool) SetSecurity

func (t *FileReadTool) SetSecurity(s PathChecker)

type FileWriteTool

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

func NewFileWrite

func NewFileWrite() *FileWriteTool

func (*FileWriteTool) Description

func (t *FileWriteTool) Description() string

func (*FileWriteTool) Execute

func (t *FileWriteTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*FileWriteTool) Name

func (t *FileWriteTool) Name() string

func (*FileWriteTool) Parameters

func (t *FileWriteTool) Parameters() json.RawMessage

func (*FileWriteTool) SetSecurity

func (t *FileWriteTool) SetSecurity(s PathChecker)

type FindSkillsTool

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

func NewFindSkills

func NewFindSkills(loader *skills.Loader) *FindSkillsTool

func (*FindSkillsTool) Description

func (t *FindSkillsTool) Description() string

func (*FindSkillsTool) Execute

func (t *FindSkillsTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*FindSkillsTool) Name

func (t *FindSkillsTool) Name() string

func (*FindSkillsTool) Parameters

func (t *FindSkillsTool) Parameters() json.RawMessage

type ListTasksTool

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

func NewListTasks

func NewListTasks(spawner SubagentSpawner) *ListTasksTool

func (*ListTasksTool) Description

func (t *ListTasksTool) Description() string

func (*ListTasksTool) Execute

func (*ListTasksTool) Name

func (t *ListTasksTool) Name() string

func (*ListTasksTool) Parameters

func (t *ListTasksTool) Parameters() json.RawMessage

type LogReadTool

type LogReadTool struct{}

func NewLogRead

func NewLogRead() *LogReadTool

func (*LogReadTool) Description

func (t *LogReadTool) Description() string

func (*LogReadTool) Execute

func (t *LogReadTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*LogReadTool) Name

func (t *LogReadTool) Name() string

func (*LogReadTool) Parameters

func (t *LogReadTool) Parameters() json.RawMessage

type MemoryRecallTool

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

func NewMemoryRecall

func NewMemoryRecall(store *memory.Store) *MemoryRecallTool

func (*MemoryRecallTool) Description

func (t *MemoryRecallTool) Description() string

func (*MemoryRecallTool) Execute

func (t *MemoryRecallTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*MemoryRecallTool) Name

func (t *MemoryRecallTool) Name() string

func (*MemoryRecallTool) Parameters

func (t *MemoryRecallTool) Parameters() json.RawMessage

type MemoryStoreTool

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

func NewMemoryStore

func NewMemoryStore(store *memory.Store) *MemoryStoreTool

func (*MemoryStoreTool) Description

func (t *MemoryStoreTool) Description() string

func (*MemoryStoreTool) Execute

func (t *MemoryStoreTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*MemoryStoreTool) Name

func (t *MemoryStoreTool) Name() string

func (*MemoryStoreTool) Parameters

func (t *MemoryStoreTool) Parameters() json.RawMessage

type PathChecker

type PathChecker interface {
	CheckPath(path string) (int, string) // 0=allowed, 1=denied
}

PathChecker validates file paths against security policy.

type ReadSkillTool

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

func NewReadSkill

func NewReadSkill(loader *skills.Loader) *ReadSkillTool

func (*ReadSkillTool) Description

func (t *ReadSkillTool) Description() string

func (*ReadSkillTool) Execute

func (t *ReadSkillTool) Execute(_ context.Context, params json.RawMessage) (ToolResult, error)

func (*ReadSkillTool) Name

func (t *ReadSkillTool) Name() string

func (*ReadSkillTool) Parameters

func (t *ReadSkillTool) Parameters() json.RawMessage

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Count

func (r *Registry) Count() int

func (*Registry) Deregister

func (r *Registry) Deregister(name string)

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, params json.RawMessage) (ToolResult, error)

func (*Registry) Get

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

func (*Registry) Register

func (r *Registry) Register(tool Tool)

func (*Registry) SetDefaultTimeout

func (r *Registry) SetDefaultTimeout(d time.Duration)

SetDefaultTimeout sets the timeout for tool execution.

func (*Registry) SetLogger

func (r *Registry) SetLogger(l *slog.Logger)

SetLogger sets the logger for structured observability logging.

func (*Registry) ToolDefs

func (r *Registry) ToolDefs() []providers.ToolDef

ToolDefs returns sorted tool definitions for provider (sorted for KV cache stability).

type RunSkillTool

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

func NewRunSkill

func NewRunSkill(loader *skills.Loader) *RunSkillTool

func (*RunSkillTool) Description

func (t *RunSkillTool) Description() string

func (*RunSkillTool) Execute

func (t *RunSkillTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*RunSkillTool) Name

func (t *RunSkillTool) Name() string

func (*RunSkillTool) Parameters

func (t *RunSkillTool) Parameters() json.RawMessage

type SecurityChecker

type SecurityChecker interface {
	CheckCommand(command string) (int, string) // 0=allowed, 1=denied, 2=needs_approval
	ScrubCredentials(text string) string
}

type ShellExecTool

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

func NewShellExec

func NewShellExec() *ShellExecTool

func (*ShellExecTool) Description

func (t *ShellExecTool) Description() string

func (*ShellExecTool) Execute

func (t *ShellExecTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*ShellExecTool) Name

func (t *ShellExecTool) Name() string

func (*ShellExecTool) Parameters

func (t *ShellExecTool) Parameters() json.RawMessage

func (*ShellExecTool) SetSecurity

func (t *ShellExecTool) SetSecurity(s SecurityChecker)

type SkillFactoryTool

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

func NewSkillFactory

func NewSkillFactory(loader *skills.Loader) *SkillFactoryTool

func (*SkillFactoryTool) Description

func (t *SkillFactoryTool) Description() string

func (*SkillFactoryTool) Execute

func (t *SkillFactoryTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*SkillFactoryTool) Name

func (t *SkillFactoryTool) Name() string

func (*SkillFactoryTool) Parameters

func (t *SkillFactoryTool) Parameters() json.RawMessage

type SpawnAgentTool

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

func NewSpawnAgent

func NewSpawnAgent(spawner SubagentSpawner) *SpawnAgentTool

func (*SpawnAgentTool) Description

func (t *SpawnAgentTool) Description() string

func (*SpawnAgentTool) Execute

func (t *SpawnAgentTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*SpawnAgentTool) Name

func (t *SpawnAgentTool) Name() string

func (*SpawnAgentTool) Parameters

func (t *SpawnAgentTool) Parameters() json.RawMessage

type SubagentSpawner

type SubagentSpawner interface {
	Spawn(ctx context.Context, description, channel, chatID string) (string, error)
	StopAll() int
	Stop(taskID string) error
	List() []TaskInfo
	Count() int
}

SubagentSpawner is the interface for spawning background tasks. This avoids a circular dependency with the agent package.

type TaskInfo

type TaskInfo struct {
	ID          string    `json:"id"`
	Description string    `json:"description"`
	StartedAt   time.Time `json:"started_at"`
	Running     bool      `json:"running"`
}

TaskInfo is a summary of a background task.

type Tool

type Tool interface {
	Name() string
	Description() string
	Parameters() json.RawMessage
	Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)
}

type ToolResult

type ToolResult struct {
	ToolCallID    string
	ForLLM        string
	ForUser       string
	Silent        bool
	NeedsApproval bool   // If true, the tool execution needs human approval before proceeding
	ApprovalInfo  string // Description of what needs approval
}

type WebReadTool

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

func NewWebRead

func NewWebRead() *WebReadTool

func (*WebReadTool) Description

func (t *WebReadTool) Description() string

func (*WebReadTool) Execute

func (t *WebReadTool) Execute(ctx context.Context, params json.RawMessage) (ToolResult, error)

func (*WebReadTool) Name

func (t *WebReadTool) Name() string

func (*WebReadTool) Parameters

func (t *WebReadTool) Parameters() json.RawMessage

Jump to

Keyboard shortcuts

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