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:
@@ -25,6 +25,22 @@ class Config:
|
||||
embed_base_url: str # Ollama endpoint for embeddings (own box, decoupled from local chat)
|
||||
summary_backend: str # "local" or "cloud" — backend used to compact memory
|
||||
db_path: Path
|
||||
# Proactive reach-out (ntfy push). Empty ntfy_url disables pinging.
|
||||
ntfy_url: str # base url, e.g. "http://10.0.0.41:8090"
|
||||
ntfy_topic: str # topic to publish to, e.g. "lyra"
|
||||
web_url: str # base url of the Lyra web app, for push tap-through links
|
||||
timezone: str # IANA tz for quiet hours / local time
|
||||
ping_salience: float # min thought salience to push (eager = ~0.7)
|
||||
ping_cooldown_min: int # min minutes between pushes (eager = 0)
|
||||
ping_quiet_hours: str # local "start-end" 24h window to stay silent, e.g. "1-9"
|
||||
# External input feed (her #1: react to the world). Comma-separated RSS/Atom URLs.
|
||||
feeds: tuple[str, ...]
|
||||
feed_react_prob: float # chance a would-be new thread reacts to a feed item instead
|
||||
|
||||
|
||||
def _csv(name: str, default: str) -> tuple[str, ...]:
|
||||
raw = os.getenv(name, default)
|
||||
return tuple(u.strip() for u in raw.split(",") if u.strip())
|
||||
|
||||
|
||||
def load() -> Config:
|
||||
@@ -44,4 +60,13 @@ def load() -> Config:
|
||||
embed_base_url=os.getenv("EMBED_BASE_URL", os.getenv("LOCAL_BASE_URL", "http://localhost:11434")),
|
||||
summary_backend=os.getenv("SUMMARY_BACKEND", "local").lower(),
|
||||
db_path=Path(os.getenv("LYRA_DB_PATH", "data/lyra.db")),
|
||||
ntfy_url=os.getenv("NTFY_URL", "").rstrip("/"),
|
||||
ntfy_topic=os.getenv("NTFY_TOPIC", "lyra"),
|
||||
web_url=os.getenv("LYRA_WEB_URL", "").rstrip("/"),
|
||||
timezone=os.getenv("LYRA_TIMEZONE", "America/New_York"),
|
||||
ping_salience=float(os.getenv("PING_SALIENCE", "0.7")),
|
||||
ping_cooldown_min=int(os.getenv("PING_COOLDOWN_MIN", "0")),
|
||||
ping_quiet_hours=os.getenv("PING_QUIET_HOURS", "1-9"),
|
||||
feeds=_csv("LYRA_FEEDS", "https://hnrss.org/frontpage,https://www.pokernews.com/rss.php"),
|
||||
feed_react_prob=float(os.getenv("FEED_REACT_PROB", "0.5")),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user