feat(summarizer): add SummarizeForPush and use for Pushover; keep full WebUI/on-demand output; clamp only on push\ndocs: add AGENTS.md; revert CLAUDE.md release section
This commit is contained in:
parent
2f9ab6a414
commit
8dc52976eb
7 changed files with 512 additions and 21 deletions
|
|
@ -156,7 +156,14 @@ func (s *Server) handleTrigger(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
ctxSum, cancel := context.WithTimeout(ctx, tout)
|
||||
defer cancel()
|
||||
summary, err := s.Summarizer.Summarize(ctxSum, channel, msgs, window)
|
||||
var summary string
|
||||
var err error
|
||||
// If we will push, use a push-optimized prompt; otherwise allow full-length
|
||||
if strings.EqualFold(r.URL.Query().Get("push"), "1") || strings.EqualFold(r.URL.Query().Get("push"), "true") {
|
||||
summary, err = s.Summarizer.SummarizeForPush(ctxSum, channel, msgs, window)
|
||||
} else {
|
||||
summary, err = s.Summarizer.Summarize(ctxSum, channel, msgs, window)
|
||||
}
|
||||
if err != nil {
|
||||
if s.Logger != nil {
|
||||
s.Logger.Error("http trigger summarizer", "err", err)
|
||||
|
|
@ -167,13 +174,18 @@ func (s *Server) handleTrigger(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
// Only push if explicitly requested
|
||||
pushFlag := strings.EqualFold(r.URL.Query().Get("push"), "1") || strings.EqualFold(r.URL.Query().Get("push"), "true")
|
||||
if pushFlag && s.Notifier != nil {
|
||||
title := fmt.Sprintf("IRC digest %s (%s)", channel, window)
|
||||
_ = s.Notifier.Notify(ctx, title, summary)
|
||||
if s.Metrics != nil {
|
||||
atomic.AddInt64(&s.Metrics.NotificationsSent, 1)
|
||||
}
|
||||
}
|
||||
if pushFlag && s.Notifier != nil {
|
||||
title := fmt.Sprintf("IRC digest %s (%s)", channel, window)
|
||||
// Trim only for push notifications (Pushover limit ~1024)
|
||||
msg := strings.TrimSpace(summary)
|
||||
if len(msg) > 1000 {
|
||||
msg = msg[:1000] + "…"
|
||||
}
|
||||
_ = s.Notifier.Notify(ctx, title, msg)
|
||||
if s.Metrics != nil {
|
||||
atomic.AddInt64(&s.Metrics.NotificationsSent, 1)
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
_, _ = w.Write([]byte(summary))
|
||||
}
|
||||
|
|
@ -720,13 +732,16 @@ func (s *Server) handleTriggerJSON(w http.ResponseWriter, r *http.Request) {
|
|||
_, _ = w.Write([]byte("summarizer error"))
|
||||
return
|
||||
}
|
||||
if push && s.Notifier != nil {
|
||||
title := fmt.Sprintf("IRC digest %s (%s)", channel, dur)
|
||||
_ = s.Notifier.Notify(r.Context(), title, sum)
|
||||
if s.Metrics != nil {
|
||||
atomic.AddInt64(&s.Metrics.NotificationsSent, 1)
|
||||
}
|
||||
}
|
||||
if push && s.Notifier != nil {
|
||||
title := fmt.Sprintf("IRC digest %s (%s)", channel, dur)
|
||||
// Safety clamp for provider limits
|
||||
msg := strings.TrimSpace(sum)
|
||||
if len(msg) > 1024 { msg = msg[:1024] }
|
||||
_ = s.Notifier.Notify(r.Context(), title, msg)
|
||||
if s.Metrics != nil {
|
||||
atomic.AddInt64(&s.Metrics.NotificationsSent, 1)
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"summary": sum})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue