Add Reminders (CalDAV), Notes, Reading List agents + Mac bridge

This commit is contained in:
2026-04-13 03:20:44 +00:00
parent 852d329379
commit 8cf5bb51ee
4 changed files with 410 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""
Reading List Agent
Fetches Safari "Saved for Later" reading list via the Mac bridge.
Returns a markdown section for the daily briefing.
"""
import sys
from shared import api_request, log_run
AGENT_ID = "reading-list"
DEFAULT_BRIDGE_URL = "http://192.168.1.62:8551"
def run(config=None):
"""Run the reading list agent.
Config keys:
bridge_url: Mac bridge URL (default: http://192.168.1.62:8551)
unread_only: only show unread items (default: True)
limit: max items to show (default: 20)
"""
cfg = config or {}
bridge_url = cfg.get("bridge_url", DEFAULT_BRIDGE_URL)
unread_only = cfg.get("unread_only", True)
limit = cfg.get("limit", 20)
try:
data = api_request(f"{bridge_url}/api/safari/reading-list")
items = data.get("items", [])
if unread_only:
items = [i for i in items if i.get("isUnread", True)]
items = items[:limit]
if not items:
return "## Reading List\n\n*No saved articles.*\n", "No articles"
md = "## Reading List\n\n"
md += "| Article | Saved |\n"
md += "|---------|-------|\n"
for item in items:
title = item.get("title", "Untitled")[:70]
url = item.get("url", "")
date_added = item.get("dateAdded", "")[:10]
# Link the title if we have a URL
display = f"[{title}]({url})" if url else title
md += f"| {display} | {date_added} |\n"
md += "\n"
summary = f"{len(items)} saved article{'s' if len(items) != 1 else ''}"
log_run(AGENT_ID, "success", output=summary)
return md, summary
except Exception as e:
err = f"Reading list error: {e}"
print(f" {err}", file=sys.stderr)
log_run(AGENT_ID, "failed", err=err)
return "## Reading List\n\n*Could not reach Apple Bridge. Is your Mac online?*\n", f"error: {e}"
if __name__ == "__main__":
section, summary = run()
print(section)
print(f"\nSummary: {summary}")