Files
agents_and_robots/pkg/command/builtins.go
T
egutierrez 33b11a63c8 feat: añadir sistema de comandos directos (!command)
Implementa pkg/command/ como core puro: tipos Spec/ParsedArgs, parser de
args key=value con soporte de comillas, specs de 8 comandos built-in
(help, tools, tool, ping, status, info, clear, version) y BuiltinNames()
para aliases.

En agents/runtime.go: nuevo flujo handleEvent que prioriza comandos sobre
LLM — custom rules del agente → built-in handlers → comando desconocido →
LLM fallback. Handlers en agents/commands.go. El comando !tool ejecuta
tools directamente via Registry con args key=value parseados.

LLM ahora es opcional: si no hay provider configurado, el agente corre
como simple_bot respondiendo solo a comandos.

Se extrae executeActions() como helper reutilizable para ambos flujos
(comando y no-comando).
2026-03-07 01:11:26 +00:00

62 lines
1.4 KiB
Go

package command
// Builtins returns the specs of all built-in commands. Pure.
func Builtins() []Spec {
return []Spec{
{
Name: "help",
Aliases: []string{"h"},
Description: "Lista comandos disponibles",
Usage: "!help",
},
{
Name: "tools",
Description: "Lista tools registradas con descripcion",
Usage: "!tools",
},
{
Name: "tool",
Description: "Ejecutar una tool directamente",
Usage: "!tool <nombre> [key=value ...]",
},
{
Name: "ping",
Description: "Alive check",
Usage: "!ping",
},
{
Name: "status",
Description: "Info del agente: uptime, rooms activos",
Usage: "!status",
},
{
Name: "info",
Description: "Nombre, version y descripcion del agente",
Usage: "!info",
},
{
Name: "clear",
Description: "Limpia ventana de conversacion del room actual",
Usage: "!clear",
},
{
Name: "version",
Aliases: []string{"v"},
Description: "Version del agente",
Usage: "!version",
},
}
}
// BuiltinNames returns just the command names (including aliases) for lookup. Pure.
func BuiltinNames() map[string]string {
m := make(map[string]string)
for _, spec := range Builtins() {
m[spec.Name] = spec.Name
for _, alias := range spec.Aliases {
m[alias] = spec.Name
}
}
return m
}