import requests from smolagents import tool from tools.simple_text_browser import _BROWSER @tool def simple_search(query: str) -> str: """ Perform a DuckDuckGo web search and return the top snippets. Args: query: The search query to perform. """ return _BROWSER.search(query) @tool def archive_search(url: str, date: str) -> str: """ Given a URL and a date (YYYYMMDD), returns the archived snapshot text via Wayback. Args: url: The original URL to look up. date: The desired snapshot date as YYYYMMDD. """ api = f"https://archive.org/wayback/available?url={url}×tamp={date}" data = requests.get(api, timeout=10).json() snap = data.get("archived_snapshots", {}).get("closest", {}).get("url") if not snap: return f"No archive found for {url} at {date}." return _BROWSER.visit_page(snap)