53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
// tool/agent.go – Tool-Agent: Dispatcher für externe Tools (Email, ...)
|
||
package tool
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"my-brain-importer/internal/agents"
|
||
"my-brain-importer/internal/agents/tool/email"
|
||
)
|
||
|
||
// Agent verteilt Tool-Anfragen an spezialisierte Sub-Agenten.
|
||
type Agent struct{}
|
||
|
||
func New() *Agent { return &Agent{} }
|
||
|
||
// Handle unterstützt: email
|
||
func (a *Agent) Handle(req agents.Request) agents.Response {
|
||
switch req.Action {
|
||
case agents.ActionEmail:
|
||
return a.handleEmail(req)
|
||
default:
|
||
return agents.Response{Text: "❌ Unbekannte Tool-Aktion. Verfügbar: email"}
|
||
}
|
||
}
|
||
|
||
func (a *Agent) handleEmail(req agents.Request) agents.Response {
|
||
subAction := agents.ActionEmailSummary
|
||
if len(req.Args) > 0 {
|
||
subAction = req.Args[0]
|
||
}
|
||
|
||
var (
|
||
result string
|
||
err error
|
||
)
|
||
|
||
switch subAction {
|
||
case agents.ActionEmailSummary:
|
||
result, err = email.Summarize()
|
||
case agents.ActionEmailUnread:
|
||
result, err = email.SummarizeUnread()
|
||
case agents.ActionEmailRemind:
|
||
result, err = email.ExtractReminders()
|
||
default:
|
||
return agents.Response{Text: fmt.Sprintf("❌ Unbekannte Email-Aktion `%s`. Verfügbar: summary, unread, remind", subAction)}
|
||
}
|
||
|
||
if err != nil {
|
||
return agents.Response{Error: err, Text: fmt.Sprintf("❌ Email-Fehler: %v", err)}
|
||
}
|
||
return agents.Response{Text: "📧 **Email-Analyse:**\n\n" + result}
|
||
}
|