Ryanhub - file viewer
filename: automation/morning.go
branch: main
back to repo
package automation

import (
	"context"
	"strings"
	"time"

	"assistant/agent"
	"assistant/config"
	"assistant/util"
)

func runMorningBriefing(ctx context.Context, cfg *config.Config, ag *agent.Agent, tel *agent.Telemetry) {
	if ag == nil {
		return
	}
	var b strings.Builder
	b.WriteString("Produce a concise morning briefing for the user. ")
	b.WriteString("Use the weather and news tools. ")
	if cfg.Tools.Tasks.Enabled {
		b.WriteString("If task tools are available, list open tasks and suggest priorities. ")
	}
	b.WriteString("Stay under about 400 words.")
	prompt := b.String()
	reply, err := ag.Run(ctx, prompt)
	if err != nil {
		util.Logf("morning briefing failed: %v", err)
		if tel != nil {
			tel.SetAutomationLast("morning_briefing", time.Now(), false, err.Error())
		}
		return
	}
	util.Logf("morning briefing:\n%s", reply)
	if tel != nil {
		tel.SetAutomationLast("morning_briefing", time.Now(), true, "")
	}
}