| 63 | |
| 64 | |
| 65 | def _build_summary(results: list[tuple[str, AgentResponse]], date_prefix: str) -> str: |
| 66 | lines = [ |
| 67 | "# OpenOSINT Multi-Target Investigation Summary", |
| 68 | "", |
| 69 | f"**Date:** {date_prefix} ", |
| 70 | f"**Targets investigated:** {len(results)}", |
| 71 | "", |
| 72 | "---", |
| 73 | "", |
| 74 | ] |
| 75 | for target, response in results: |
| 76 | lines.append(f"## {target}") |
| 77 | lines.append("") |
| 78 | if response.error: |
| 79 | lines.append(f"**Error:** {response.error}") |
| 80 | elif response.content: |
| 81 | content = response.content |
| 82 | summary_start = content.find("## Summary") |
| 83 | conclusion_start = content.find("## Conclusion") |
| 84 | if summary_start != -1: |
| 85 | end = conclusion_start if conclusion_start != -1 else len(content) |
| 86 | lines.append(content[summary_start:end].strip()) |
| 87 | else: |
| 88 | excerpt = content[:500].strip() |
| 89 | if len(content) > 500: |
| 90 | excerpt += "…" |
| 91 | lines.append(excerpt) |
| 92 | else: |
| 93 | lines.append("No findings.") |
| 94 | lines.append("") |
| 95 | lines.append("---") |
| 96 | lines.append("") |
| 97 | return "\n".join(lines) |
| 98 | |
| 99 | |
| 100 | # --------------------------------------------------------------------------- |