// Package tools collects tools package tools import ( "context" "fmt" "github.com/ollama/ollama/api" "tipsy.codes/charles/mc-god/v2/internal/pkg/rcon" ) type Tool interface { Do(ctx context.Context, toolCall api.ToolCall, client *rcon.Client) error Desc() api.Tool Name() string } type Tools map[string]Tool func New(tools ...Tool) Tools { ret := make(map[string]Tool) for _, tool := range tools { ret[tool.Name()] = tool } return ret } func (t Tools) AsAPI() api.Tools { var ret api.Tools for _, tool := range t { ret = append(ret, tool.Desc()) } return ret } func (t Tools) Do(ctx context.Context, toolCall api.ToolCall, client *rcon.Client) error { tool, found := t[toolCall.Function.Name] if !found { return fmt.Errorf("unknown tool %q", toolCall.Function.Name) } return tool.Do(ctx, toolCall, client) }