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.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package memory
|
||||
|
||||
import "github.com/enmanuel/agents/pkg/llm"
|
||||
|
||||
// Window is an immutable sliding window of conversation messages for a single room.
|
||||
type Window struct {
|
||||
messages []llm.Message
|
||||
maxSize int
|
||||
}
|
||||
|
||||
// NewWindow creates an empty window with the given capacity.
|
||||
func NewWindow(maxSize int) Window {
|
||||
return Window{maxSize: maxSize}
|
||||
}
|
||||
|
||||
// Append returns a new Window with the message added, dropping the oldest
|
||||
// messages if capacity is exceeded.
|
||||
func (w Window) Append(msg llm.Message) Window {
|
||||
msgs := make([]llm.Message, len(w.messages), len(w.messages)+1)
|
||||
copy(msgs, w.messages)
|
||||
msgs = append(msgs, msg)
|
||||
if len(msgs) > w.maxSize {
|
||||
msgs = msgs[len(msgs)-w.maxSize:]
|
||||
}
|
||||
return Window{messages: msgs, maxSize: w.maxSize}
|
||||
}
|
||||
|
||||
// ToLLMMessages returns a copy of the window contents as []llm.Message.
|
||||
func (w Window) ToLLMMessages() []llm.Message {
|
||||
out := make([]llm.Message, len(w.messages))
|
||||
copy(out, w.messages)
|
||||
return out
|
||||
}
|
||||
|
||||
// Len returns the number of messages in the window.
|
||||
func (w Window) Len() int {
|
||||
return len(w.messages)
|
||||
}
|
||||
|
||||
// Clear returns an empty window with the same capacity.
|
||||
func (w Window) Clear() Window {
|
||||
return NewWindow(w.maxSize)
|
||||
}
|
||||
Reference in New Issue
Block a user