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:
+18
-2
@@ -35,8 +35,8 @@ type Tool struct {
|
||||
Exec ToolFunc
|
||||
}
|
||||
|
||||
// getString extracts a string argument by name, returning "" if missing or wrong type.
|
||||
func getString(args map[string]any, key string) string {
|
||||
// GetString extracts a string argument by name, returning "" if missing or wrong type.
|
||||
func GetString(args map[string]any, key string) string {
|
||||
v, ok := args[key]
|
||||
if !ok {
|
||||
return ""
|
||||
@@ -47,3 +47,19 @@ func getString(args map[string]any, key string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// GetInt extracts an integer argument by name, returning 0 if missing or wrong type.
|
||||
func GetInt(args map[string]any, key string) int {
|
||||
v, ok := args[key]
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
switch n := v.(type) {
|
||||
case float64:
|
||||
return int(n)
|
||||
case int:
|
||||
return n
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user