refactor: mover tools a subpackages individuales
Cada tool ahora vive en su propio subpackage dentro de tools/ (clock, file, http, knowledgetools, matrix, memorytools, ssh, weather) en lugar de archivos planos en el paquete raíz tools/. Esto mejora la organización, permite imports selectivos y reduce acoplamiento entre tools. El paquete tools/ raíz conserva los tipos base (Def, Param, Result, ToolFunc, Tool, Registry). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package clock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/enmanuel/agents/tools"
|
||||
)
|
||||
|
||||
// NewCurrentTime creates a current_time tool that returns the current date and time.
|
||||
// Useful for agents that need temporal awareness.
|
||||
func NewCurrentTime() tools.Tool {
|
||||
return tools.Tool{
|
||||
Def: tools.Def{
|
||||
Name: "current_time",
|
||||
Description: "Returns the current date and time in the server's timezone. Use this when you need to know the current time or date.",
|
||||
Parameters: []tools.Param{
|
||||
{Name: "format", Type: "string", Description: "Optional Go time format string. Defaults to RFC3339 if empty.", Required: false},
|
||||
},
|
||||
},
|
||||
Exec: func(ctx context.Context, args map[string]any) tools.Result {
|
||||
layout := tools.GetString(args, "format")
|
||||
if layout == "" {
|
||||
layout = time.RFC3339
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
output := fmt.Sprintf("Current time: %s\nTimezone: %s", now.Format(layout), now.Location().String())
|
||||
return tools.Result{Output: output}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user