llm mail integration

This commit is contained in:
Christoph K.
2026-03-19 21:46:12 +01:00
parent fdc7a8588d
commit 0e7aa3e7f2
19 changed files with 1707 additions and 306 deletions

View File

@@ -0,0 +1,56 @@
// memory/agent.go Memory-Agent: wraps brain.RunIngest und brain.IngestChatMessage
package memory
import (
"fmt"
"strings"
"my-brain-importer/internal/agents"
"my-brain-importer/internal/brain"
"my-brain-importer/internal/config"
)
// Agent verwaltet das Einspeichern von Wissen.
type Agent struct{}
func New() *Agent { return &Agent{} }
// Handle unterstützt zwei Aktionen:
// - "store": Speichert Text als Chat-Nachricht
// - "ingest": Startet den Markdown-Ingest aus brain_root
func (a *Agent) Handle(req agents.Request) agents.Response {
switch req.Action {
case agents.ActionStore:
return a.store(req)
case agents.ActionIngest:
return a.ingest(req)
default:
return agents.Response{Text: "❌ Unbekannte Memory-Aktion. Verfügbar: store, ingest"}
}
}
func (a *Agent) store(req agents.Request) agents.Response {
if len(req.Args) == 0 {
return agents.Response{Text: "❌ Kein Text zum Speichern angegeben."}
}
text := strings.Join(req.Args, " ")
author := req.Author
if author == "" {
author = "unknown"
}
source := req.Source
if source == "" {
source = "agent"
}
err := brain.IngestChatMessage(text, author, source)
if err != nil {
return agents.Response{Error: err, Text: fmt.Sprintf("❌ Fehler beim Speichern: %v", err)}
}
return agents.Response{Text: fmt.Sprintf("✅ Gespeichert: _%s_", text)}
}
func (a *Agent) ingest(_ agents.Request) agents.Response {
brain.RunIngest(config.Cfg.BrainRoot)
return agents.Response{Text: fmt.Sprintf("✅ Ingest abgeschlossen! Quelle: `%s`", config.Cfg.BrainRoot)}
}