feat: implementar tipo Robot como runtime ligero para bots command-only

Introduce la separacion Robot vs Agent en el sistema:

- agents/types.go: interfaz Runner comun (Run, Stop, Done, RegisterCommand)
  que tanto Agent como Robot satisfacen
- agents/robot.go: struct Robot — runtime minimo que solo conecta a Matrix
  y despacha comandos. Sin LLM, reglas, memoria, knowledge, skills ni tools.
  Mensajes normales se ignoran silenciosamente
- internal/config/schema.go: campo Type en AgentMeta ("agent"|"robot")
- cmd/launcher: usa Runner interface para manejar ambos tipos uniformemente.
  Si cfg.Agent.Type == "robot" crea NewRobot en vez de New (tanto en
  arranque como en hot-reload)
- agents/_template_robot/config.yaml: plantilla minima (~55 lineas) para
  robots command-only

El Robot soporta built-in commands reducidos (help, ping, status, info,
version) y comandos custom via RegisterCommand. No incluye tools, tool,
clear ni prompts ya que no tiene LLM ni memoria.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 23:12:33 +00:00
parent ac5cde3f3e
commit f11f76f39b
6 changed files with 477 additions and 67 deletions
+45 -29
View File
@@ -158,8 +158,6 @@ func main() {
continue
}
rules := rulesFor(cfg.Agent.ID, logger)
// Per-agent logger → writes to logs/<agent-id>/YYYY-MM-DD.jsonl
agentLogger, agentCleanup, aErr := agentlog.NewAgentLogger(agentlog.LoggerConfig{
BaseDir: logDir,
@@ -172,41 +170,59 @@ func main() {
agentCleanup = func() {}
}
// Resolve centralized ACL for this agent
agentACL := pksecurity.ResolveACL(cfg.Agent.ID, deps.secPolicy)
agentLogger.Debug("resolved acl for agent",
"agent", cfg.Agent.ID,
"acl_empty", agentACL.Empty(),
)
// Branch: robot (command-only, lightweight) vs agent (full runtime).
var runner agents.Runner
a, err := agents.New(cfg, rules, agentACL, agentLogger)
if err != nil {
logger.Error("failed to create agent", "id", cfg.Agent.ID, "err", err)
agentCleanup()
continue
}
if cfg.Agent.Type == "robot" {
robot, rErr := agents.NewRobot(cfg, agentLogger)
if rErr != nil {
logger.Error("failed to create robot", "id", cfg.Agent.ID, "err", rErr)
agentCleanup()
continue
}
runner = robot
agentLogger.Info("created robot", "id", cfg.Agent.ID)
} else {
rules := rulesFor(cfg.Agent.ID, logger)
// Connect agent to bus for orchestration
a.SetBus(agentBus)
// Resolve centralized ACL for this agent
agentACL := pksecurity.ResolveACL(cfg.Agent.ID, deps.secPolicy)
agentLogger.Debug("resolved acl for agent",
"agent", cfg.Agent.ID,
"acl_empty", agentACL.Empty(),
)
// If orchestrator is active, wire interceptor and membership notify
if orch != nil {
a.SetInterceptor(orch.orchestrator.Intercept)
a.SetMembershipNotify(orch.orchestrator.NotifyMembership)
a, cErr := agents.New(cfg, rules, agentACL, agentLogger)
if cErr != nil {
logger.Error("failed to create agent", "id", cfg.Agent.ID, "err", cErr)
agentCleanup()
continue
}
orch.orchestrator.RegisterParticipant(orchestration.ParticipantInfo{
ID: cfg.Agent.ID,
MatrixUserID: cfg.Matrix.UserID,
Description: cfg.Agent.Description,
Capabilities: cfg.Agent.Tags,
})
// Connect agent to bus for orchestration
a.SetBus(agentBus)
// Grab the first available Matrix client for room scanning
scannerOnce.set(a.RawMatrixClient())
// If orchestrator is active, wire interceptor and membership notify
if orch != nil {
a.SetInterceptor(orch.orchestrator.Intercept)
a.SetMembershipNotify(orch.orchestrator.NotifyMembership)
orch.orchestrator.RegisterParticipant(orchestration.ParticipantInfo{
ID: cfg.Agent.ID,
MatrixUserID: cfg.Matrix.UserID,
Description: cfg.Agent.Description,
Capabilities: cfg.Agent.Tags,
})
// Grab the first available Matrix client for room scanning
scannerOnce.set(a.RawMatrixClient())
}
runner = a
}
registry.register(&runningAgent{
agent: a,
runner: runner,
cfg: cfg,
cfgPath: path,
logger: agentLogger,