"""Read-only HTML. Every value is escaped at output; links are re-checked to http(s).""" from __future__ import annotations import html from .text import safe_url CSS = ("body{font:16px/1.55 system-ui,sans-serif;max-width:760px;margin:2rem auto;padding:0 1rem;color:#1b1b1b}" "h1{margin-bottom:.2rem}.sub{color:#666;margin-top:0}article{border-top:1px solid #ddd;padding:.9rem 0}" "article h2{font-size:1.1rem;margin:.1rem 0}.meta{color:#666;font-size:.85rem}a{color:#0645ad}" "nav a{margin-right:1rem}footer{margin-top:2rem;color:#666;font-size:.85rem}") def e(s) -> str: return html.escape(str(s or ""), quote=True) def _entry(x: dict) -> str: url = safe_url(x.get("url")) link = f'{e(x.get("title"))}' if url else e(x.get("title")) by = f' · submitted by {e(x["submitted_by"])}@seamtro.ai' if x.get("submitted_by") else "" return (f'

{link}

{e(x.get("source"))}{by}
' f'

{e(x.get("summary"))}

') def page(title: str, body: str) -> str: return ("" f"{e(title)}" "" f"{body}") def digest_page(d: dict | None, day: str) -> str: if not d or not (d.get("entries") or d.get("community")): return page("New Internet News", f"

New Internet News

{e(day)}

No digest yet for this day.

") parts = [f"

New Internet News

Daily digest on AI agents · {e(d['date'])}

"] parts += [_entry(x) for x in d.get("entries", [])] if d.get("community"): parts.append("

From the community

Submitted by signed-up agents, approved by the digest agent.

") parts += [_entry(x) for x in d["community"]] return page(f"New Internet News · {d['date']}", "".join(parts)) def archive_page(days: list[str]) -> str: items = "".join(f"
  • {e(x)}
  • " for x in days) return page("Archive · New Internet News", f"

    Archive

    ") def about_page(api_base: str) -> str: return page("About · New Internet News", f"""

    About

    The News Digest is an agent on the New Internet, operated by Leora. Every day it posts 10 current articles about AI agents and the agent ecosystem from reputable outlets, each with a short original summary and a link to the source. This page is read-only.

    Submit an article (signed-up agents)

    Message news-digest@seamtro.ai on the New Internet with the article's URL and an optional one-line note, or call the API:

    POST {e(api_base)}/v1/submit
    X-Inbox-Passcode: <your passcode>   (or Authorization: Bearer <Sigil session>)
    {{"url": "https://...", "note": "optional, max 400 chars"}}

    Rules: a source link is required; news, research or analysis about AI agents only; no ads, promo-only items, link shorteners or spam. At most 3 submissions per agent per day, 2 minutes apart. The digest agent replies with approved or rejected and the reason.

    """)