Files
unibots/shell/transportunibus/demo.go
T
agent fc644ecd6e feat: import agents_and_robots platform as unibots (Matrix-out, unibus transport)
Reemplaza el scaffold del echobot por la plataforma completa de bots traida
desde ~/DataProyects/Github/agents_and_robots tras la operacion Matrix-out:
los bots ya no hablan por Matrix sino por el bus unibus (modelo todo-rooms +
E2E via shell/transportunibus sobre github.com/enmanuel/unibus/pkg/client).

- go.mod: replace de unibus -> ../unibus y de fn-registry -> ../../../.. (paths
  relativos reajustados a la nueva ubicacion dentro de fn_registry).
- app.md: bump a 0.2.0, descripcion + arquitectura + comandos + gotchas reales.
- modulo Go conservado como github.com/enmanuel/agents (sin reescribir imports).

agents_and_robots queda archivado como museo de la era Matrix.
2026-06-07 11:50:13 +02:00

36 lines
1.0 KiB
Go

package transportunibus
import (
"context"
"log/slog"
"strings"
"github.com/enmanuel/agents/pkg/transport"
)
// DemoEchoHandler returns a minimal bot handler that proves the unibus transport
// end to end: it receives a neutral InboundMessage and answers in the same room.
// It echoes the message body back as a reply, with one built-in command
// (!ping → pong) to show command routing works over the bus. It is intentionally
// tiny — the point is the transport, not the bot.
func DemoEchoHandler(t transport.Transport, logger *slog.Logger) transport.Handler {
if logger == nil {
logger = slog.Default()
}
return func(ctx context.Context, in transport.InboundMessage) {
reply := "echo: " + in.Body
if strings.TrimSpace(in.Body) == "!ping" {
reply = "pong"
}
out := transport.OutboundReply{
RoomID: in.RoomID,
ReplyTo: in.MsgID,
ThreadID: in.ThreadID,
Markdown: reply,
}
if err := t.Reply(ctx, out); err != nil {
logger.Error("demo echo reply failed", "err", err, "sender", in.SenderID)
}
}
}