#!/usr/bin/env python3
"""Manual test script for search_web and read_webpage.

Run from repo root (or with PYTHONPATH set) so tools and core can be imported.
Prints the exact return type and truncated content for each call.

Usage:
  python scripts/test_web_tools.py
  python scripts/test_web_tools.py   # from repo root
"""
from __future__ import annotations

import os
import sys

_repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if _repo_root not in sys.path:
    sys.path.insert(0, _repo_root)

def main():
    from tools.web_tools import search_web, read_webpage

    print("=== search_web ===")
    result = search_web.invoke({"query": "Python 3.12 release date"})
    print(f"type: {type(result).__name__}")
    s = str(result)
    print(f"content (first 500 chars): {s[:500]!r}")
    if len(s) > 500:
        print("... [truncated]")
    print()

    print("=== read_webpage (public URL) ===")
    result = read_webpage.invoke({"url": "https://example.com/"})
    print(f"type: {type(result).__name__}")
    s = str(result)
    print(f"content (first 300 chars): {s[:300]!r}")
    if len(s) > 300:
        print("... [truncated]")
    print()

    print("=== read_webpage (SSRF block: localhost) ===")
    result = read_webpage.invoke({"url": "http://localhost/"})
    print(f"type: {type(result).__name__}")
    print(f"content: {result!r}")
    print()

    print("Done.")

if __name__ == "__main__":
    main()
