tools

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tools provides tool execution for the laplaced Telegram bot.

It handles all tool execution for the Laplace agent: - Memory tools: add, update, delete facts - People tools: create, update, delete, merge people - Search tools: search history and people - Model tools: custom LLM calls

The ToolExecutor dispatches tool calls to appropriate handlers and manages access to repositories and services.

Package tools provides tool execution for the laplaced bot. It handles fact management, people management, and search tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFactID

func ParseFactID(v interface{}) (int64, error)

ParseFactID extracts fact ID from string "Fact:123" format or int. Prefers "Fact:123" format, falls back to numeric for backward compatibility.

func ParsePersonID

func ParsePersonID(v interface{}) (int64, error)

ParsePersonID extracts person ID from string "Person:123" format or int. Prefers "Person:123" format, falls back to numeric for backward compatibility.

Types

type MemoryOpParams

type MemoryOpParams struct {
	Action     string
	Content    string
	Category   string
	FactType   string
	Reason     string
	Importance int
	FactID     int64
}

MemoryOpParams holds parsed parameters for a memory operation.

func ParseMemoryOpParams

func ParseMemoryOpParams(params map[string]interface{}) (MemoryOpParams, error)

ParseMemoryOpParams extracts operation parameters from a map. Returns error if fact_id is provided but invalid.

type ToolExecutor

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

ToolExecutor handles tool execution for the bot. It dispatches tool calls to appropriate handlers and manages access to repositories and services.

func NewToolExecutor

func NewToolExecutor(
	orClient openrouter.Client,
	factRepo storage.FactRepository,
	factHistoryRepo storage.FactHistoryRepository,
	cfg *config.Config,
	logger *slog.Logger,
) *ToolExecutor

NewToolExecutor creates a new ToolExecutor with required dependencies.

func (*ToolExecutor) ExecuteToolCall

func (e *ToolExecutor) ExecuteToolCall(ctx context.Context, userID int64, toolName string, arguments string) (string, error)

ExecuteToolCall dispatches tool execution by name.

func (*ToolExecutor) SetAgentLogger

func (e *ToolExecutor) SetAgentLogger(logger *agentlog.Logger)

SetAgentLogger sets the optional agent logger for Scout logging.

func (*ToolExecutor) SetPeopleRepository

func (e *ToolExecutor) SetPeopleRepository(repo storage.PeopleRepository)

SetPeopleRepository sets the optional people repository.

func (*ToolExecutor) SetRAGService

func (e *ToolExecutor) SetRAGService(svc *rag.Service)

SetRAGService sets the optional RAG service for search tools.

Jump to

Keyboard shortcuts

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