feat: thought loop reach-out (ntfy push) + external input feeds
Her remaining two wishes from the 6-19 sketch: Proactive reach-out (#6, literal): lyra/notify.py pushes to ntfy so she can reach Brian when he's not in the app. thoughts.maybe_ping gates on salience, a cooldown, and local quiet hours (all config-tunable; eager defaults), uses ntfy JSON publish (UTF-8 titles/messages), links to /thoughts, and marks the thread surfaced so chat won't also re-raise it. Disabled unless NTFY_URL is set. External input feed (#1): lyra/feeds.py pulls configurable RSS/Atom feeds (stdlib ElementTree, no new dep; tolerant of RSS 2.0 + Atom), dedupes seen items in a feed_items table, and hands think() one fresh item at a time. New 'react' mode: a would-be new thread instead reacts to a world item (FEED_REACT_PROB). Dream cycle refreshes feeds on its cadence; failures degrade to no item. Config: NTFY_URL/NTFY_TOPIC/LYRA_WEB_URL, PING_SALIENCE/COOLDOWN/QUIET_HOURS, LYRA_TIMEZONE, LYRA_FEEDS, FEED_REACT_PROB (+ .env.example). thought_meta table for ping cooldown. 10 new tests (feeds parse, react mode, ping gating); suite 65. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -25,7 +25,7 @@ import argparse
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from lyra import config, era, logbus, memory, narrative, profile, self_state, summary, thoughts
|
||||
from lyra import config, era, feeds, logbus, memory, narrative, profile, self_state, summary, thoughts
|
||||
from lyra.llm import Backend
|
||||
from lyra.summary import SUMMARIZE_AFTER
|
||||
|
||||
@@ -81,6 +81,12 @@ def dream_cycle(backend: Backend | None = None, force: bool = False) -> dict:
|
||||
# Thought-loop housekeeping (no LLM): rest stale threads so the open-thread cap
|
||||
# never jams and the feed stays current. Cheap; run every pass.
|
||||
thoughts.decay()
|
||||
# Pull external feeds on the cycle cadence (~30 min) so she has fresh items from
|
||||
# the world to react to. Network-only; failures degrade to no new items.
|
||||
try:
|
||||
feeds.refresh()
|
||||
except Exception as exc:
|
||||
logbus.log("error", "feed refresh failed", error=str(exc)[:160])
|
||||
|
||||
actions: list[str] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user