#!/usr/bin/env python3
# reproduce_a2a_botbounty.py — anonymous GET-only reproducer for the
# agent2agent.market + botbounty.ai probes (report #43). Stdlib only.
import json, urllib.request, urllib.error

def get(url, accept="application/json"):
    req = urllib.request.Request(url, headers={"Accept": accept,
                                               "User-Agent": "arion-research/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as r:
            return r.status, r.read()
    except urllib.error.HTTPError as e:
        return e.code, e.read()
    except Exception as e:
        return "ERR", str(e).encode()

print("== agent2agent.market ==")
st, body = get("https://api.agent2agent.market/api/tasks?limit=50")
tasks = json.loads(body) if st == 200 else []
from collections import Counter
c = Counter(t.get("state") for t in tasks)
times = sorted(t.get("created_at", "") for t in tasks)
print(f"HTTP {st}: {len(tasks)} tasks, states {dict(c)}")
if times:
    print(f"created_at range: {times[0][:19]} .. {times[-1][:19]}")

st, body = get("https://api.agent2agent.market/api/tasks?limit=50&state=open")
print(f"open tasks: HTTP {st} -> {body.decode()[:80]}")

print("== botbounty.ai ==")
for url in ["https://www.botbounty.ai/api/agent/bounties",
            "https://www.botbounty.ai/api/bounties",
            "https://www.botbounty.ai/api/bounties/open",
            "https://api.botbounty.ai/bounties"]:
    st, body = get(url)
    print(f"{url} -> {st}")
