refactor: extraer campo sender en Agent para desacoplar envio de mensajes
Añade un campo `sender effects.MatrixSender` al struct Agent que reemplaza las llamadas directas a `a.matrix` para enviar mensajes (sendReply, typing, SendMarkdown en handleTaskEvent). En produccion, sender apunta al mismo *matrix.Client. Esto permite inyectar un spy en tests sin requerir una conexion real a Matrix. El campo `a.matrix` se mantiene para operaciones que no son de envio (SetPresence, Raw, etc.). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,7 @@ type Agent struct {
|
||||
rules []decision.Rule
|
||||
llm coretypes.CompleteFunc // nil when no LLM configured (simple_bot)
|
||||
matrix *matrix.Client
|
||||
sender effects.MatrixSender // used by sendReply; same object as matrix in production
|
||||
runner *effects.Runner
|
||||
listener *matrix.Listener
|
||||
toolReg *tools.Registry
|
||||
@@ -157,6 +158,7 @@ func New(cfg *config.AgentConfig, rules []decision.Rule, agentACL acl.ACL, logge
|
||||
rules: rules,
|
||||
llm: llmFunc,
|
||||
matrix: matrixClient,
|
||||
sender: matrixClient,
|
||||
runner: runner,
|
||||
toolReg: toolReg,
|
||||
logger: logger,
|
||||
|
||||
Reference in New Issue
Block a user