feat(impressum): Snapshot-Modul-Tab — ImpressumAgent auf gespeichertem Text
Snapshot-Detailseite wird zu Modul-Tabs (Cookies & Tracking | Impressum).
Backend GET /snapshots/{id}/impressum-check laeuft den v3 ImpressumAgent auf
dem gespeicherten Impressum-Text (kein Re-Crawl); Input-Erzeugung in
impressum_input_from_snapshot() ausgelagert (pure + getestet: Text/Scope/
company_name-Fallback/None-Pfad). Frontend laedt lazy beim Tab-Wechsel und
rendert mit dem bestehenden AgentResultTab (keine zweite Engine).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,31 @@ def _derive_scope(profile_dict: dict) -> list[str]:
|
||||
return sorted(scope)
|
||||
|
||||
|
||||
def impressum_input_from_snapshot(snap: dict) -> dict | None:
|
||||
"""Baut den ImpressumAgent-Input aus einem gespeicherten Snapshot (kein
|
||||
Re-Crawl). Pure + testbar: zieht den Impressum-Text aus doc_entries, leitet
|
||||
den Scope aus scan_context + Profil ab (identisch zur Live-Auswertung) und
|
||||
nimmt site_label als company_name-Fallback. None, wenn kein Impressum-Text.
|
||||
"""
|
||||
docs = snap.get("doc_entries") or []
|
||||
text = next((e.get("text") or e.get("content") or ""
|
||||
for e in docs if e.get("doc_type") == "impressum"), "")
|
||||
if len((text or "").strip()) < _MIN_TEXT:
|
||||
return None
|
||||
profile = snap.get("profile") or {}
|
||||
scope = sorted(
|
||||
set(scan_context_to_scope(snap.get("scan_context")))
|
||||
| set(_derive_scope(profile))
|
||||
)
|
||||
return {
|
||||
"doc_type": "impressum",
|
||||
"text": text,
|
||||
"business_scope": scope,
|
||||
"company_name": (profile.get("company_name") or snap.get("site_label") or ""),
|
||||
"origin_domain": snap.get("site_domain", ""),
|
||||
}
|
||||
|
||||
|
||||
async def run_agent_outputs(state: dict) -> None:
|
||||
"""Für jedes Topic mit registriertem v3-Agent + ausreichend Text:
|
||||
Agent laufen lassen, AgentOutput ablegen + als SSE topic-Event
|
||||
|
||||
Reference in New Issue
Block a user